/* ===========================================
   ICD-10 Coding Review System - Styles
   Modern Thai Hospital UI - Daily Review Design
   =========================================== */

/* CSS Variables */
:root {
    /* Colors */
    --primary: #3b82f6;
    --primary-light: #eff6ff;
    --success: #22c55e;
    --success-light: #dcfce7;
    --warning: #f59e0b;
    --danger: #ef4444;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-tertiary: #94a3b8;
    --bg-page: #f8fafc;
    --bg-card: #ffffff;
    --border-color: #e2e8f0;
    
    /* Spacing */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-6: 1.5rem;
    
    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    
    /* Typography */
    --font-main: 'IBM Plex Sans Thai', -apple-system, sans-serif;
}

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

body {
    font-family: var(--font-main);
    background-color: var(--bg-page);
    color: var(--text-primary);
    min-height: 100vh;
}

.app-container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 40px;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 40px;
}

.header-left {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.page-title {
    font-size: 32px;
    font-weight: 700;
    color: #0f172a;
    letter-spacing: -0.5px;
}

/* User Profile */
.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    text-align: right;
}

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

.user-name {
    font-weight: 700;
    font-size: 16px;
    color: #1e293b;
}

.user-role {
    font-size: 14px;
    color: #64748b;
}

.user-avatar {
    width: 48px;
    height: 48px;
    background-color: #1d4ed8;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 6px -1px rgba(29, 78, 216, 0.2);
}

/* Tabs */
.tabs {
    display: flex;
    gap: 4px;
    background: #e2e8f0;
    padding: 4px;
    border-radius: 12px;
    width: fit-content;
}

.tab {
    padding: 8px 16px;
    border: none;
    background: transparent;
    border-radius: 8px;
    font-family: inherit;
    font-weight: 600;
    font-size: 14px;
    color: #64748b;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.tab.active {
    background: white;
    color: #0f172a;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.tab-count {
    color: #64748b;
    font-size: 12px;
}

/* Results Table */
.results-section {
    background: transparent;
}

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

.results-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 12px;
}

.results-table th {
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: #94a3b8;
    letter-spacing: 1px;
    text-transform: uppercase;
    padding: 0 24px 12px 24px;
}

.results-table tbody tr {
    background: white;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    transition: transform 0.2s;
}

.results-table tbody tr:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05);
}

.results-table td {
    padding: 24px;
    vertical-align: top;
    border-top: 1px solid #f1f5f9;
    border-bottom: 1px solid #f1f5f9;
}

.results-table td:first-child {
    border-left: 1px solid #f1f5f9;
    border-top-left-radius: 16px;
    border-bottom-left-radius: 16px;
}

.results-table td:last-child {
    border-right: 1px solid #f1f5f9;
    border-top-right-radius: 16px;
    border-bottom-right-radius: 16px;
}

/* Columns */
.col-datetime { width: 15%; }
.col-patient { width: 25%; }
.col-diagnosis { width: 25%; }
.col-icd { width: 20%; }
.col-actions { width: 15%; text-align: right; }

/* Cell Content */
.datetime-date {
    font-weight: 700;
    font-size: 16px;
    color: #1e293b;
    margin-bottom: 4px;
}

.datetime-time {
    font-size: 14px;
    color: #64748b;
}

.patient-name {
    font-weight: 700;
    font-size: 16px;
    color: #1e293b;
    margin-bottom: 4px;
}

.patient-info {
    font-size: 14px;
    color: #64748b;
    margin-bottom: 8px;
}

.btn-view-emr {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #3b82f6;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    border: none;
    background: none;
    cursor: pointer;
    padding: 0;
}

.btn-add-diagnosis {
    display: inline-block;
    padding: 8px 16px;
    border: 1px dashed #3b82f6;
    border-radius: 8px;
    color: #3b82f6;
    font-weight: 600;
    font-size: 14px;
    background: #eff6ff;
    cursor: pointer;
    text-decoration: none;
}

.diagnosis-text {
    font-size: 16px;
    color: #334155;
    line-height: 1.5;
}

/* ICD Suggestion */
.icd-suggestion {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.icd-code-badge {
    background: #f1f5f9;
    padding: 6px 12px;
    border-radius: 6px;
    font-weight: 700;
    color: #1e293b;
    font-size: 14px;
    min-width: 60px;
    text-align: center;
}

.icd-bar-container {
    display: flex;
    align-items: center;
    gap: 6px;
}

.icd-confidence-bar {
    width: 24px;
    height: 8px;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.icd-confidence-fill {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    background: #cbd5e1;
}

.icd-confidence-fill.high { background: #64748b; }
.icd-confidence-text {
    color: #22c55e;
    font-weight: 700;
    font-size: 14px;
}

/* Actions */
.actions-cell {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

.btn-approve-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 20px;
    border-radius: 20px;
    border: none;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-approve-pill.active {
    background: #22c55e;
    color: white;
}

.btn-approve-pill.inactive {
    background: #e2e8f0;
    color: #94a3b8;
}

.btn-icon-circle {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid #e2e8f0;
    background: white;
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-icon-circle:hover {
    border-color: #cbd5e1;
    color: #1e293b;
}

/* Modals (Keep existing structural styles, update colors) */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}
.modal-overlay.active { opacity: 1; pointer-events: auto; }

.modal {
    background: white;
    border-radius: 16px;
    width: 500px;
    max-width: 90%;
    padding: 24px;
    box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-header h3 { font-size: 18px; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 24px; cursor: pointer; color: #94a3b8; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 8px; font-weight: 500; font-size: 14px; }
.form-group input, .form-group textarea {
    width: 100%; padding: 10px; border: 1px solid #e2e8f0; border-radius: 8px; font-family: inherit;
}
.modal-footer { display: flex; justify-content: flex-end; gap: 12px; margin-top: 24px; }

/* Existing Utility Classes needed for JS */
.loading-spinner { /* ... keep existing ... */ }

/* ===== RESPONSIVE: iPad landscape / large tablet (≤1024px) ===== */
@media (max-width: 1024px) {
    .app-container {
        padding: 24px;
    }

    .page-title {
        font-size: 26px;
    }

    .results-table td {
        padding: 16px;
    }

    .results-table th {
        padding: 0 16px 12px 16px;
    }

    .actions-cell {
        flex-direction: column;
        align-items: flex-end;
        gap: 6px;
    }

    .btn-approve-pill {
        padding: 6px 14px;
        font-size: 13px;
    }
}

/* ===== RESPONSIVE: iPad portrait / small tablet (≤810px) ===== */
@media (max-width: 810px) {
    .app-container {
        padding: 16px;
    }

    .header {
        margin-bottom: 24px;
    }

    .page-title {
        font-size: 22px;
    }

    .results-table td {
        padding: 12px;
    }

    .results-table th {
        padding: 0 12px 10px 12px;
        font-size: 11px;
        letter-spacing: 0.5px;
    }

    .col-datetime { width: 12%; }
    .col-patient  { width: 22%; }
    .col-diagnosis { width: 28%; }
    .col-icd      { width: 18%; }
    .col-actions  { width: 20%; }

    .datetime-date { font-size: 14px; }
    .datetime-time { font-size: 12px; }

    .patient-name { font-size: 14px; }
    .patient-info { font-size: 12px; }

    .diagnosis-text { font-size: 14px; }

    .icd-suggestion { gap: 8px; }

    .icd-code-badge {
        font-size: 12px;
        padding: 4px 8px;
        min-width: 50px;
    }

    .icd-confidence-text { font-size: 12px; }

    .actions-cell {
        flex-direction: column;
        align-items: flex-end;
        gap: 6px;
    }

    .btn-approve-pill {
        padding: 6px 12px;
        font-size: 12px;
        border-radius: 16px;
    }

    .btn-icon-circle {
        width: 30px;
        height: 30px;
    }

    .modal {
        width: calc(100vw - 32px);
        max-width: 100%;
        padding: 20px;
    }

    .user-name { font-size: 14px; }
    .user-role { font-size: 12px; }

    .user-avatar {
        width: 40px;
        height: 40px;
        border-radius: 10px;
    }

    .tab {
        padding: 6px 12px;
        font-size: 13px;
    }
}
