/* ==========================================================================
   1. CSS Variables & Base Styles
   ========================================================================== */
:root {
    --color-primary: #3b82f6;      /* blue-500 */
    --color-primary-dark: #2563eb; /* blue-600 */
    --color-text-base: #334155;    /* slate-700 */
    --color-text-muted: #64748b;   /* slate-500 */
    --color-bg-base: #f1f5f9;      /* slate-100 */
    --color-surface: #ffffff;     /* white */
    --font-sans: 'Inter', sans-serif;
}

body {
    font-family: var(--font-sans);
    color: var(--color-text-base);
    background-color: var(--color-bg-base);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ==========================================================================
   2. Layout & Navigation
   ========================================================================== */
#main-content {
    height: 100vh;
    overflow-y: auto;
    padding-bottom: 5rem; /* Space for mobile bottom nav */
}

@media (min-width: 1024px) {
    #main-content {
        padding-bottom: 2rem; /* Reset padding for desktop */
    }
}

.nav-link {
    color: var(--color-text-muted);
}
/* Desktop Sidebar Active State */
#sidebar-nav .nav-link.active {
    background-color: var(--color-primary);
    color: white;
}
/* Mobile Bottom Nav Active State */
#bottom-nav .nav-link.active {
    color: var(--color-primary);
}

/* ==========================================================================
   3. Modals & Overlays
   ========================================================================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(15, 23, 42, 0.6); /* slate-900 with opacity */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    z-index: 100;
}

.modal-content {
    background-color: var(--color-surface);
    border-radius: 0.75rem; /* 12px */
    width: 100%;
    box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #e2e8f0; /* slate-200 */
    flex-shrink: 0;
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex-grow: 1;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem; /* 12px */
    padding: 1rem 1.5rem;
    background-color: #f8fafc; /* slate-50 */
    border-top: 1px solid #e2e8f0; /* slate-200 */
    border-bottom-left-radius: 0.75rem;
    border-bottom-right-radius: 0.75rem;
    flex-shrink: 0;
}

/* ==========================================================================
   4. Reusable Component Styles
   ========================================================================== */

/* Calendar */
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; text-align: center; }
.calendar-day { padding: 8px 4px; border-radius: 9999px; cursor: pointer; position: relative; transition: all 0.2s; }
.calendar-day.has-job::after { content: ''; position: absolute; bottom: 4px; left: 50%; transform: translateX(-50%); width: 5px; height: 5px; border-radius: 50%; background-color: var(--color-primary); }
.calendar-day:not(.is-selected):hover { background-color: #e2e8f0; } /* slate-200 */
.calendar-day.is-today { background-color: #f1f5f9; font-weight: 700; border: 1px solid #cbd5e1; }
.calendar-day.is-selected { background-color: var(--color-primary-dark); color: white; }
.calendar-day.is-selected.has-job::after { background-color: white; }
.calendar-day.other-month { color: #d1d5db; cursor: default; }

/* Line Items & Dragging */
.sortable-ghost { opacity: 0.4; background: #e0e7ff; }
.drag-handle { cursor: move; cursor: grab; }
.drag-handle:active { cursor: grabbing; }

/* Form Inputs */
input, textarea, select { transition: border-color 0.2s, box-shadow 0.2s; }
input:focus, textarea:focus, select:focus {
    border-color: var(--color-primary) !important;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.4) !important;
    outline: none !important;
}
#line-items-container textarea.autoresize-notes {
    resize: none;
}

/* ==========================================================================
   5. Utility & Print Styles
   ========================================================================== */
.no-print { display: block; }

@media print {
    body, #app-container, #main-content {
        background: white !important;
        padding: 0 !important;
        margin: 0 !important;
        overflow: visible !important;
    }
    .no-print { display: none !important; }
    #main-content > * { display: none; }
    #main-content > #preview-wrapper { display: block; }

    /* --- NEW RULES TO FIX PRINTING --- */
    #preview-wrapper {
        transform: none !important;
        height: auto !important;
        width: 100% !important;
        overflow: visible !important;
        box-shadow: none !important;
    }

    #preview-for-pdf {
        transform: none !important;
        box-shadow: none !important;
        width: 100% !important;
        height: auto !important;
        display: block !important;
    }
    /* --- END OF NEW RULES --- */
}

#pdf-render-container {
    position: absolute; left: -9999px; top: -9999px; width: 800px;
}

/* === NEW RULE TO FIX SIDEBAR VISIBILITY === */
/* Force-hide nav elements when user is logged out */
body.logged-out #sidebar-nav,
body.logged-out #bottom-nav {
    display: none !important;
}
/* ==========================================================================
   6. Guided Tour Styles
   ========================================================================== */
#tour-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(15, 23, 42, 0.7); /* slate-900 with opacity */
    z-index: 200;
    transition: opacity 0.3s ease-in-out;
}

.tour-highlight {
    position: relative;
    z-index: 201;
    box-shadow: 0 0 0 9999px rgba(15, 23, 42, 0.7);
    border-radius: 6px;
}

#tour-popover {
    position: absolute;
    z-index: 202;
    background-color: var(--color-surface);
    color: var(--color-text-base);
    padding: 1rem;
    border-radius: 0.5rem;
    width: 280px;
    max-width: 90vw;
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    transition: opacity 0.2s, transform 0.2s;
}

#tour-popover[data-popper-placement^='top'] .tour-arrow {
    bottom: -5px;
}

#tour-popover[data-popper-placement^='bottom'] .tour-arrow {
    top: -5px;
}

.tour-arrow,
.tour-arrow::before {
  position: absolute;
  width: 10px;
  height: 10px;
  background: inherit;
}
.tour-arrow {
  visibility: hidden;
}
.tour-arrow::before {
  visibility: visible;
  content: '';
  transform: rotate(45deg);
}
/* ==========================================================================
   7. Line Item Inserter Visibility
   ========================================================================== */

/* On desktop, hide the inserter by default and only show it when hovering the line item wrapper */
.line-item-inserter {
    opacity: 0;
}
.line-item-wrapper:hover .line-item-inserter {
    opacity: 1;
}

/* On mobile screens (less than 1024px), force the inserter on the VERY LAST line item to be permanently visible */
@media (max-width: 1023px) {
    .line-item-wrapper:last-child .line-item-inserter {
        opacity: 1;
    }
}