/* Mock EHR Styles - Clinical/Utilitarian Design */

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

:root {
    --primary: #1a5f7a;
    --primary-dark: #134b5f;
    --primary-light: #2980b9;
    --accent: #27ae60;
    --danger: #c0392b;
    --warning: #f39c12;
    --background: #ecf0f1;
    --surface: #ffffff;
    --text: #2c3e50;
    --text-light: #7f8c8d;
    --border: #bdc3c7;
    --shadow: rgba(0, 0, 0, 0.1);
    --mena-purple: #7c3aed;
    --mena-purple-light: #a78bfa;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--background);
    color: var(--text);
    line-height: 1.5;
}

#app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.ehr-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 0.75rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px var(--shadow);
    z-index: 100;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.brand-icon {
    font-size: 1.5rem;
    font-weight: bold;
    background: white;
    color: var(--primary);
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.brand-name {
    font-size: 1.25rem;
    font-weight: 600;
}

.header-user {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.user-name {
    font-weight: 500;
}

.user-role {
    font-size: 0.875rem;
    opacity: 0.8;
}

/* Main Container */
.main-container {
    display: flex;
    flex: 1;
    position: relative;
}

/* Sidebar */
.sidebar {
    width: 200px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 1rem 0;
    flex-shrink: 0;
}

.nav-menu {
    display: flex;
    flex-direction: column;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    color: var(--text);
    text-decoration: none;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.nav-item:hover {
    background: var(--background);
}

.nav-item.active {
    background: var(--background);
    border-left-color: var(--primary);
    color: var(--primary);
    font-weight: 500;
}

.nav-icon {
    font-size: 1.25rem;
}

/* Content Area */
.content {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
    max-height: calc(100vh - 60px);
    transition: margin-right 0.3s ease;
}

.content.panel-open {
    margin-right: 420px;
}

/* Views */
.view {
    display: none;
}

.view.active {
    display: block;
}

.view-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.view-header h1 {
    font-size: 1.5rem;
    color: var(--text);
}

.search-input {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.875rem;
    width: 250px;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary);
}

/* Mena Settings Panel */
.mena-settings {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
}

.settings-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.settings-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text);
    white-space: nowrap;
}

.mode-buttons {
    display: flex;
    gap: 0.5rem;
}

/* Theme Controls */
.theme-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.color-picker-group,
.mode-toggle-group,
.locale-toggle-group,
.content-lang-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.color-picker-group label,
.mode-toggle-group label,
.locale-toggle-group label,
.content-lang-group label {
    font-size: 0.75rem;
    color: var(--text-light);
}

.color-picker-group input[type="color"] {
    width: 32px;
    height: 32px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    background: none;
}

.color-picker-group input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 2px;
}

.color-picker-group input[type="color"]::-webkit-color-swatch {
    border-radius: 2px;
    border: none;
}

.mode-toggle-group select,
.locale-toggle-group select,
.content-lang-group select {
    padding: 0.375rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.8125rem;
    background: white;
    cursor: pointer;
}

.mode-toggle-group select:focus,
.locale-toggle-group select:focus,
.content-lang-group select:focus {
    outline: none;
    border-color: var(--mena-purple);
}

.mode-btn {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: white;
    cursor: pointer;
    font-size: 0.8125rem;
    display: flex;
    align-items: center;
    gap: 0.375rem;
    transition: all 0.2s;
    color: var(--text);
}

.mode-btn:hover {
    border-color: var(--mena-purple);
    background: #f5f3ff;
}

.mode-btn.active {
    background: var(--mena-purple);
    color: white;
    border-color: var(--mena-purple);
}

.mode-icon {
    font-size: 1rem;
}

/* Patient List */
.patient-list {
    display: grid;
    gap: 1rem;
}

.patient-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    transition: all 0.2s;
}

.patient-card:hover {
    border-color: var(--primary);
    box-shadow: 0 2px 8px var(--shadow);
}

.patient-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.patient-avatar {
    width: 48px;
    height: 48px;
    background: var(--primary-light);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1.125rem;
}

.patient-details h3 {
    font-size: 1rem;
    margin-bottom: 0.25rem;
}

.patient-details p {
    font-size: 0.875rem;
    color: var(--text-light);
}

.patient-meta {
    text-align: right;
}

.patient-meta .time {
    font-size: 0.875rem;
    color: var(--text-light);
}

.patient-meta .status {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    margin-top: 0.25rem;
    display: inline-block;
}

.status.scheduled {
    background: #e8f5e9;
    color: #2e7d32;
}

.status.in-progress {
    background: #fff3e0;
    color: #ef6c00;
}

.status.completed {
    background: #e3f2fd;
    color: #1565c0;
}

/* Chart View */
.chart-header {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 1rem;
}

.back-btn {
    background: none;
    border: 1px solid var(--border);
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.2s;
}

.back-btn:hover {
    background: var(--background);
}

.patient-header-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.patient-header-info h1 {
    font-size: 1.5rem;
}

.mrn-badge {
    background: var(--background);
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    font-size: 0.875rem;
    color: var(--text-light);
}

/* Chart Cards */
.chart-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1rem;
}

.chart-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.25rem;
}

.chart-card h2 {
    font-size: 1rem;
    color: var(--text);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

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

.info-label {
    font-size: 0.75rem;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.info-value {
    font-size: 0.9375rem;
    color: var(--text);
}

/* Lists */
.condition-list,
.medication-list,
.allergy-list {
    list-style: none;
}

.condition-list li,
.medication-list li,
.allergy-list li {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--background);
    font-size: 0.9375rem;
}

.condition-list li:last-child,
.medication-list li:last-child,
.allergy-list li:last-child {
    border-bottom: none;
}

.allergies-card {
    border-left: 3px solid var(--danger);
}

.allergy-list li {
    color: var(--danger);
}

/* Vitals Grid */
.vitals-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.vital-item {
    text-align: center;
    padding: 0.75rem;
    background: var(--background);
    border-radius: 4px;
}

.vital-value {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--primary);
}

.vital-label {
    font-size: 0.75rem;
    color: var(--text-light);
    margin-top: 0.25rem;
}

/* Mena Card */
.mena-card {
    grid-column: 1 / -1;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border: 2px dashed var(--mena-purple);
    position: relative;
}

.mena-card.inline-active {
    border-style: solid;
    padding: 0;
    overflow: hidden;
}

.mena-card.inline-active h2,
.mena-card.inline-active .mena-description,
.mena-card.inline-active .mena-btn {
    display: none;
}

.mena-description {
    color: var(--text-light);
    margin-bottom: 1rem;
}

.mena-btn {
    background: linear-gradient(135deg, var(--mena-purple) 0%, #6d28d9 100%);
    color: white;
    border: none;
    padding: 0.875rem 1.5rem;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s;
}

.mena-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3);
}

.mena-icon {
    font-size: 1.25rem;
}

/* Inline Container */
.mena-inline-container {
    display: none;
    width: 100%;
    height: 600px;
}

.mena-inline-container.active {
    display: block;
}

.mena-inline-container iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* Document Card */
.document-card {
    grid-column: 1 / -1;
}

.document-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.document-header h2 {
    margin: 0;
    padding: 0;
    border: none;
}

.document-actions {
    display: flex;
    gap: 0.5rem;
}

.action-btn {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: white;
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.2s;
}

.action-btn:hover {
    background: var(--background);
}

.action-btn.primary {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.action-btn.primary:hover {
    background: #229954;
}

.document-content {
    background: var(--background);
    border-radius: 4px;
    padding: 1rem;
    max-height: 400px;
    overflow-y: auto;
    white-space: pre-wrap;
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
    line-height: 1.6;
}

.codes-section {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.codes-section h3 {
    font-size: 0.875rem;
    color: var(--text);
    margin-bottom: 0.75rem;
}

.codes-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.code-badge {
    background: var(--background);
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    font-size: 0.8125rem;
    font-family: monospace;
}

.code-badge.icd {
    border-left: 3px solid var(--primary);
}

.code-badge.billing {
    border-left: 3px solid var(--accent);
}

/* ==========================================
   MENA EMBED CONTAINERS
   ========================================== */

/* Modal Overlay */
.mena-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.mena-modal-overlay.active {
    display: flex;
    opacity: 1;
}

.mena-modal-container {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 900px;
    height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
    transform: scale(0.95);
    transition: transform 0.2s ease;
}

.mena-modal-overlay.active .mena-modal-container {
    transform: scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    background: #f9fafb;
}

.modal-header h2 {
    font-size: 1.125rem;
    color: var(--text);
    margin: 0;
}

.modal-close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-light);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    line-height: 1;
}

.modal-close-btn:hover {
    background: var(--background);
    color: var(--text);
}

.modal-content {
    flex: 1;
    overflow: hidden;
}

.modal-content iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* Side Panel */
.mena-panel {
    position: fixed;
    top: 60px;
    right: 0;
    width: 420px;
    height: calc(100vh - 60px);
    background: white;
    border-left: 1px solid var(--border);
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.1);
    z-index: 500;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.3s ease;
}

.mena-panel.active {
    transform: translateX(0);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(135deg, var(--mena-purple) 0%, #6d28d9 100%);
    color: white;
}

.panel-header h2 {
    font-size: 1rem;
    margin: 0;
    font-weight: 500;
}

.panel-close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    line-height: 1;
}

.panel-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.panel-content {
    flex: 1;
    overflow: hidden;
}

.panel-content iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* Floating Widget */
.mena-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 380px;
    height: 500px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    z-index: 900;
    display: none;
    flex-direction: column;
    overflow: hidden;
    resize: both;
    min-width: 320px;
    min-height: 400px;
}

.mena-widget.active {
    display: flex;
}

.mena-widget.expanded {
    width: 600px;
    height: 700px;
}

.widget-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: linear-gradient(135deg, var(--mena-purple) 0%, #6d28d9 100%);
    color: white;
    cursor: move;
    user-select: none;
}

.widget-title {
    font-size: 0.9375rem;
    font-weight: 500;
}

.widget-controls {
    display: flex;
    gap: 0.25rem;
}

.widget-expand-btn,
.widget-close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    font-size: 1rem;
    cursor: pointer;
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    line-height: 1;
}

.widget-expand-btn:hover,
.widget-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.widget-content {
    flex: 1;
    overflow: hidden;
}

.widget-content iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        display: none;
    }

    .chart-content {
        grid-template-columns: 1fr;
    }

    .vitals-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .info-grid {
        grid-template-columns: 1fr;
    }

    .embed-mode-selector {
        flex-direction: column;
        align-items: flex-start;
    }

    .mode-buttons {
        flex-wrap: wrap;
    }

    .mena-panel {
        width: 100%;
    }

    .mena-widget {
        width: calc(100% - 32px);
        left: 16px;
        right: 16px;
    }
}

/* =============================================================================
   EHR NOTES (FROM MENA)
   ============================================================================= */

.ehr-notes-card {
    grid-column: 1 / -1;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border: 2px solid var(--primary);
}

.ehr-notes-card .card-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.ehr-notes-card .card-header h2 {
    margin: 0;
    padding: 0;
    border: none;
    font-size: 1.125rem;
}

.badge.from-mena {
    background: var(--primary);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.refresh-btn {
    margin-left: auto;
    padding: 0.375rem 0.75rem !important;
    font-size: 0.8rem !important;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 2rem;
    color: var(--text-light);
}

.empty-state p {
    margin: 0.5rem 0;
}

.empty-state .hint {
    font-size: 0.875rem;
    opacity: 0.7;
}

.empty-state.error {
    color: #dc2626;
}

.empty-state.error .hint {
    color: var(--text-light);
}

/* EHR Note Cards */
.ehr-note {
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 1rem;
    overflow: hidden;
}

.ehr-note.structured {
    border-left: 4px solid var(--primary);
}

.ehr-note.freeform {
    border-left: 4px solid #6b7280;
}

.ehr-note .note-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
}

.ehr-note .note-title {
    font-weight: 600;
    color: var(--text);
}

.ehr-note .note-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.ehr-note .note-type {
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-weight: 600;
    text-transform: uppercase;
}

.ehr-note .note-type.structured {
    background: #dbeafe;
    color: #1d4ed8;
}

.ehr-note .note-type.freeform {
    background: #f3f4f6;
    color: #374151;
}

.ehr-note .note-date {
    font-size: 0.8rem;
    color: var(--text-light);
}

.ehr-note .note-body {
    padding: 1rem;
}

/* Structured Fields */
.structured-field {
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #f1f5f9;
}

.structured-field:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.structured-field .field-label {
    font-weight: 600;
    color: var(--primary);
    font-size: 0.875rem;
    margin-bottom: 0.375rem;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.structured-field .field-value {
    color: var(--text);
    line-height: 1.6;
    white-space: pre-wrap;
}

/* Free-form content */
.note-content-text {
    color: var(--text);
    line-height: 1.6;
    white-space: pre-wrap;
}

/* Codes in notes */
.note-codes {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.note-codes strong {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-light);
}
