/* Modern Dashboard Style - Slate/Indigo Theme */
:root {
    --primary: #4f46e5;
    /* Indigo 600 */
    --primary-hover: #4338ca;
    /* Indigo 700 */
    --secondary: #64748b;
    /* Slate 500 */
    --bg-body: #f1f5f9;
    /* Slate 100 */
    --bg-card: #ffffff;
    --text-main: #0f172a;
    /* Slate 900 */
    --text-muted: #64748b;
    /* Slate 500 */
    --border: #e2e8f0;
    /* Slate 200 */
    --success: #10b981;
    /* Emerald 500 */
    --warning: #f59e0b;
    /* Amber 500 */
    --danger: #ef4444;
    /* Red 500 */
    --info: #3b82f6;
    /* Blue 500 */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    font-family: 'Outfit', 'Tajawal', sans-serif;
    background: var(--bg-body);
    color: var(--text-main);
    direction: rtl;
    -webkit-font-smoothing: antialiased;
}

a {
    text-decoration: none;
    color: inherit;
    transition: all 0.2s;
}

/* --- Layout --- */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.main-content {
    padding: 30px 0;
}

/* --- Navbar --- */
.navbar {
    background: #ffffff;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: var(--shadow-sm);
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 20px;
    color: var(--primary);
}

.brand-icon {
    background: var(--primary);
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
}

.nav-links {
    display: flex;
    gap: 8px;
}

.nav-item {
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 500;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-item:hover {
    background: #f8fafc;
    color: var(--primary);
}

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

.nav-user {
    display: flex;
    align-items: center;
    gap: 16px;
    padding-right: 16px;
    border-right: 1px solid var(--border);
}

.user-info {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    line-height: 1.2;
}

.user-name {
    font-weight: 600;
    font-size: 14px;
}

.company-badge {
    font-size: 11px;
    background: #f1f5f9;
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--text-muted);
}

.btn-logout {
    color: var(--danger);
    font-size: 18px;
    padding: 8px;
    border-radius: 50%;
    background: #fef2f2;
}

.btn-logout:hover {
    background: #fee2e2;
}

/* --- Dashboard Header --- */
.welcome-section {
    margin-bottom: 32px;
}

.welcome-section h1 {
    font-size: 28px;
    font-weight: 700;
    margin: 0 0 8px 0;
    color: var(--text-main);
}

.subtitle {
    color: var(--text-muted);
    margin: 0;
    font-size: 16px;
}

/* --- Stats Grid --- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.stat-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 16px;
    transition: transform 0.2s;
}

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

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
}

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

.stat-label {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.2;
}

/* Stat Colors */
.stat-card.total .stat-icon {
    background: #eef2ff;
    color: var(--primary);
}

.stat-card.waiting .stat-icon {
    background: #fff7ed;
    color: var(--warning);
}

.stat-card.serving .stat-icon {
    background: #ecfdf5;
    color: var(--success);
}

.stat-card.served .stat-icon {
    background: #f0f9ff;
    color: var(--info);
}

.stat-card.canceled .stat-icon {
    background: #fef2f2;
    color: var(--danger);
}

/* --- Link Cards Grid --- */
.section-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 20px;
    color: var(--text-main);
}

.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.card {
    background: white;
    border-radius: 12px;
    padding: 24px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: flex-start;
    gap: 16px;
    transition: all 0.2s ease;
}

.card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.card-icon {
    width: 40px;
    height: 40px;
    background: #f8fafc;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.card-content h3 {
    margin: 0 0 6px 0;
    font-size: 16px;
    font-weight: 600;
}

.card-content p {
    margin: 0;
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.5;
}

/* Special Card Styles */
.card.primary {
    background: linear-gradient(135deg, #4f46e5 0%, #4338ca 100%);
    color: white;
    border: none;
}

.card.primary .card-icon {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.card.primary .card-content p {
    color: rgba(255, 255, 255, 0.8);
}

.card.primary:hover {
    box-shadow: 0 10px 20px -5px rgba(79, 70, 229, 0.4);
}

.card.action {
    border-left: 4px solid var(--success);
}

.card.super-admin {
    border: 2px dashed var(--info);
    background: #f0f9ff;
}

/* --- Forms & Tables (Legacy Support) --- */
.form-row {
    margin-bottom: 16px;
}

.form-row label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    font-size: 14px;
}

.form-row input,
.form-row select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s;
}

.form-row input:focus,
.form-row select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    font-size: 14px;
}

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

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

.btn-secondary {
    background: var(--secondary);
    color: white;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}

.table th {
    background: #f8fafc;
    padding: 12px 16px;
    text-align: right;
    font-weight: 600;
    font-size: 13px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

.table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}

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

/* --- Mobile Responsive --- */
@media (max-width: 768px) {
    .nav-container {
        height: auto;
        flex-direction: column;
        padding: 16px;
        gap: 16px;
    }

    .nav-links {
        width: 100%;
        overflow-x: auto;
        padding-bottom: 4px;
    }

    .nav-user {
        width: 100%;
        justify-content: space-between;
        border-right: none;
        border-top: 1px solid var(--border);
        padding-top: 12px;
        padding-right: 0;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }

    .stat-card.total {
        grid-column: 1 / -1;
    }
}

/* --- Modals --- */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(2px);
    overflow-y: auto;
    /* Allow scrolling on the modal container */
    padding: 20px;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: white;
    width: min(500px, 90vw);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    animation: modalSlide 0.3s ease-out;
    margin: auto;
    /* Center vertically/horizontally in flex container */
    max-height: 90vh;
    /* Prevent it from being taller than screen */
    display: flex;
    flex-direction: column;
}

@keyframes modalSlide {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #f8fafc;
    flex-shrink: 0;
}

.modal-header h2,
.modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    /* Scrollable content */
}

.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    background: #f8fafc;
    flex-shrink: 0;
}

.modal-close {
    cursor: pointer;
    font-size: 24px;
    color: var(--text-muted);
    line-height: 1;
}

.modal-close:hover {
    color: var(--danger);
}

/* --- Wide Container for Operational Pages --- */
.container-wide {
    max-width: 1470px;
    margin: 24px auto;
    padding: 0 16px;
}

/* --- Auth/Profile Form Styling --- */
.auth-container {
    max-width: 450px;
    margin: 60px auto;
}

.auth-card {
    background: white;
    padding: 40px;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
}

.auth-title {
    text-align: center;
    margin-bottom: 30px;
    font-size: 24px;
    font-weight: 700;
    color: var(--primary);
}

/* --- Old Style Card Restoration for Operational Pages --- */
.operational-card {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .06);
    padding: 16px;
    margin-bottom: 16px;
    border: none;
    /* Remove the new border */
}

/* --- Wallboard Card Layout --- */
.wallboard-card {
    flex-direction: column !important;
    align-items: stretch !important;
}