/* QMS360 - Odoo-inspired theme */
:root {
    --primary: #714B67;
    --primary-dark: #5a3c52;
    --primary-light: #875A7B;
    --sidebar-bg: #2F2F2F;
    --sidebar-hover: #3d3d3d;
    --header-bg: #714B67;
    --body-bg: #f0f0f0;
    --card-bg: #ffffff;
    --border: #dee2e6;
    --text: #212529;
    --text-muted: #6c757d;
    --success: #28a745;
    --danger: #dc3545;
    --warning: #ffc107;
    --sidebar-width: 220px;
    --sidebar-collapsed-width: 56px;
    --sidebar-transition: 0.2s ease;
    --shadow-3d-sm: 0 3px 0 rgba(0, 0, 0, 0.18), 0 4px 8px rgba(0, 0, 0, 0.14);
    --shadow-3d-md: 0 4px 0 rgba(0, 0, 0, 0.2), 0 6px 14px rgba(0, 0, 0, 0.16);
    --shadow-3d-inset: inset 0 2px 4px rgba(0, 0, 0, 0.12);
    --shadow-3d-inset-light: inset 0 1px 0 rgba(255, 255, 255, 0.22);
    --input-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.08), 0 2px 6px rgba(0, 0, 0, 0.07);
    --input-shadow-focus: inset 0 2px 5px rgba(0, 0, 0, 0.06), 0 3px 10px rgba(113, 75, 103, 0.22), 0 0 0 2px rgba(113, 75, 103, 0.12);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    color: var(--text);
    background: var(--body-bg);
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #383838 0%, #2f2f2f 40%, #262626 100%);
    color: #fff;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    transition: width var(--sidebar-transition);
    overflow: hidden;
    box-shadow: 4px 0 14px rgba(0, 0, 0, 0.18);
}

.sidebar-brand {
    padding: 16px;
    font-size: 18px;
    font-weight: 600;
    border-bottom: 1px solid rgba(0, 0, 0, 0.35);
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-height: 53px;
    display: flex;
    align-items: center;
    transition: opacity var(--sidebar-transition);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
    box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.06);
}

.sidebar-nav { flex: 1; padding: 10px 8px; overflow-x: hidden; overflow-y: auto; }

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    margin: 5px 4px;
    color: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(0, 0, 0, 0.45);
    border-radius: 8px;
    white-space: nowrap;
    min-height: 42px;
    background: linear-gradient(180deg, #4a4a4a 0%, #3a3a3a 45%, #2e2e2e 100%);
    box-shadow: var(--shadow-3d-sm), var(--shadow-3d-inset-light);
    transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}

.sidebar-nav a:hover {
    background: linear-gradient(180deg, #555 0%, #444 45%, #383838 100%);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 4px 0 #1a1a1a, 0 6px 12px rgba(0, 0, 0, 0.22), var(--shadow-3d-inset-light);
}

.sidebar-nav a.active {
    background: linear-gradient(180deg, #9a6d90 0%, #714b67 45%, #5a3c52 100%);
    color: #fff;
    border-color: rgba(0, 0, 0, 0.35);
    box-shadow: 0 3px 0 #3d2838, 0 5px 10px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.sidebar-nav a:active {
    transform: translateY(2px);
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.25), var(--shadow-3d-inset);
}

.sidebar-nav a,
.sidebar-nav a:hover,
.sidebar-nav a:active,
.sidebar-nav a.active {
    text-decoration: none;
}

.sidebar-nav .nav-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    opacity: 0.9;
}

.sidebar-nav .nav-label {
    overflow: hidden;
    text-overflow: ellipsis;
    transition: opacity var(--sidebar-transition);
}

.sidebar-nav .nav-section {
    padding: 12px 16px 4px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: rgba(255,255,255,0.45);
    white-space: nowrap;
    overflow: hidden;
    transition: opacity var(--sidebar-transition);
}

.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid rgba(255,255,255,0.1);
    font-size: 12px;
    color: rgba(255,255,255,0.6);
    white-space: nowrap;
    overflow: hidden;
    transition: opacity var(--sidebar-transition);
}

/* Collapsed sidebar (default) */
.app-shell.sidebar-collapsed .sidebar {
    width: var(--sidebar-collapsed-width);
}

.app-shell.sidebar-collapsed .sidebar-brand,
.app-shell.sidebar-collapsed .nav-label,
.app-shell.sidebar-collapsed .nav-section,
.app-shell.sidebar-collapsed .sidebar-footer {
    opacity: 0;
    width: 0;
    height: 0;
    padding: 0;
    margin: 0;
    overflow: hidden;
    visibility: hidden;
}

.app-shell.sidebar-collapsed .sidebar-brand {
    min-height: 53px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.app-shell.sidebar-collapsed .sidebar-nav a {
    justify-content: center;
    padding: 10px 0;
    gap: 0;
    margin: 5px 6px;
}

.sidebar-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    margin-right: 12px;
    padding: 0;
    border: 1px solid rgba(0, 0, 0, 0.25);
    border-radius: 8px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.22) 0%, rgba(255, 255, 255, 0.08) 100%);
    color: #fff;
    cursor: pointer;
    flex-shrink: 0;
    box-shadow: 0 3px 0 rgba(0, 0, 0, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.25);
    transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}

.sidebar-toggle:hover {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.3) 0%, rgba(255, 255, 255, 0.12) 100%);
    transform: translateY(-1px);
}

.sidebar-toggle:active {
    transform: translateY(2px);
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.2), inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.top-header .header-start {
    display: flex;
    align-items: center;
    min-width: 0;
}

.top-header h1 {
    margin: 0;
    font-size: 16px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.top-header {
    background: linear-gradient(180deg, #7d5573 0%, var(--header-bg) 45%, #5f3f56 100%);
    color: #fff;
    padding: 0 24px;
    height: 46px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.top-header .user-menu {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.9);
}

.top-header .user-menu a {
    color: #fff;
    margin-left: 12px;
    display: inline-block;
    padding: 5px 12px;
    border-radius: 7px;
    border: 1px solid rgba(0, 0, 0, 0.2);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.18) 0%, rgba(0, 0, 0, 0.08) 100%);
    box-shadow: 0 2px 0 rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.2);
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.top-header .user-menu a:hover {
    color: #fff;
    transform: translateY(-1px);
}

.top-header .user-menu a:active {
    transform: translateY(1px);
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.2), inset 0 2px 3px rgba(0, 0, 0, 0.18);
}

.content-area {
    padding: 20px 24px;
    flex: 1;
}

.alert {
    padding: 12px 16px;
    border-radius: 4px;
    margin-bottom: 16px;
}

.alert-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.alert-danger { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.alert-warning { background: #fff3cd; color: #856404; border: 1px solid #ffeeba; }

.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    margin-bottom: 16px;
}

.card-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-body { padding: 16px; }

.btn {
    display: inline-block;
    padding: 8px 16px;
    border: 1px solid rgba(0, 0, 0, 0.18);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    line-height: 1.4;
    text-decoration: none;
    box-shadow: var(--shadow-3d-md), var(--shadow-3d-inset-light);
    transform: translateY(0);
    transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease, color 0.12s ease;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(3px);
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.2), var(--shadow-3d-inset);
}

.btn-primary {
    background: linear-gradient(180deg, #8a5f7f 0%, var(--primary) 45%, var(--primary-dark) 100%);
    color: #fff;
    border-color: rgba(0, 0, 0, 0.28);
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.25);
}

.btn-primary:hover {
    background: linear-gradient(180deg, #966989 0%, #7a516f 45%, #4f3348 100%);
    color: #fff;
}

.btn-secondary {
    background: linear-gradient(180deg, #fff 0%, #f3f4f6 55%, #e5e7eb 100%);
    color: var(--text);
    border-color: #c5cad0;
}

.btn-secondary:hover {
    background: linear-gradient(180deg, #fff 0%, #f8f9fa 55%, #eceff2 100%);
    color: var(--text);
}

.btn-danger {
    background: linear-gradient(180deg, #e4606d 0%, var(--danger) 50%, #bd2130 100%);
    color: #fff;
    border-color: rgba(0, 0, 0, 0.22);
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
}

.btn-danger:hover {
    background: linear-gradient(180deg, #eb7580 0%, #dc3545 50%, #a71d2a 100%);
    color: #fff;
}

.btn-sm {
    padding: 5px 11px;
    font-size: 12px;
    border-radius: 7px;
    box-shadow: var(--shadow-3d-sm), var(--shadow-3d-inset-light);
}

.btn-sm:active {
    transform: translateY(2px);
}

.form-group { margin-bottom: 14px; }

.form-group label {
    display: block;
    margin-bottom: 4px;
    font-weight: 500;
    font-size: 13px;
}

.form-control {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid #c5cad0;
    border-radius: 8px;
    font-size: 14px;
    background: linear-gradient(180deg, #f9fafb 0%, #fff 100%);
    box-shadow: var(--input-shadow);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

textarea.form-control {
    min-height: 80px;
    resize: vertical;
}

select.form-control {
    appearance: none;
    background-image: linear-gradient(180deg, #f9fafb 0%, #fff 100%),
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236c757d' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat, no-repeat;
    background-position: 0 0, right 12px center;
    padding-right: 34px;
}

input[type="file"].form-control {
    padding: 7px 10px;
    background: linear-gradient(180deg, #f3f4f6 0%, #fff 100%);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: var(--input-shadow-focus);
}

.form-control:disabled,
.form-control[readonly] {
    background: linear-gradient(180deg, #eceff2 0%, #f5f6f8 100%);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.required::after { content: ' *'; color: var(--danger); }

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.table th {
    background: #f8f9fa;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-muted);
}

.table tr:hover td { background: #fafafa; }

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}

.badge-success { background: #d4edda; color: #155724; }
.badge-danger { background: #f8d7da; color: #721c24; }
.badge-warning { background: #fff3cd; color: #856404; }

.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }

/* Login */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #714B67 0%, #875A7B 100%);
}

.login-box {
    background: #fff;
    padding: 32px;
    border-radius: 12px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 12px 0 rgba(0, 0, 0, 0.12), 0 20px 40px rgba(0, 0, 0, 0.22);
    border: 1px solid rgba(255, 255, 255, 0.35);
}

.login-box .btn-primary {
    margin-top: 8px;
}

.login-box h2 {
    margin: 0 0 8px;
    color: var(--primary);
    text-align: center;
}

.login-box .subtitle {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 24px;
    font-size: 13px;
}

/* Kiosk layout */
.kiosk-fullpage {
    margin-bottom: 0;
    min-height: calc(100vh - 86px);
    display: flex;
    flex-direction: column;
}

.kiosk-list-body {
    flex: 1;
    overflow: auto;
    padding: 0 !important;
}

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay.show {
    display: flex;
}

.modal-dialog {
    background: var(--card-bg);
    border-radius: 12px;
    width: 100%;
    max-width: 640px;
    max-height: calc(100vh - 40px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border);
    box-shadow: 0 16px 0 rgba(0, 0, 0, 0.08), 0 24px 48px rgba(0, 0, 0, 0.28);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(180deg, #fafafa 0%, #f3f4f6 100%);
}

.modal-header h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--primary);
}

.modal-close {
    width: 36px;
    height: 36px;
    border: 1px solid #c5cad0;
    border-radius: 8px;
    background: linear-gradient(180deg, #fff 0%, #e5e7eb 100%);
    color: var(--text-muted);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    box-shadow: var(--shadow-3d-sm), var(--shadow-3d-inset-light);
}

.modal-close:hover {
    color: var(--text);
}

.modal-close:active {
    transform: translateY(2px);
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.2), var(--shadow-3d-inset);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
}

.modal-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.kiosk-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

@media (max-width: 992px) {
    .kiosk-grid { grid-template-columns: 1fr; }

    .app-shell.sidebar-expanded .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 1000;
        box-shadow: 4px 0 16px rgba(0,0,0,0.2);
    }

    .app-shell.sidebar-expanded::before {
        content: '';
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.35);
        z-index: 999;
    }
}

.patient-search-results {
    border: 1px solid var(--border);
    border-top: none;
    max-height: 200px;
    overflow-y: auto;
    background: #fff;
    display: none;
    position: absolute;
    width: 100%;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.patient-search-results.show { display: block; }

.patient-search-results .result-item {
    padding: 10px 12px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
}

.patient-search-results .result-item:hover { background: #f5f0f4; }

.search-wrap { position: relative; }

.token-number-display {
    font-size: 48px;
    font-weight: 700;
    color: var(--primary);
    text-align: center;
    letter-spacing: 2px;
}

.expired-banner {
    background: #fff3cd;
    color: #856404;
    padding: 10px 24px;
    text-align: center;
    font-weight: 500;
    border-bottom: 1px solid #ffeeba;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: normal;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    box-shadow: var(--input-shadow);
    border-radius: 4px;
}

.actions-bar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
