:root {
    --primary: #000000;
    --primary-light: #f3f4f6;
    --primary-dark: #111827;
    --success: #000000;
    --warning: #4b5563;
    --danger: #ef4444;
    --bg-main: #ffffff;
    --bg-sidebar: #000000;
    --text-main: #000000;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    --sidebar-width: 260px;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --glass: rgba(255, 255, 255, 0.9);
    --radius: 12px;
    --font-inter: 'Inter', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-inter);
    background-color: var(--bg-main);
    color: var(--text-main);
    overflow: hidden; /* Main container handles scrolling */
}

.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 100;
    flex-shrink: 0;
    backdrop-filter: blur(10px);
}

.sidebar-header {
    padding: 24px;
    border-bottom: 1px solid var(--border);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.25rem;
    font-weight: 700;
    color: #ffffff;
}

.logo-icon {
    width: 32px;
    height: 32px;
}

.sidebar-nav {
    flex: 1;
    padding: 24px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border: none;
    background: transparent;
    border-radius: var(--radius);
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    width: 100%;
}

.nav-item i {
    width: 20px;
    height: 20px;
}

.nav-item:hover {
    background-color: #1f2937;
    color: #ffffff;
}

.nav-item.active {
    background-color: var(--primary);
    color: white;
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid var(--border);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar {
    width: 40px;
    height: 40px;
    background: #ffffff;
    color: #000000;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: #ffffff;
}

.user-role {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.6);
}

/* Main Content Area */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.content-header {
    height: 70px;
    background: var(--glass);
    backdrop-filter: blur(10px);
    padding: 0 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: 50;
}

.content-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 20px;
}

.search-bar {
    display: flex;
    align-items: center;
    background: #f1f5f9;
    padding: 8px 16px;
    border-radius: 20px;
    gap: 8px;
    width: 300px;
}

.search-bar i {
    width: 18px;
    height: 18px;
    color: var(--text-muted);
}

.search-bar input {
    border: none;
    background: transparent;
    outline: none;
    font-size: 0.9rem;
    width: 100%;
}

.notification-btn {
    position: relative;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
}

.badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 8px;
    height: 8px;
    background: var(--danger);
    border-radius: 50%;
    border: 2px solid white;
}

.module-container {
    flex: 1;
    padding: 32px;
    overflow-y: auto;
    background-color: var(--bg-main);
    animation: fadeIn 0.4s ease-out;
}

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

/* Dashboard Module */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.kpi-card {
    background: white;
    padding: 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border: 1px solid transparent;
}

.kpi-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-light);
}

.kpi-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.kpi-label {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-weight: 500;
}

.kpi-icon {
    padding: 8px;
    border-radius: 8px;
    background: #f1f5f9;
    color: var(--primary);
}

.kpi-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-main);
}

.kpi-trend {
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    gap: 4px;
}

.trend-up { color: var(--success); }
.trend-down { color: var(--danger); }

/* Tables */
.card {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: box-shadow 0.3s ease;
}

.card:hover {
    box-shadow: var(--shadow-lg);
}

.card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.table-wrapper {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    text-align: left;
    padding: 16px 24px;
    background: #f8fafc;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    font-weight: 600;
}

td {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
    vertical-align: middle;
}

tr:last-child td {
    border-bottom: none;
}

.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

/* Kanban Board */
.kanban-container {
    display: flex;
    gap: 20px;
    padding-bottom: 20px;
    overflow-x: auto;
}

.kanban-column {
    min-width: 300px;
    background: #f1f5f9;
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 200px);
}

.kanban-col-header {
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.kanban-col-header h3 {
    font-size: 0.95rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.count-badge {
    background: #e2e8f0;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
}

.kanban-cards {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
    flex: 1;
}

.order-card {
    background: white;
    padding: 16px;
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
    cursor: grab;
    transition: transform 0.2s, box-shadow 0.2s;
}

.order-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.order-id {
    font-size: 0.75rem;
    color: var(--primary);
    font-weight: 600;
    margin-bottom: 4px;
}

.order-client {
    font-weight: 600;
    margin-bottom: 8px;
}

.order-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Modal base overlay */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

/* Form/data modal — sits above normal content */
#modal-container {
    z-index: 1100;
}

/* Confirmation modal — ALWAYS on top of everything including form modals */
#confirm-modal {
    z-index: 9000;
}

/* Login overlay — highest of all */
#login-overlay {
    background: #ffffff;
    z-index: 9999;
    backdrop-filter: none;
}

#login-overlay .modal-content {
    border: none;
    box-shadow: none;
    max-width: 400px;
    width: 90%;
    animation: fadeIn 0.8s ease-out;
}

.modal-overlay.hidden {
    display: none !important;
    opacity: 0;
}

.modal-content {
    background: white;
    width: 100%;
    max-width: 600px;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-body {
    padding: 24px;
}

.close-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
}

/* Forms */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    outline: none;
    font-family: inherit;
    transition: border-color 0.2s;
}

.form-control:focus {
    border-color: var(--primary);
}

.pill {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}

.pill-indigo { background: #000000; color: #ffffff; }
.pill-green { background: #e5e7eb; color: #000000; }
.pill-gray { background: #f3f4f6; color: #000000; border: 1px solid #d1d5db; }

/* Product thumbnail */
.thumbnail {
    width: 40px;
    height: 40px;
    border-radius: 4px;
    object-fit: cover;
    background: #f1f5f9;
}

/* Chart placeholder */
.chart-container {
    height: 300px;
    width: 100%;
    background: #f8fafc;
    border-radius: 8px;
    display: flex;
    align-items: flex-end;
    padding: 20px;
    gap: 12px;
    margin-top: 20px;
}

.bar {
    flex: 1;
    background: var(--primary-light);
    border-radius: 4px 4px 0 0;
    transition: height 1s ease;
}

/* Order Queue */
.order-queue-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.queue-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.queue-info {
    display: flex;
    flex-direction: column;
}

.queue-status {
    font-size: 0.7rem;
    font-weight: 600;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 2000;
}

.toast {
    background: white;
    color: var(--text-main);
    padding: 16px 20px;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 300px;
    animation: toastIn 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.35);
    border-left: 4px solid var(--primary);
    position: relative;
    overflow: hidden;
}

.toast.success { border-left-color: #000000; }
.toast.danger { border-left-color: var(--danger); }
.toast.info { border-left-color: #000000; }

@keyframes toastIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.toast-exit {
    animation: toastOut 0.3s forwards;
}

@keyframes toastOut {
    to { transform: translateX(100%); opacity: 0; }
}

/* ── Utility ── */
.hidden { display: none !important; }

/* ── Modal Overlay (appended block — overrides above for specificity) ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}
.modal-content {
    background: #ffffff;
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
    border: 1px solid #e5e7eb;
    animation: modalIn 0.25s ease-out;
}
.confirm-modal { max-width: 420px; padding: 36px 32px; text-align: center; }
@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95) translateY(-10px); }
    to   { opacity: 1; transform: scale(1)   translateY(0); }
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px 28px 16px;
    border-bottom: 1px solid #e5e7eb;
}
.modal-body { padding: 24px 28px 28px; }

/* ── Login Page ── */
.login-page {
    position: fixed;
    inset: 0;
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}
/* Ensure hidden always wins regardless of specificity order */
#login-overlay.hidden { display: none !important; }
.login-card {
    width: 100%;
    max-width: 420px;
    padding: 48px 40px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.08);
    animation: modalIn 0.3s ease-out;
}
.login-logo { display: flex; justify-content: center; margin-bottom: 32px; }
.login-title { font-size: 1.6rem; font-weight: 700; text-align: center; margin-bottom: 6px; }
.login-subtitle { font-size: 0.9rem; color: #6b7280; text-align: center; margin-bottom: 32px; }
.login-submit-btn { width: 100%; justify-content: center; padding: 14px; font-size: 1rem; margin-top: 8px; }
.login-hint { font-size: 0.75rem; color: #6b7280; text-align: center; margin-top: 20px; }

/* ── Logout Button ── */
.logout-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    width: 100%;
    padding: 10px 12px;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 8px;
    color: rgba(255,255,255,0.75);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}
.logout-btn:hover { background: rgba(239,68,68,0.2); border-color: rgba(239,68,68,0.4); color: #fca5a5; }
.logout-btn i { width: 16px; height: 16px; }

/* ── Btn Secondary ── */
.btn-secondary {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: 1px solid #e5e7eb;
    background: #f9fafb;
    color: #000000;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-secondary:hover { background: #f1f5f9; }

/* ── Mobile Optimization ─────────────────────────────────────────────────── */
.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-main);
    padding: 4px;
}

/* Base table scrolling */
.table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 768px) {
    /* Sidebar as a drawer */
    .sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        left: -100%;
        transition: left 0.3s ease;
        z-index: 100;
        width: 280px;
    }
    .sidebar.open {
        left: 0;
    }
    
    .mobile-menu-btn {
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Layout Adjustments */
    .content-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
        padding: 16px;
    }
    .header-actions {
        width: 100%;
        justify-content: space-between;
    }
    .search-bar {
        width: 100%;
    }
    .search-bar input {
        width: 100%;
    }
    .main-content {
        padding: 16px;
    }
    
    /* Kanban Boards */
    .kanban-board {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }
    
    /* Override all inline grid columns to stack vertically on mobile */
    div[style*="grid-template-columns:repeat(4,1fr)"],
    div[style*="grid-template-columns: repeat(4, 1fr)"],
    div[style*="grid-template-columns:1fr 1fr"],
    div[style*="grid-template-columns: 1fr 1fr"],
    div[style*="grid-template-columns:1.3fr 1fr"],
    div[style*="grid-template-columns: 1.3fr 1fr"],
    div[style*="grid-template-columns:1fr auto"],
    div[style*="grid-template-columns: 1fr auto"] {
        grid-template-columns: 1fr !important;
    }
    
    /* Modals & Forms */
    .modal-content, .login-card {
        width: 95%;
        max-width: 100%;
        margin: 10px;
        padding: 20px 16px;
    }
    .form-group input, .form-group select {
        font-size: 16px; /* Prevents iOS Safari zoom */
    }
    
    /* Search Dropdown & Notifications */
    #search-dropdown, #notif-panel {
        position: fixed !important;
        top: 140px !important;
        left: 10px !important;
        right: 10px !important;
        width: auto !important;
        max-width: none !important;
        max-height: calc(100vh - 160px) !important;
    }
    
    /* Table styling for mobile */
    .table {
        min-width: 600px; /* forces horizontal scroll */
    }
}

