/* ==========================================================================
   styles.css — Anesthesia Logbook v8.2
   All styles extracted from the original monolithic HTML.
   Font stack: system-ui only. Zero external font dependencies.
   ========================================================================== */

/* --- CSS Custom Properties (Dark theme default) -------------------------- */
:root {
    --bg:            #1a1f26;
    --bg-soft:       #242933;
    --card:          rgba(52, 58, 74, 0.85);
    --text-main:     #e8eaed;
    --text-soft:     #a8adb3;
    --text-faint:    #7b8290;
    --primary:       #3b7dd9;
    --primary-dark:  #2563c7;
    --primary-light:#5a95e8;
    --success:       #66bb6a;
    --warning:       #ffa726;
    --error:         #ef5350;
    --input-bg:      #2a2f3c;
    --input-border:  #4a4f5f;
    --shadow:        0 4px 20px rgba(0, 0, 0, 0.4);
    --shadow-glow:   0 0 30px rgba(59, 125, 217, 0.3);
    --radius:        16px;
    --radius-sm:     8px;
}

/* --- Light theme override ------------------------------------------------- */
body.light-mode {
    --bg:           #f8f9fb;
    --bg-soft:      #ffffff;
    --card:         rgba(255, 255, 255, 0.98);
    --text-main:    #1a1d29;
    --text-soft:    #6f7378;
    --text-faint:   #9095a0;
    --input-bg:     #ffffff;
    --input-border:#e8e8e8;
    --shadow:       0 2px 8px rgba(0, 0, 0, 0.06);
}

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

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text-main);
    line-height: 1.6;
    transition: background 0.3s ease, color 0.3s ease;
}

/* Hide number-input spinners */
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
input[type=number] { -moz-appearance: textfield; }

/* --- Modal ---------------------------------------------------------------- */
.modal {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.modal-content {
    background: var(--card);
    backdrop-filter: blur(20px);
    padding: 50px;
    border-radius: var(--radius);
    box-shadow: var(--shadow), var(--shadow-glow);
    max-width: 500px;
    width: 90%;
    border: 1px solid rgba(59, 125, 217, 0.2);
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-content h2 {
    color: var(--primary);
    margin-bottom: 10px;
    font-size: 32px;
    font-weight: 800;
}

.modal-content p {
    color: var(--text-soft);
    margin-bottom: 30px;
}

/* --- Generic field -------------------------------------------------------- */
.field {
    margin-bottom: 20px;
}

.field label {
    display: block;
    font-weight: 600;
    margin-bottom: 2px;
    color: var(--text-main);
    font-size: 14px;
}

.field input,
.field select,
.field textarea {
    width: 100%;
    padding: 12px 14px;
    background: var(--input-bg);
    border: 2px solid var(--input-border);
    border-radius: var(--radius-sm);
    color: var(--text-main);
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.field textarea {
    min-height: 100px;
    resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 125, 217, 0.1);
}

/* --- Header --------------------------------------------------------------- */
.header {
    position: sticky;
    top: 0;
    background: var(--card);
    backdrop-filter: blur(20px);
    padding: 15px 30px;
    box-shadow: var(--shadow);
    z-index: 100;
    border-bottom: 1px solid rgba(59, 125, 217, 0.2);
}

.header-content {
    max-width: 1600px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 800;
    font-size: 20px;
    box-shadow: 0 0 20px rgba(59, 125, 217, 0.5);
}

.user-details h3 { font-size: 13px; font-weight: 700; }
.user-details p  { font-size: 13px; color: var(--text-soft); }

.header-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* --- Buttons --------------------------------------------------------------  */
.btn {
    padding: 10px 18px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: inherit;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    box-shadow: 0 4px 12px rgba(59, 125, 217, 0.3);
}
.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(59, 125, 217, 0.5);
}

.btn-success { background: linear-gradient(135deg, #11998e, #38ef7d); color: white; }
.btn-warning { background: linear-gradient(135deg, #f39c12, #f1c40f); color: white; }
.btn-danger  { background: linear-gradient(135deg, #e74c3c, #c0392b); color: white; }

.theme-toggle {
    background: var(--input-bg);
    border: 2px solid var(--input-border);
    color: var(--text-main);
    font-size: 20px;
    width: 45px;
    height: 45px;
    padding: 0;
    justify-content: center;
}

/* --- About modal author layout ------------------------------------------- */
.author-content {
    display: flex;
    gap: 30px;
    align-items: center;
    flex-wrap: wrap;
}

.author-info { flex: 1; min-width: 300px; }
.author-info h2          { color: var(--primary); font-size: 24px; margin-bottom: 5px; }
.author-info .title      { color: var(--text-soft); font-size: 13px; font-weight: 600; margin-bottom: 15px; }
.author-info ul          { list-style: none; padding: 0; }
.author-info li          { color: var(--text-main); font-size: 14px; margin-bottom: 6px; padding-left: 20px; position: relative; }
.author-info li::before  { content: '\2713'; position: absolute; left: 0; color: var(--primary); font-weight: 700; }

/* --- Date search ---------------------------------------------------------- */
.date-search {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.date-search input[type="date"] {
    flex: 1;
    padding: 10px 12px;
    background: var(--input-bg);
    border: 2px solid var(--input-border);
    border-radius: var(--radius-sm);
    color: var(--text-main);
    font-size: 13px;
    font-family: inherit;
}
.date-search input[type="date"]:focus { border-color: var(--primary); outline: none; }

.btn-clear-date {
    padding: 10px 16px;
    background: var(--input-bg);
    border: 2px solid var(--input-border);
    color: var(--text-main);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    transition: all 0.3s ease;
}
.btn-clear-date:hover {
    border-color: var(--primary);
    background: rgba(59, 125, 217, 0.1);
}

/* --- Footer --------------------------------------------------------------- */
.footer {
    text-align: center;
    padding: 20px;
    color: var(--text-soft);
    font-size: 13px;
    border-top: 1px solid rgba(59, 125, 217, 0.2);
    margin-top: 40px;
}
.footer strong { color: var(--primary); font-weight: 700; }

/* --- Print selection checkboxes ------------------------------------------ */
.case-checkbox {
    width: 20px;
    height: 20px;
    accent-color: var(--primary);
    cursor: pointer;
}

.print-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.print-report { display: none; }

/* --- Print styles — A4 format -------------------------------------------- */
@media print {
    @page {
        size: A4 portrait;
        margin: 5mm;
    }

    * {
        background: white !important;
        color: black !important;
        box-shadow: none !important;
        text-shadow: none !important;
    }

    body { background: white !important; margin: 0; padding: 0; }

    .header, .footer, .db-panel, .form-container, .notification,
    .btn, button, .case-actions, .print-actions, .filter-options,
    .search-box, .date-search, .form-panel, .container {
        display: none !important;
    }

    .print-report {
        display: block !important;
        page-break-after: always;
        background: white;
        color: black;
        padding: 0; margin: 0;
        width: 100%;
        max-height: 277mm;
        transform: scale(0.88);
        transform-origin: top left;
        overflow: hidden;
    }
    .print-report:last-child { page-break-after: auto; }

    .print-header {
        border-bottom: 1.5px solid #2563eb;
        padding-bottom: 1mm;
        margin-bottom: 1.5mm;
    }

    .print-title {
        font-size: 16px;
        font-weight: 800;
        color: #2563eb !important;
        margin: 0;
        line-height: 1;
    }

    .print-subtitle {
        font-size: 12px;
        color: #666 !important;
        margin: 0;
        line-height: 1;
    }

    .print-section { margin-bottom: 1.5mm; page-break-inside: avoid; }

    .print-section-title {
        font-size: 14px;
        font-weight: 700;
        color: #2563eb !important;
        border-bottom: 0.5px solid #ccc;
        padding-bottom: 0.5mm;
        margin-bottom: 1mm;
        text-transform: uppercase;
        line-height: 1;
    }

    .print-field {
        display: flex;
        gap: 1mm;
        font-size: 12px;
        line-height: 1.05;
    }

    .print-label  { font-weight: 700; color: #000 !important; white-space: nowrap; }
    .print-value  { color: #000 !important; word-break: break-word; }

    .print-notes-section {
        margin-top: 2mm;
        padding-top: 1.5mm;
        border-top: 1.5px solid #2563eb;
        max-height: 75mm;
        overflow: hidden;
    }

    .print-notes-title {
        font-size: 14px;
        font-weight: 700;
        color: #2563eb !important;
        margin-bottom: 1mm;
        line-height: 1;
    }

    .print-notes-content {
        font-size: 12px;
        line-height: 1.15;
        max-height: 70mm;
        overflow: hidden;
    }

    .print-footer {
        margin-top: 2mm;
        padding-top: 1mm;
        border-top: 0.5px solid #ddd;
        font-size: 10px;
        color: #666 !important;
        text-align: center;
        line-height: 1;
    }
}

/* --- Main container (2-col grid) ----------------------------------------- */
.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 20px;
    display: grid;
    grid-template-columns: 1fr 500px;
    gap: 20px;
}

.form-panel {
    background: var(--card);
    backdrop-filter: blur(20px);
    padding: 40px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid rgba(59, 125, 217, 0.2);
}

/* --- Title block ---------------------------------------------------------- */
.title-block {
    text-align: center;
    padding: 30px;
    margin-bottom: 30px;
    border-radius: var(--radius);
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    box-shadow: var(--shadow-glow);
}
.title-block h1 { font-size: 28px; font-weight: 800; color: white; margin-bottom: 3px; }
.version {
    background: rgba(255, 255, 255, 0.2);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    color: white;
}

/* --- Form sections -------------------------------------------------------- */
.section {
    margin-bottom: 30px;
    background: rgba(26, 29, 41, 0.3);
    padding: 25px;
    border-radius: var(--radius);
    border-left: 4px solid var(--primary);
}

.section-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid rgba(59, 125, 217, 0.3);
    display: flex;
    align-items: center;
    gap: 12px;
}

.section-number {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    width: 32px; height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: 800;
    box-shadow: 0 0 15px rgba(59, 125, 217, 0.5);
    flex-shrink: 0;
}

.field-group {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 15px;
}

/* --- Checkbox & Radio groups ---------------------------------------------- */
.checkbox-group,
.radio-group {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 10px;
}

.checkbox-item,
.radio-item {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--input-bg);
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    border: 2px solid var(--input-border);
    cursor: pointer;
    transition: border-color 0.3s ease, background 0.3s ease;
}

.checkbox-item:hover,
.radio-item:hover {
    border-color: var(--primary);
    background: rgba(59, 125, 217, 0.1);
}

.checkbox-item input,
.radio-item input {
    width: 18px; height: 18px;
    cursor: pointer;
    accent-color: var(--primary);
}

.checkbox-item label,
.radio-item label {
    cursor: pointer;
    font-weight: 600;
    color: var(--text-main);
}

/* IBW auto-calc badge */
.auto-calc {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark)) !important;
    color: white !important;
    font-weight: 700;
    border: none !important;
}

/* Conditional "other" fields — hidden by default, shown via .show */
.other-field          { margin-top: 12px; display: none; }
.other-field.show     { display: block; }

/* --- Case Decision block -------------------------------------------------- */
.case-decision {
    background: linear-gradient(135deg, rgba(59,125,217,0.1), rgba(37,99,199,0.1));
    padding: 25px;
    border-radius: var(--radius);
    border: 2px solid var(--primary);
    margin: 30px 0;
}

.decision-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 15px;
    text-align: center;
}

.decision-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.decision-btn {
    padding: 15px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 700;
    font-size: 15px;
    font-family: inherit;
    transition: all 0.3s ease;
}

.decision-btn.proceed  { background: linear-gradient(135deg, #11998e, #38ef7d); color: white; }
.decision-btn.postpone { background: linear-gradient(135deg, #f39c12, #f1c40f); color: white; }
.decision-btn:hover     { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(0,0,0,0.3); }
.decision-btn.active    { box-shadow: 0 0 0 3px rgba(59,125,217,0.5); }

.postpone-reason       { margin-top: 15px; display: none; }
.postpone-reason.show  { display: block; }

/* --- Form submit buttons -------------------------------------------------- */
.form-buttons {
    display: flex;
    gap: 15px;
    margin-top: 40px;
    justify-content: center;
}

.btn-large {
    padding: 15px 35px;
    font-size: 15px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* --- Database panel ------------------------------------------------------- */
.db-panel {
    background: var(--card);
    backdrop-filter: blur(20px);
    padding: 25px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid rgba(59, 125, 217, 0.2);
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    position: sticky;
    top: 100px;
}

.db-header h2 { color: var(--primary); font-size: 22px; margin-bottom: 15px; font-weight: 800; }

.db-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 20px;
}

.stat-box {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    padding: 15px;
    border-radius: var(--radius-sm);
    text-align: center;
}
.stat-box .number { font-size: 24px; font-weight: 800; color: white; }
.stat-box .label  { font-size: 11px; color: rgba(255,255,255,0.9); font-weight: 600; }

.search-box { margin-bottom: 15px; }

.filter-options {
    display: flex;
    gap: 8px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 6px 12px;
    border: 2px solid var(--primary);
    background: transparent;
    color: var(--primary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 11px;
    font-weight: 700;
    font-family: inherit;
    transition: all 0.3s ease;
}
.filter-btn.active { background: var(--primary); color: white; }

.case-list { max-height: 500px; overflow-y: auto; }

/* --- Case cards ----------------------------------------------------------- */
.case-card {
    background: rgba(26, 29, 41, 0.4);
    padding: 15px;
    border-radius: var(--radius-sm);
    margin-bottom: 10px;
    border-left: 4px solid var(--primary);
    transition: all 0.3s ease;
}
.case-card:hover {
    background: rgba(26, 29, 41, 0.7);
    transform: translateX(5px);
}

.case-card .case-id       { font-size: 8px; color: var(--text-faint); margin-bottom: 5px; }
.case-card .case-patient  { font-weight: 700; font-size: 15px; margin-bottom: 5px; }
.case-card .case-info     { font-size: 12px; color: var(--text-soft); margin-bottom: 3px; }
.case-card .case-date     { font-size: 8px; color: var(--text-faint); margin-top: 8px; }

.case-actions { display: flex; gap: 6px; margin-top: 10px; }
.btn-sm       { padding: 5px 12px; font-size: 11px; font-weight: 700; }

/* --- Notification toast -------------------------------------------------- */
.notification {
    position: fixed;
    top: 20px; right: 20px;
    padding: 16px 24px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    display: none;
    z-index: 1000;
    font-weight: 700;
    font-size: 14px;
}

.notification.show {
    display: block;
    animation: slideIn 0.3s ease;
}

.notification.success { background: linear-gradient(135deg, #11998e, #38ef7d); color: white; }
.notification.error   { background: linear-gradient(135deg, #eb3349, #f45c43); color: white; }
.notification.info    { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: white; }

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

/* --- Custom scrollbar ----------------------------------------------------- */
::-webkit-scrollbar       { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg-soft); }
::-webkit-scrollbar-thumb { background: var(--primary); border-radius: 4px; }

/* ==========================================================================
   RESPONSIVE BREAKPOINTS
   ========================================================================== */

/* 1200px — single column layout */
@media (max-width: 1200px) {
    .container { grid-template-columns: 1fr !important; }
    .db-panel  { position: relative; top: 0; max-height: none; }
}

/* 768px — mobile */
@media (max-width: 768px) {
    .header            { width: 100%; left: 0; right: 0; }
    .header-content    { flex-direction: column; gap: 10px; }
    .header-actions    { width: 100%; justify-content: center; }

    .btn {
        flex: 1;
        min-width: 70px;
        justify-content: center;
        padding: 8px 12px;
        font-size: 11px;
    }

    .form-panel        { padding: 20px 15px; }
    .section           { padding: 15px; margin-bottom: 20px; }
    .field-group       { grid-template-columns: 1fr !important; }

    .checkbox-group,
    .radio-group       { flex-direction: column; gap: 8px; }

    .checkbox-item,
    .radio-item        { width: 100%; }

    .decision-buttons  { grid-template-columns: 1fr; }
    .author-content    { flex-direction: column; text-align: center; }
    .db-panel          { padding: 15px; }
    .db-stats          { grid-template-columns: 1fr 1fr; }
    .case-card         { padding: 12px; }
    .title-block       { padding: 20px 15px; }
    .title-block h1    { font-size: 22px; }
    .version           { font-size: 8px; padding: 4px 10px; }
    .modal-content     { padding: 30px 20px; }

    /* Prevent iOS zoom on focus */
    input, select, textarea {
        font-size: 16px !important;
        min-height: 44px;
    }

    /* Touch-friendly tap targets */
    button, .btn                  { min-height: 48px !important; touch-action: manipulation; }
    .checkbox-item, .radio-item   { min-height: 48px; padding: 10px; }
}

/* 480px — small mobile */
@media (max-width: 480px) {
    .form-panel     { padding: 15px 10px; }
    .section        { padding: 12px; }
    .title-block    { padding: 15px 10px; }
    .title-block h1 { font-size: 18px; }
    .btn            { padding: 6px 10px; font-size: 8px; }
    .user-avatar    { width: 40px; height: 40px; font-size: 13px; }
}
