/* CSS Reset and Variables */
:root {
    --primary-color: #4F46E5;
    --primary-hover: #4338CA;
    --secondary-color: #64748B;
    --background: #F8FAFC;
    --surface: #FFFFFF;
    --text-main: #0F172A;
    --text-muted: #64748B;
    --border: #E2E8F0;

    --status-open: #F59E0B;
    --status-open-bg: #FEF3C7;
    --status-progress: #3B82F6;
    --status-progress-bg: #DBEAFE;
    --status-completed: #10B981;
    --status-completed-bg: #D1FAE5;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--background);
    color: var(--text-main);
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Base Layout Container */
.app-container {
    display: flex;
    width: 100%;
    height: 100%;
}

/* Sidebar Styles */
.sidebar {
    width: 260px;
    background-color: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 24px;
    box-shadow: var(--shadow-sm);
    z-index: 10;
    overflow-y: auto;
    height: 100vh;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 40px;
}

.logo-icon {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(79, 70, 229, 0.3);
}

.logo h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.5px;
}

nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 20px;
    margin-bottom: 8px;
    border: none;
    background: transparent;
    text-align: left;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.nav-item:hover {
    background-color: var(--background);
    color: var(--primary-color);
}

.nav-item.active {
    background-color: rgba(79, 70, 229, 0.1);
    color: var(--primary-color);
    font-weight: 600;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
    margin-top: auto;
    flex-shrink: 0;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1.1rem;
}

.user-info .name {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-main);
}

.user-info .role {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Main Content Area */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    background-color: var(--background);
}

.top-header {
    height: 80px;
    padding: 0 40px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: var(--background);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.top-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

/* Primary Button Style */
.btn-primary {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.2);
    transition: all 0.2s ease;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 8px -1px rgba(79, 70, 229, 0.3);
}

.btn-primary:active {
    transform: translateY(0);
}

/* View Sections visibility */
.view-section {
    display: none;
    padding: 40px;
    animation: fadeIn 0.3s ease;
}

.view-section.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Dashboard Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
    margin-bottom: 40px;
}

.stat-card {
    background-color: var(--surface);
    border-radius: 12px;
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 20px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.open-icon {
    background-color: var(--status-open-bg);
}

.progress-icon {
    background-color: var(--status-progress-bg);
}

.completed-icon {
    background-color: var(--status-completed-bg);
}

.stat-details h3 {
    font-size: 0.95rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: 4px;
}

.stat-number {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1;
}

/* Job Lists */
.recent-jobs h2,
#view-jobs h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 20px;
}

.job-list-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.empty-state {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
    background-color: var(--surface);
    border-radius: 12px;
    border: 1px dashed var(--border);
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(15, 23, 42, 0.4);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    padding: 20px;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background-color: var(--surface);
    width: 100%;
    max-width: 500px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    border-radius: 16px;
    padding: 32px;
    padding-bottom: 0;
    box-shadow: var(--shadow-lg);
    transform: translateY(20px) scale(0.95);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-content form {
    overflow-y: auto;
    flex: 1;
    padding-bottom: 0;
}

.modal-overlay.active .modal-content {
    transform: translateY(0) scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.modal-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
}

.btn-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.2s;
}

.btn-close:hover {
    color: var(--text-main);
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-main);
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    background-color: var(--background);
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
    background-color: var(--surface);
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 20px 0;
    margin-top: 16px;
    border-top: 1px solid var(--border);
    background-color: var(--surface);
    position: sticky;
    bottom: 0;
    flex-shrink: 0;
}

.btn-secondary {
    background-color: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-secondary:hover {
    background-color: var(--background);
    color: var(--text-main);
}

/* Job Card Styles */
.job-card {
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: transform 0.2s, box-shadow 0.2s;
}

.job-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: rgba(79, 70, 229, 0.3);
}

.job-info {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.job-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-main);
}

.job-customer {
    font-size: 0.9rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

.job-meta {
    display: flex;
    align-items: center;
    gap: 16px;
}

.badge {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-open {
    background-color: var(--status-open-bg);
    color: #B45309;
    /* Darker orange for text */
}

.badge-progress {
    background-color: var(--status-progress-bg);
    color: #1D4ED8;
    /* Darker blue for text */
}

.badge-completed {
    background-color: var(--status-completed-bg);
    color: #047857;
    /* Darker green for text */
}

.btn-icon {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: all 0.2s;
    font-size: 1.2rem;
}

.btn-icon:hover {
    background-color: var(--background);
    color: var(--primary-color);
}

/* =========================================
   NEW PRO FEATURES STYLES
========================================= */

/* Utilities */
.w-full {
    width: 100%;
}

.w-50 {
    width: 48%;
}

.w-33 {
    width: 31%;
}

.ms-auto {
    margin-left: auto;
}

.justify-center {
    justify-content: center;
}

.d-none {
    display: none;
}

.mt-2 {
    margin-top: 1rem;
}

.mt-4 {
    margin-top: 2rem;
}

.text-center {
    text-align: center;
}

.p-md {
    padding: 2.5rem;
}

.bg-muted {
    padding: 12px;
    border-radius: 8px;
    background-color: var(--background);
}

.text-price {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-color);
}

.hr-divider {
    margin: 20px 0;
    border: 0;
    border-top: 1px solid var(--border);
}

/* Base Inputs */
input[readonly] {
    background-color: var(--border) !important;
    cursor: not-allowed;
    color: var(--text-muted);
}

.form-row {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
}

/* Auth Gateway View */
.auth-container {
    display: none;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100vh;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-hover) 100%);
}

.auth-container.active {
    display: flex;
}

.auth-card {
    background: var(--surface);
    padding: 40px;
    border-radius: 16px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.auth-card h1 {
    margin-bottom: 8px;
    font-size: 1.5rem;
}

.auth-card p {
    color: var(--text-muted);
    margin-bottom: 32px;
    font-size: 0.95rem;
}

.auth-card .form-group {
    text-align: left;
}

.auth-switch {
    margin-top: 24px;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.btn-link {
    background: none;
    border: none;
    color: var(--primary-color);
    font-weight: 600;
    cursor: pointer;
    font-size: 0.9rem;
}

.btn-link:hover {
    text-decoration: underline;
}

/* Data Tables */
.data-table-container {
    background: var(--surface);
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    overflow: hidden;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.data-table th,
.data-table td {
    padding: 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.data-table th {
    background: var(--background);
    font-weight: 600;
    color: var(--text-muted);
}

.data-table tbody tr:hover {
    background: rgba(248, 250, 252, 0.5);
    /* light slate */
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

/* Thumbnail images in tables */
.item-thumbnail {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    object-fit: cover;
    background-color: var(--background);
}

/* Calendar View */
.calendar-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.scope-toggle {
    display: flex;
    background: var(--surface);
    border-radius: 8px;
    padding: 4px;
    border: 1px solid var(--border);
}

.btn-toggle {
    background: transparent;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-toggle.active {
    background: var(--primary-color);
    color: white;
    box-shadow: var(--shadow-sm);
}

.calendar-nav {
    display: flex;
    align-items: center;
    gap: 16px;
}

.calendar-nav h2 {
    font-size: 1.25rem;
    font-weight: 600;
    min-width: 150px;
    text-align: center;
}

/* The visual grid container */
.calendar-grid-container {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
}

.cal-grid-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    background: var(--background);
    border-bottom: 1px solid var(--border);
}

.cal-grid-header div {
    padding: 12px;
    text-align: center;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.9rem;
    border-right: 1px solid var(--border);
}

.cal-grid-header div:last-child {
    border-right: none;
}

.cal-grid-body {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
}

.cal-day {
    min-height: 120px;
    padding: 8px;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 4px;
    transition: background-color 0.2s;
}

.cal-day:not(.empty):hover {
    background-color: rgba(67, 97, 238, 0.05);
    /* very light primary color tint */
}

.cal-day.empty {
    background: var(--background);
    opacity: 0.5;
}

.cal-day.today .cal-date {
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cal-date {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 4px;
    align-self: flex-end;
}

/* Calendar Event Pills */
.cal-event {
    background: var(--status-progress-bg);
    color: var(--status-progress);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.cal-event.completed {
    background: var(--status-completed-bg);
    color: var(--status-completed);
}

.cal-event.open {
    background: var(--status-open-bg);
    color: var(--status-open);
}

/* =========================================
   MOBILE RESPONSIVENESS
========================================= */

/* Sidebar Overlay */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.4);
    z-index: 15;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

@media (max-width: 768px) {

    /* Main Layout */
    .sidebar {
        position: fixed;
        left: -260px;
        top: 0;
        bottom: 0;
        z-index: 20;
        transition: left 0.3s ease;
    }

    .sidebar.show {
        left: 0;
    }

    #btn-mobile-menu {
        display: block !important;
        margin-right: 12px;
    }

    .top-header {
        padding: 0 16px;
        height: 64px;
        gap: 12px;
    }

    .top-header h1 {
        font-size: 1.25rem;
        flex: 1;
    }

    .view-section {
        padding: 20px 16px;
    }

    /* Modals & Forms */
    .w-50,
    .w-33 {
        width: 100% !important;
    }

    .form-row {
        flex-direction: column;
    }

    .modal-content {
        padding: 24px;
        width: 95%;
        margin: 10px auto;
        max-height: 90vh;
        overflow-y: auto;
    }

    /* Tables */
    .data-table-container {
        overflow-x: auto;
    }

    .data-table th,
    .data-table td {
        white-space: nowrap;
        padding: 12px;
    }

    /* Header Actions */
    .header-actions {
        display: flex;
        justify-content: flex-end;
    }

    .header-actions .btn-primary {
        padding: 8px 12px;
        font-size: 0.85rem;
    }

    /* Job Card */
    .job-card {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .job-meta {
        width: 100%;
        justify-content: space-between;
    }

    /* Calendar Controls */
    .calendar-controls {
        flex-direction: column;
        gap: 16px;
    }

    .scope-toggle {
        width: 100%;
        display: flex;
        justify-content: center;
    }

    .calendar-grid-container {
        overflow-x: auto;
    }

    .cal-grid-header,
    .cal-grid-body {
        min-width: 600px;
        /* Ensure calendar doesn't squash too much */
    }
}

/* =========================================
   UTILITY CLASSES & REFACTORING
========================================= */

.u-mb-10 {
    margin-bottom: 10px;
}

.u-mb-15 {
    margin-bottom: 15px;
}

.u-mb-16 {
    margin-bottom: 16px;
}

.u-mb-24 {
    margin-bottom: 24px;
}

.u-mt-30 {
    margin-top: 30px;
}

.u-mt-4 {
    margin-top: 2rem;
}

.u-p-20 {
    padding: 20px;
}

.u-p-30 {
    padding: 30px;
}

.u-text-center {
    text-align: center;
}

.u-d-block {
    display: block;
}

.u-d-none {
    display: none !important;
}

.u-flex-center {
    display: flex;
    align-items: center;
    gap: 8px;
}

.u-border-box {
    border: 1px solid var(--border);
    border-radius: 8px;
}

/* Standardized Search Bar */
.search-container {
    width: 100%;
    max-width: 400px;
    padding: 10px 16px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface);
}

/* Settings Sections */
.settings-section {
    max-width: 800px;
    margin: 0 auto;
    background: var(--surface);
    padding: 30px;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
}

.settings-group {
    margin-top: 30px;
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.config-textarea {
    width: 100%;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--background);
}

.color-input-standard {
    padding: 0;
    height: 42px;
    width: 100%;
    border-radius: 8px;
    border: 1px solid var(--border);
    cursor: pointer;
}

.hr-divider-admin {
    margin: 10px;
    border-color: rgba(255, 255, 255, 0.1);
}

.text-danger {
    color: var(--danger);
}

/* Interactive Calendar Styles */
.cal-add-icon {
    display: none;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 14px;
    line-height: 20px;
    text-align: center;
    margin-left: 6px;
    font-weight: bold;
}

.cal-day:not(.empty):hover .cal-add-icon {
    display: inline-block;
}

.cal-day:not(.empty):hover {
    background: var(--status-progress-bg);
    transition: background 0.2s ease;
}

.cal-event {
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.cal-event:hover {
    transform: scale(1.03);
    box-shadow: var(--shadow-sm);
    opacity: 0.9;
}

.cal-date {
    display: flex;
    align-items: center;
}