/* =============================================================================
   modals.css — shared generic modal primitives (.app-modal*)

   Mode-agnostic building blocks for fixed, centered dialogs used across every
   page of the app. Do NOT add mode-specific styles here. Pages that need a
   modal should include this stylesheet and compose these classes with their
   own variant classes (e.g. .ehr-cn-add-modal, .ehr-ms-modal).

   Classes:
     .app-modal-overlay    – full-screen backdrop + flex center
     .app-modal            – the modal container
     .app-modal-header     – header bar (title + close button)
     .app-modal-close      – small X button in the header
     .app-modal-body       – scrolling body
     .app-modal-hint       – optional helper text paragraph
     .app-modal-footer     – footer bar (actions)
     .app-json-textarea    – monospace JSON textarea for import/edit dialogs
     .app-import-error     – red error callout (used in import/edit dialogs)
     .app-btn-secondary    – generic secondary button

   Toggling visibility:
     - Set display:flex on .app-modal-overlay (or add .open) to show.
     - Hide by setting display:none (or removing .open).
   ============================================================================= */

.app-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 1200;
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
}

.app-modal-overlay.open {
    display: flex;
    opacity: 1;
    pointer-events: all;
}

.app-modal {
    background: #fff;
    border-radius: 12px;
    width: min(680px, calc(100vw - 2rem));
    max-height: calc(100vh - 4rem);
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 40px rgba(0,0,0,0.18);
    transform: translateY(12px);
    transition: transform 0.2s;
}

.app-modal-overlay.open .app-modal {
    transform: translateY(0);
}

.app-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.1rem 1.4rem 0.8rem;
    border-bottom: 1px solid #e8eaed;
    flex-shrink: 0;
}

.app-modal-header h2 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary, #202124);
}

.app-modal-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem;
    color: var(--text-secondary, #5f6368);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}

.app-modal-close:hover {
    background: #f1f3f4;
}

.app-modal-body {
    padding: 1rem 1.4rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    overflow-y: auto;
    flex: 1;
}

.app-modal-hint {
    margin: 0;
    font-size: 0.85rem;
    color: var(--text-secondary, #5f6368);
}

.app-json-textarea {
    width: 100%;
    min-height: 280px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.8rem;
    line-height: 1.5;
    padding: 0.75rem;
    border: 1px solid #dadce0;
    border-radius: 6px;
    resize: vertical;
    background: #f8f9fa;
    color: var(--text-primary, #202124);
    box-sizing: border-box;
    transition: border-color 0.15s;
    outline: none;
}

.app-json-textarea:focus {
    border-color: var(--primary-color, #0056b3);
    background: #fff;
}

.app-import-error {
    margin: 0;
    font-size: 0.82rem;
    color: #c0392b;
    background: #fdf3f2;
    padding: 0.5rem 0.75rem;
    border-radius: 5px;
    border-left: 3px solid #e74c3c;
}

.app-modal-footer {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.75rem;
    padding: 0.9rem 1.4rem 1.1rem;
    border-top: 1px solid #e8eaed;
    flex-shrink: 0;
}

.app-modal-footer .modal-footer-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.app-btn-secondary {
    padding: 0.3rem 0.9rem;
    font-size: 0.85rem;
    font-weight: 500;
    border: 1px solid #dadce0;
    border-radius: 6px;
    background: #fff;
    color: var(--text-primary, #202124);
    cursor: pointer;
    transition: background 0.15s;
}

.app-btn-secondary:hover {
    background: #f1f3f4;
}
