/* ================================================================
   MedQueuePro - Hospital Queue Management System
   Accessible, high-contrast UI designed for kiosks and display boards
   ================================================================ */

/* --- CSS Variables / Theme --- */
:root {
    --color-primary: #0d6efd;
    --color-primary-dark: #0a58ca;
    --color-success: #198754;
    --color-warning: #fd7e14;
    --color-danger: #dc3545;
    --color-info: #0dcaf0;
    --color-bg: #f0f4f8;
    --color-surface: #ffffff;
    --color-text: #1a1a2e;
    --color-text-secondary: #555770;
    --color-border: #d1d5db;
    --color-emergency: #dc3545;
    --color-senior: #fd7e14;
    --color-regular: #0d6efd;
    --color-serving: #198754;
    --color-waiting: #6c757d;
    --color-completed: #6f42c1;
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);
    --transition: all 0.2s ease;
}

/* --- Reset & Base --- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* --- Navigation --- */
#main-nav {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: white;
    padding: 0 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.35rem;
    font-weight: 700;
}

.nav-icon {
    font-size: 1.6rem;
}

.nav-links {
    display: flex;
    gap: 0.25rem;
}

.nav-link {
    color: rgba(255, 255, 255, 0.75);
    text-decoration: none;
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius-sm);
    font-weight: 500;
    transition: var(--transition);
    font-size: 0.95rem;
}

.nav-link:hover,
.nav-link.active {
    color: white;
    background: rgba(255, 255, 255, 0.15);
}

/* --- Main Container --- */
#app-container {
    flex: 1;
    padding: 1.5rem 2rem;
    max-width: 1440px;
    margin: 0 auto;
    width: 100%;
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.65rem 1.5rem;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-family);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    gap: 0.5rem;
}

.btn-primary {
    background: var(--color-primary);
    color: white;
}

.btn-primary:hover {
    background: var(--color-primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.btn-secondary {
    background: #e9ecef;
    color: var(--color-text);
}

.btn-secondary:hover {
    background: #d1d5db;
}

.btn-success {
    background: var(--color-success);
    color: white;
}

.btn-success:hover {
    background: #157347;
}

.btn-danger {
    background: var(--color-danger);
    color: white;
}

.btn-danger:hover {
    background: #b02a37;
}

.btn-warning {
    background: var(--color-warning);
    color: white;
}

.btn-lg {
    padding: 1rem 2.5rem;
    font-size: 1.2rem;
    border-radius: var(--radius);
}

.btn-sm {
    padding: 0.35rem 0.85rem;
    font-size: 0.85rem;
}

/* --- Form Elements --- */
.kiosk-input,
.admin-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-family: var(--font-family);
    font-size: 1rem;
    transition: var(--transition);
    background: var(--color-surface);
}

.kiosk-input:focus,
.admin-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.15);
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.form-group label {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--color-text-secondary);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
    cursor: pointer;
    font-size: 1.05rem;
}

.checkbox-label input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: var(--color-primary);
}

/* ================================================================
   KIOSK VIEW - Large, touch-friendly interface
   ================================================================ */
.kiosk-wrapper {
    max-width: 900px;
    margin: 0 auto;
}

.kiosk-header {
    text-align: center;
    margin-bottom: 2rem;
    padding: 2rem;
    background: linear-gradient(135deg, #0d6efd 0%, #0a58ca 100%);
    color: white;
    border-radius: var(--radius);
}

.kiosk-header h1 {
    font-size: 2.2rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
}

.kiosk-subtitle {
    font-size: 1.15rem;
    opacity: 0.9;
}

.kiosk-step {
    background: var(--color-surface);
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}

.kiosk-step h2 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    color: var(--color-primary);
}

.kiosk-form {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.kiosk-input {
    font-size: 1.1rem;
    padding: 1rem 1.2rem;
}

/* Department selection grid */
.department-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.dept-card {
    background: var(--color-surface);
    border: 3px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.5rem;
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
}

.dept-card:hover {
    border-color: var(--color-primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.dept-card .dept-code {
    font-size: 2rem;
    font-weight: 800;
    color: var(--color-primary);
    margin-bottom: 0.25rem;
}

.dept-card .dept-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 0.5rem;
}

.dept-card .dept-waiting {
    font-size: 0.9rem;
    color: var(--color-text-secondary);
}

/* Priority selection */
.priority-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.priority-btn {
    border: 3px solid var(--color-border);
    border-radius: var(--radius);
    padding: 2rem 1rem;
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
    background: var(--color-surface);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    font-family: var(--font-family);
}

.priority-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.priority-icon {
    font-size: 2.5rem;
}

.priority-label {
    font-size: 1.2rem;
    font-weight: 700;
}

.priority-emergency {
    border-color: var(--color-emergency);
    color: var(--color-emergency);
}

.priority-emergency:hover {
    background: rgba(220, 53, 69, 0.08);
}

.priority-senior {
    border-color: var(--color-senior);
    color: var(--color-senior);
}

.priority-senior:hover {
    background: rgba(253, 126, 20, 0.08);
}

.priority-regular {
    border-color: var(--color-regular);
    color: var(--color-regular);
}

.priority-regular:hover {
    background: rgba(13, 110, 253, 0.08);
}

/* Token receipt */
.token-receipt {
    text-align: center;
    padding: 2rem;
}

.token-number-large {
    font-size: 5rem;
    font-weight: 800;
    color: var(--color-primary);
    margin: 1.5rem 0;
    letter-spacing: 0.1em;
    line-height: 1;
}

.token-details {
    margin-bottom: 2rem;
    font-size: 1.1rem;
    color: var(--color-text-secondary);
}

.token-details p {
    margin: 0.3rem 0;
}

/* ================================================================
   DISPLAY BOARD - TV-friendly, high contrast, large fonts
   ================================================================ */
.display-wrapper {
    max-width: 1400px;
    margin: 0 auto;
}

.display-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding: 1.5rem 2rem;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: white;
    border-radius: var(--radius);
}

.display-title {
    font-size: 2rem;
    font-weight: 800;
}

.display-clock {
    font-size: 2rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.display-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.display-counter-card {
    background: var(--color-surface);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    border-left: 6px solid var(--color-serving);
    min-height: 160px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.display-counter-card.on-break {
    border-left-color: var(--color-warning);
    opacity: 0.7;
}

.display-counter-card .counter-label {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--color-text-secondary);
    margin-bottom: 0.25rem;
}

.display-counter-card .dept-badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
    background: rgba(13, 110, 253, 0.1);
    color: var(--color-primary);
    margin-bottom: 0.75rem;
}

.display-counter-card .serving-token {
    font-size: 3.5rem;
    font-weight: 800;
    color: var(--color-serving);
    text-align: center;
    line-height: 1.1;
}

.display-counter-card .serving-token.empty {
    font-size: 1.2rem;
    color: var(--color-waiting);
    font-weight: 500;
}

.display-counter-card .patient-name-display {
    text-align: center;
    font-size: 1rem;
    color: var(--color-text-secondary);
    margin-top: 0.25rem;
}

/* Waiting section on display */
.display-waiting-section {
    background: var(--color-surface);
    border-radius: var(--radius);
    padding: 1.5rem 2rem;
    box-shadow: var(--shadow);
}

.display-waiting-section h2 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    color: var(--color-text);
}

.waiting-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
}

.waiting-dept-card {
    padding: 1rem;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-sm);
}

.waiting-dept-card .dept-header {
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--color-primary);
}

.waiting-dept-card .waiting-count {
    font-size: 2rem;
    font-weight: 800;
    color: var(--color-text);
}

.waiting-dept-card .next-tokens {
    font-size: 0.9rem;
    color: var(--color-text-secondary);
    margin-top: 0.5rem;
}

/* ================================================================
   ADMIN PANEL
   ================================================================ */
.admin-wrapper {
    max-width: 1400px;
    margin: 0 auto;
}

.admin-header {
    margin-bottom: 1.5rem;
}

.admin-header h1 {
    font-size: 1.8rem;
    margin-bottom: 1rem;
}

.admin-tabs {
    display: flex;
    gap: 0.5rem;
    border-bottom: 2px solid var(--color-border);
    padding-bottom: 0;
}

.tab-btn {
    padding: 0.7rem 1.5rem;
    border: none;
    background: none;
    font-family: var(--font-family);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--color-text-secondary);
    cursor: pointer;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    transition: var(--transition);
}

.tab-btn:hover {
    color: var(--color-primary);
}

.tab-btn.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}

.admin-section {
    background: var(--color-surface);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}

.admin-section h2 {
    font-size: 1.3rem;
    margin-bottom: 1rem;
    color: var(--color-text);
}

/* Admin counter cards */
.admin-counters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
}

.admin-counter-card {
    border: 2px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 1rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.admin-counter-card .counter-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.admin-counter-card .counter-token {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--color-serving);
}

.admin-counter-card .counter-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Admin queues */
.admin-queues-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
}

.queue-card {
    border: 2px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 1rem;
}

.queue-card .queue-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.queue-card .queue-list {
    list-style: none;
    max-height: 200px;
    overflow-y: auto;
}

.queue-card .queue-list li {
    padding: 0.4rem 0.5rem;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
}

.queue-card .queue-list li:last-child {
    border-bottom: none;
}

/* Token table */
.tokens-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.tokens-table th,
.tokens-table td {
    padding: 0.65rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}

.tokens-table th {
    background: var(--color-bg);
    font-weight: 700;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--color-text-secondary);
}

.tokens-table tbody tr:hover {
    background: rgba(13, 110, 253, 0.03);
}

.token-filters {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
    align-items: center;
}

.token-filters .admin-input {
    max-width: 200px;
}

/* Status badges */
.badge {
    display: inline-block;
    padding: 0.2rem 0.55rem;
    border-radius: 4px;
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.badge-waiting { background: #e9ecef; color: #495057; }
.badge-serving { background: #d1e7dd; color: #0f5132; }
.badge-completed { background: #e2d9f3; color: #432874; }
.badge-cancelled { background: #f8d7da; color: #842029; }
.badge-transferred { background: #cff4fc; color: #055160; }
.badge-no_show { background: #fff3cd; color: #664d03; }
.badge-emergency { background: #f8d7da; color: #842029; }
.badge-senior { background: #fff3cd; color: #664d03; }
.badge-regular { background: #cfe2ff; color: #084298; }
.badge-open { background: #d1e7dd; color: #0f5132; }
.badge-closed { background: #e9ecef; color: #495057; }
.badge-on_break { background: #fff3cd; color: #664d03; }

/* Analytics */
.analytics-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--color-surface);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
    text-align: center;
}

.stat-card .stat-value {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--color-primary);
    line-height: 1.1;
}

.stat-card .stat-label {
    font-size: 0.85rem;
    color: var(--color-text-secondary);
    font-weight: 600;
    margin-top: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.analytics-charts {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
    gap: 1.5rem;
}

.chart-container {
    background: var(--color-surface);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.chart-container h3 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    color: var(--color-text);
}

.chart-container canvas {
    width: 100% !important;
    max-height: 280px;
}

/* Admin form */
.admin-form {
    margin-bottom: 1rem;
}

.admin-form .form-row {
    grid-template-columns: 1fr 1fr 1fr;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: var(--color-surface);
    border-radius: var(--radius);
    padding: 2rem;
    max-width: 500px;
    width: 90%;
    box-shadow: var(--shadow-lg);
}

.modal-content h3 {
    margin-bottom: 1rem;
}

.modal-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
    justify-content: flex-end;
}

/* Footer */
#app-footer {
    text-align: center;
    padding: 1.25rem;
    background: var(--color-surface);
    color: var(--color-text-secondary);
    font-size: 0.9rem;
    border-top: 1px solid var(--color-border);
    margin-top: auto;
}

/* Responsive */
@media (max-width: 768px) {
    #main-nav {
        flex-direction: column;
        height: auto;
        padding: 0.75rem 1rem;
        gap: 0.5rem;
    }

    .nav-links {
        width: 100%;
        justify-content: center;
    }

    #app-container {
        padding: 1rem;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .priority-grid {
        grid-template-columns: 1fr;
    }

    .display-grid {
        grid-template-columns: 1fr;
    }

    .admin-form .form-row {
        grid-template-columns: 1fr;
    }

    .analytics-charts {
        grid-template-columns: 1fr;
    }

    .token-filters {
        flex-wrap: wrap;
    }
}

/* Animations */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.pulse-animation {
    animation: pulse 2s ease-in-out infinite;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.slide-in {
    animation: slideIn 0.3s ease-out;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--color-bg);
}

::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--color-text-secondary);
}
