:root {
    --primary: #10b981;
    --primary-dark: #059669;
    --primary-light: #34d399;
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --bg-card-hover: #f1f5f9;
    --border: rgba(0, 0, 0, 0.08);
    --text-main: #0f172a;
    --text-muted: #64748b;
    --sidebar-width: 280px;
    --navbar-height: 70px;
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(0, 0, 0, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background: var(--bg-main);
    color: var(--text-main);
    overflow-x: hidden;
    color-scheme: light;
}

/* Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    position: fixed;
    height: 100vh;
    z-index: 50;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 2rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo-circle {
    width: 40px;
    height: 40px;
    background: var(--primary);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.5rem;
    color: white;
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.3);
}

.app-name {
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: -0.025em;
    background: linear-gradient(to right, #0f172a, #64748b);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar-nav {
    flex: 1;
    padding: 0.5rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    overflow-y: auto;
}

/* Custom Scrollbar for all elements */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.02);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.25);
}


.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9375rem;
    font-weight: 500;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-item:hover {
    color: var(--text-main);
    background: rgba(0, 0, 0, 0.05);
}

.nav-item.active {
    color: var(--primary-dark);
    background: rgba(16, 185, 129, 0.15);
    border-left: 3px solid var(--primary);
}

.nav-item i {
    font-size: 1.25rem;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    min-width: 0;
    width: calc(100% - var(--sidebar-width));
}

.navbar {
    height: var(--navbar-height);
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    padding: 0 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 40;
}

.page-container {
    padding: 2rem;
    flex: 1;
    min-width: 0;
    width: 100%;
}

/* Kanban Responsive */
.kanban-container {
    display: flex;
    gap: 1.25rem;
    overflow-x: auto;
    padding-bottom: 1.5rem;
    width: 100%;
    /* Keep horizontal scrollbar above the fold and allow vertical scrolling inside columns */
    height: calc(100vh - 220px);
    scroll-behavior: smooth;
}

.kanban-col {
    flex: 0 0 300px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

@media (max-width: 768px) {
    .page-container {
        padding: 1rem;
    }

    .kanban-col {
        flex: 0 0 85vw;
    }
    
    .kanban-container {
        height: auto;
        min-height: 70vh;
    }
}

/* Components */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 1.25rem;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05), 0 1px 2px rgba(0,0,0,0.03);
    transition: transform 0.2s, box-shadow 0.2s;
}

.glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    box-shadow: 0 4px 15px -3px rgba(0, 0, 0, 0.05), 0 2px 6px -2px rgba(0, 0, 0, 0.025);
}

.tab-container {
    display: flex;
    gap: 0.5rem;
    background: rgba(0, 0, 0, 0.03);
    padding: 0.4rem;
    border-radius: 1rem;
    width: fit-content;
    border: 1px solid var(--border);
    margin-bottom: 2.5rem;
}

.tab-pill {
    padding: 0.6rem 1.5rem;
    border-radius: 0.75rem;
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
    background: transparent;
    color: var(--text-muted);
}

.tab-pill:hover {
    color: var(--text-main);
    background: rgba(0, 0, 0, 0.05);
}

.tab-pill.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    border-radius: 0.75rem;
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-main);
}

.btn-outline:hover {
    background: rgba(0, 0, 0, 0.05);
}

.badge {
    display: inline-flex;
    padding: 0.25rem 0.75rem;
    border-radius: 2rem;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.badge-success { background: rgba(16, 185, 129, 0.1); color: #10b981; }
.badge-warning { background: rgba(245, 158, 11, 0.1); color: #f59e0b; }
.badge-danger { background: rgba(239, 68, 68, 0.1); color: #ef4444; }
.badge-info { background: rgba(14, 165, 233, 0.1); color: #0ea5e9; }

/* Tables */
.table, .data-table {
    width: 100%;
    border-collapse: collapse;
    vertical-align: middle;
}

.table th, .data-table th {
    text-align: left;
    padding: 1rem 1.25rem;
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    font-weight: 700;
    border-bottom: 1px solid var(--border);
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.table td, .data-table td {
    padding: 1.25rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.875rem;
    color: var(--text-main);
}

.table tr:last-child td, .data-table tr:last-child td {
    border-bottom: none;
}

.table tr:hover td, .data-table tr:hover td {
    background: rgba(0, 0, 0, 0.02);
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.animate-fade {
    animation: fadeIn 0.4s ease-out forwards;
}

/* Modals & Overlays */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Forms */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-muted);
}

.form-control {
    width: 100%;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--text-main);
    font-size: 0.9375rem;
    transition: all 0.2s;
    color-scheme: light;
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='rgba(0,0,0,0.5)'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1.25rem;
    padding-right: 2.5rem;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    background: #ffffff;
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.1);
}

.form-control::placeholder {
    color: #94a3b8;
}

/* ── Mobile & Responsive UI Media Queries ───────────────────────── */
@media (max-width: 768px) {
    /* Hide desktop sidebar drawer */
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: none;
    }
    
    /* Open sidebar overlay drawer drawer */
    .sidebar.sidebar-open {
        transform: translateX(0);
        box-shadow: 10px 0 30px rgba(0, 0, 0, 0.5);
    }
    
    /* Overlay background panel */
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background: rgba(0, 0, 0, 0.6);
        backdrop-filter: blur(4px);
        z-index: 45;
    }
    
    /* Remove sidebar indentation margin for main page content container */
    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
    }
    
    /* Show list hamburger toggler */
    .mobile-menu-toggle {
        display: block !important;
    }
    
    /* Make grid forms list items stack vertically on mobile */
    .form-row, .grid-row, .dashboard-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }
    
    /* Convert dual columns splits to full-width stack blocks */
    div[style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
        gap: 1.5rem !important;
    }
    
    .navbar {
        padding: 0 1rem !important;
    }
    
    .page-container {
        padding: 1rem !important;
    }
    
    /* Data tables responsive scrolling */
    .table, .data-table {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Target flex layouts in page title headers */
    .page-container > div[style*="display: flex"][style*="justify-content: space-between"] {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 1rem !important;
    }
    
    .page-container > div[style*="display: flex"][style*="justify-content: space-between"] > div[style*="display: flex"] {
        flex-direction: column !important;
        align-items: stretch !important;
        width: 100% !important;
        gap: 0.75rem !important;
    }
    
    .page-container > div[style*="display: flex"][style*="justify-content: space-between"] form {
        display: flex !important;
        width: 100% !important;
        gap: 0.5rem !important;
    }
    
    .page-container > div[style*="display: flex"][style*="justify-content: space-between"] input[name="search"] {
        flex: 1 !important;
        width: auto !important;
    }
    
    .page-container > div[style*="display: flex"][style*="justify-content: space-between"] .btn,
    .page-container > div[style*="display: flex"][style*="justify-content: space-between"] a.btn {
        width: 100% !important;
        justify-content: center !important;
        text-align: center !important;
        display: inline-flex !important;
    }

    /* Target headers inside cards (like Customer Database search & buttons) */
    .card > div[style*="display: flex"][style*="justify-content: space-between"] {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 1rem !important;
    }

    .card > div[style*="display: flex"][style*="justify-content: space-between"] > div[style*="display: flex"] {
        flex-direction: column !important;
        align-items: stretch !important;
        width: 100% !important;
        gap: 0.75rem !important;
    }

    .card > div[style*="display: flex"][style*="justify-content: space-between"] form {
        display: flex !important;
        width: 100% !important;
        gap: 0.5rem !important;
    }

    .card > div[style*="display: flex"][style*="justify-content: space-between"] input[name="search"] {
        flex: 1 !important;
        width: auto !important;
    }

    .card > div[style*="display: flex"][style*="justify-content: space-between"] .btn,
    .card > div[style*="display: flex"][style*="justify-content: space-between"] a.btn {
        width: 100% !important;
        justify-content: center !important;
        text-align: center !important;
        display: inline-flex !important;
    }

    .hide-on-mobile {
        display: none !important;
    }
}
