/* All CSS from your original <style> tag is now in this file */
:root {
    --primary-color: #3498db;
    --secondary-color: #2c3e50;
    --light-gray: #f4f7f9;
    --text-color: #34495e;
    --sidebar-bg: linear-gradient(180deg, #2c3e50, #34495e);
    --sidebar-text: #ecf0f1;
    --sidebar-active-text: #ffffff;
}

body {
    background-color: var(--light-gray);
    font-family: 'Poppins', sans-serif;
}

/* Hide login page by default in the new structure */
#login-page {
    display: none;
}

#app-content {
    display: block; /* Show app content by default */
}

.top-navbar {
    box-shadow: 0 2px 8px rgba(0,0,0,.1);
    background: #ffffff;
}
.navbar-brand {
    color: var(--secondary-color) !important;
    font-weight: 600;
}

.content-wrapper {
    margin-left: 260px;
    padding: 2rem;
    transition: margin-left 0.3s ease;
}

.emr-prominent {
    display: inline-block;
    font-weight: 900;
    color: #000000;
    font-size: 1.8em;
    background-color: #e9ecef;
    padding: 2px 8px;
    border-radius: 5px;
    border: 2px solid #343a40;
    line-height: 0.8;
    margin-top: 4px;
}

.sidebar {
    width: 260px;
    background: var(--sidebar-bg);
    box-shadow: 4px 0 15px rgba(0,0,0,.1);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1000;
    display: flex;
    flex-direction: column;
}
.sidebar-header {
    padding: 1.5rem;
    text-align: center;
    color: #ffffff;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.sidebar-header h5 {
    margin: 0;
    font-weight: 600;
}
.sidebar .nav {
    flex-grow: 1;
}
.sidebar .nav-link {
    padding: 1rem 1.5rem;
    color: var(--sidebar-text);
    border-left: 5px solid transparent;
    transition: all 0.3s ease;
    font-weight: 500;
    display: flex;
    align-items: center;
}
.sidebar .nav-link i {
    margin-right: 15px;
    font-size: 1.2em;
    width: 25px;
    text-align: center;
}
.sidebar .nav-link:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--sidebar-active-text);
}
.sidebar .nav-link.active {
    color: var(--sidebar-active-text);
    background-color: rgba(255, 255, 255, 0.1);
    border-left-color: var(--primary-color);
    font-weight: 600;
}

/* This is no longer needed as each page is separate */
/* .main-section { display: none; } */
/* .main-section.active { display: block; } */

.main-section > h2 {
    background-color: #ffffff;
    padding: 1.25rem 1.75rem;
    border-radius: 0.75rem;
    margin-bottom: 2rem;
    color: var(--text-color);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    border-left: 5px solid var(--primary-color);
    font-weight: 600;
}

.card {
    border-radius: 0.75rem;
    box-shadow: 0 4px 15px rgba(0,0,0,0.06);
    border: none;
}
.card-header {
    background-color: #fdfdff;
    font-weight: 600;
    color: var(--text-color);
    border-bottom: 1px solid #e9ecef;
    padding: 1rem 1.25rem;
}

.stat-card {
    border-radius: 0.75rem;
    color: #fff;
}
.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0,0,0,.15);
}
.stat-card .card-body {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.stat-card i {
    font-size: 3rem;
    opacity: 0.3;
}
.bg-primary { background-color: #3498db !important; }
.bg-success { background-color: #2ecc71 !important; }
.bg-info { background-color: #1abc9c !important; }
.bg-warning { background-color: #f1c40f !important; }
.bg-danger { background-color: #e74c3c !important; }
.bg-secondary { background-color: #95a5a6 !important; }


.modal-header {
    background-color: var(--primary-color);
    color: white;
}
.btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

#prescription-navigation .btn-group {
    gap: 0.5rem;
}
#prescription-navigation .btn {
    border-radius: 0.375rem !important; /* bs5 default */
}

.preview-v-pattern { position: relative; width: 100px; height: 70px; }
.preview-v-pattern::before, .preview-v-pattern::after { content: ''; position: absolute; background-color: #555; width: 40px; height: 1.5px; left: 0; top: 50%; transform-origin: left center; }
.preview-v-pattern::before { transform: translateY(-1px) rotate(-30deg); }
.preview-v-pattern::after { transform: translateY(-1px) rotate(30deg); }
.preview-v-pattern .value { position: absolute; left: 45px; font-size: 0.9rem; font-weight: 500; min-width: 50px; white-space: nowrap; color: #333; }
.preview-v-pattern .value.od { top: -8px; }
.preview-v-pattern .value.os { bottom: -8px; }

.prescription-table th,
.prescription-table td {
    text-align: center;
    padding: 0.5rem;
    border: 1px solid #dee2e6;
}
.prescription-table input {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #ced4da;
    border-radius: 0.25rem;
    text-align: center;
}
.prescription-table th.eye-header {
    background-color: #f8f9fa;
    font-weight: 600;
    color: #212529;
}
.prescription-table th.param-header {
    background-color: #f8f9fa;
    font-weight: 500;
    color: #495057;
}
.table-row-completed {
    background-color: #d4edda !important;
    border-left: 5px solid #28a745;
    transition: background-color 0.3s ease;
}
.table-row-completed:hover {
    background-color: #c3e6cb !important;
}
.patient-name-completed {
    font-weight: 700;
    color: #000000;
}

#live-preview-panel {
    background: #ffffff;
    border: 1px solid #e0e0e0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    border-radius: 0.5rem;
    padding: 1.5rem;
    font-family: 'Times New Roman', Times, serif;
    position: sticky;
    top: 90px;
    height: calc(100vh - 120px);
    overflow-y: auto;
}
#live-preview-panel h3 {
    font-size: 11pt;
    font-weight: bold;
    color: #fff;
    background-color: #4a4a4a;
    padding: 3px 6px;
    margin: 10px 0 5px 0;
}
#live-preview-panel .live-patient-info {
    border-bottom: 2px solid #333;
    padding-bottom: 10px;
    margin-bottom: 10px;
    font-size: 10pt;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
}
#live-preview-panel .live-patient-info span { font-weight: bold; margin-right: 5px;}
#live-preview-panel .live-patient-info p { margin: 0 10px 5px 0; }
#live-preview-panel pre {
    font-family: inherit;
    font-size: 10pt;
    white-space: pre-wrap;
    word-wrap: break-word;
    margin: 0 0 10px 0;
    padding: 2px 4px;
    border: 1px dotted #ccc;
    min-height: 1.5em;
    line-height: 1.4;
}
#live-preview-panel .live-med-list { list-style-type: none; padding-left: 0; font-size: 11pt; }
#live-preview-panel .live-med-list li { margin-bottom: 0.75rem; border-bottom: 1px dotted #ccc; padding-bottom: 0.5rem; }
#live-preview-panel .live-med-list .med-name { font-weight: bold; font-size: 11pt; }
#live-preview-panel .live-med-list .med-details { text-align: right; font-size: 10pt; }
#live-preview-panel .live-med-list .med-details span { 
    margin-left: 1em; 
    white-space: pre-wrap;
    display: inline-block;
    vertical-align: top;
}
#live-preview-panel .live-print-table { width: 100%; border-collapse: collapse; margin-bottom: 5px; }
#live-preview-panel .live-print-table th, #live-preview-panel .live-print-table td { border: 1px solid #000; padding: 2px 4px; text-align: center; font-size: 9pt; }
#live-preview-panel .live-print-table td { min-width: 30px; }

.ias-time-slot-btn {
    transition: all 0.2s ease;
    cursor: pointer;
}
.ias-time-slot-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    background-color: #e9f5ff;
    border-color: var(--primary-color);
}


@media (max-width: 992px) {
    .sidebar {
        left: -260px;
    }
    .content-wrapper {
        margin-left: 0;
    }
}
@media (max-width: 768px) {
    .sidebar {
        position: relative;
        width: 100%;
        height: auto;
        left: 0;
        box-shadow: none;
        border-bottom: 2px solid #ddd;
        padding-top: 0;
    }
    .content-wrapper {
        padding: 1rem;
        margin-left: 0; /* Added this for consistency */
    }
     .sidebar .nav { flex-direction: row; flex-wrap: wrap; }
    .sidebar .nav-link { border-left: none; border-bottom: 3px solid transparent; flex: 1 1 120px; justify-content: center;}
    .sidebar .nav-link.active { border-bottom-color: var(--primary-color); }
    .sidebar-header { display: none; }
}

#prescription-print-area, #token-print-area { display: none; }

@media print {
    body * {
        visibility: visible;
    }
    
    /* Print visibility rules */
    body.printing-prescription #prescription-print-area,
    body.printing-prescription #prescription-print-area * {
        visibility: visible;
    }
    body.printing-token #token-print-area,
    body.printing-token #token-print-area * {
        visibility: visible;
    }

    #prescription-print-area {
        display: block !important;
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        height: 100%;
        font-family: 'Times New Roman', Times, serif;
        -webkit-print-color-adjust: exact;
        color-adjust: exact;
    }
    #prescription-print-area .page {
        background: white;
        width: 210mm;
        height: 297mm;
        margin: 0;
        display: flex;
        flex-direction: column;
        position: relative;
        box-sizing: border-box;
        padding: 5mm 8mm;
        overflow: hidden;
    }
    #prescription-print-area .header {
        width: 100%;
        height: auto;
        box-sizing: border-box;
        padding: 0;
        border-bottom: 2px solid #333;
    }
    #prescription-print-area .header-bottom-row {
        display: flex;
        justify-content: space-between;
        width: 100%;
        padding: 10px 0;
        font-size: 12px;
        font-family: Arial, sans-serif;
    }
    #prescription-print-area .header-bottom-row p { margin: 0; }
    #prescription-print-area .header-bottom-row span { font-weight: bold; }
    #prescription-print-area .main-content {
        flex-grow: 1;
        width: 100%;
        display: flex;
    }
    #prescription-print-area .left-column {
        width: 30%;
        padding: 15px 15px 15px 0;
        box-sizing: border-box;
        border-right: 1px solid #333;
        display: flex;
        flex-direction: column;
    }
    #prescription-print-area .right-column {
        width: 70%;
        padding: 15px 0 15px 15px;
        box-sizing: border-box;
        display: flex;
        flex-direction: column;
    }
    #prescription-print-area .right-column-main-content {
        flex-grow: 1;
    }
    #prescription-print-area .footer {
        width: 100%;
        height: auto;
        box-sizing: border-box;
        border-top: 2px solid #333;
        display: flex;
        flex-direction: column;
        justify-content: center;
        font-family: 'Times New Roman', serif;
        font-size: 14px;
        padding: 10px 0;
    }
    #prescription-print-area #print-old-refraction-section {
        margin-top: auto;
    }
    #prescription-print-area .section h3 {
        font-size: 12pt;
        margin: 0 0 5px 0;
        padding-bottom: 3px;
        font-weight: bold;
        background-color: #4a4a4a;
        color: #ffffff;
        padding: 4px 8px;
        margin-right: -15px;
        border-bottom: 1px solid #ccc;
    }
    #prescription-print-area #print-new-refraction-section h3 {
        background-color: transparent;
        color: inherit;
        padding: 0;
        margin-right: 0;
    }
    #prescription-print-area .section p, #prescription-print-area .section ul, #prescription-print-area .section table {
        font-size: 11pt;
        margin: 0;
        line-height: 1.4;
    }
    #prescription-print-area .section p { min-height: 1.2em; }
    #prescription-print-area .section pre {
        font-family: inherit;
        margin: 0;
        padding: 0;
        font-size: 11pt;
        line-height: 1.4;
        white-space: pre-wrap;
        word-wrap: break-word;
        min-height: 1.2em;
    }
    #prescription-print-area .rx-symbol {
        font-family: 'Garamond', serif;
        font-size: 2.5em;
        font-weight: bold;
        float: left;
        margin-right: 8px;
        line-height: 1;
    }
    #prescription-print-area .medication-list {
        padding-left: 40px;
        list-style-type: none;
    }
    #prescription-print-area .medication-list li {
        margin-bottom: 1rem;
        border-bottom: 1px dotted #ccc;
        padding-bottom: 0.5rem;
    }
    #prescription-print-area .medication-list .med-name {
        font-weight: bold;
        font-size: 14pt;
        margin-bottom: 0.25rem;
    }
    #prescription-print-area .medication-list .med-details {
        text-align: right;
        font-size: 12pt;
    }
    #prescription-print-area .medication-list .med-details span {
        margin-left: 1.5em;
        white-space: pre-wrap;
        display: inline-block;
        vertical-align: top;
    }
    #prescription-print-area .print-table { width: 100%; border-collapse: collapse; margin-bottom: 5px; }
    #prescription-print-area .print-table th, #prescription-print-area .print-table td { border: 1px solid #000; padding: 2px 4px; text-align: center; font-size: 10pt; }
    #prescription-print-area #print-old-refraction-section .print-table th,
    #prescription-print-area #print-old-refraction-section .print-table td {
        font-size: 8pt;
        padding: 1px;
    }
    #prescription-print-area .vision-values {
        display: flex;
        justify-content: flex-start;
        gap: 20px;
        font-size: 11pt;
        padding-left: 8px;
        margin: 0;
        white-space: nowrap;
    }
    #prescription-print-area .vision-values > span {
        font-weight: bold;
    }
    #prescription-print-area .vision-values .value-placeholder {
        font-weight: normal;
        min-width: 50px;
        display: inline-block;
        border-bottom: 1px dotted #999;
        padding: 0 4px;
        text-align: center;
    }
    #print-new-refraction-section h3 {
        display: none;
    }
}

@page {
    size: A4;
    margin: 0;
}

.blinking-notification {
    animation: blink-animation 1.5s infinite;
}

@keyframes blink-animation {
    0% { background-color: #cff4fc; }
    50% { background-color: #9eeaf9; }
    100% { background-color: #cff4fc; }
}

#suggestion-box {
    display: none;
    position: absolute;
    border: 1px solid #ccc;
    background-color: #fff;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1060;
    box-shadow: 0 5px 15px rgba(0,0,0,.2);
    border-radius: 0.375rem;
    min-width: 250px;
}
.suggestion-item {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 0.9rem;
    border-bottom: 1px solid #f0f0f0;
}
.suggestion-item:last-child {
    border-bottom: none;
}
.suggestion-item:hover {
    background-color: #f5f5f5;
}
.suggestion-item strong {
    color: var(--primary-color);
}
