/* =============================================================================
   Epic FHIR App — Styles
   ============================================================================= */

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #ffffff;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
}

.container { width: 100%; min-height: 100%; }

.card {
    background: white;
    border-radius: 0;
    padding: 30px;
    min-height: 100%;
    box-shadow: none;
}

.btn {
    background: #667eea; color: white; border: none;
    padding: 12px 24px; border-radius: 6px; font-size: 16px;
    cursor: pointer; transition: all 0.3s;
}
.btn:hover { background: #5568d3; transform: translateY(-2px); box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4); }

/* Patient Info Grid */
.patient-info { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 15px; margin-top: 20px; }
.info-item { padding: 15px; background: #f7fafc; border-radius: 6px; border-left: 3px solid #667eea; }
.info-label { font-size: 12px; color: #718096; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 5px; }
.info-value { font-size: 16px; color: #2d3748; font-weight: 500; }

/* Observation Items */
.observation-item { padding: 15px; background: #f7fafc; border-radius: 6px; margin-bottom: 10px; border-left: 3px solid #48bb78; }
.observation-code { font-weight: 600; color: #2d3748; margin-bottom: 5px; }
.observation-value { color: #4a5568; font-size: 18px; font-weight: 500; }
.observation-date { color: #718096; font-size: 12px; margin-top: 5px; }

/* Section Titles */
.section-title { font-size: 20px; color: #2d3748; margin: 25px 0 15px 0; padding-bottom: 10px; border-bottom: 2px solid #e2e8f0; }
.hidden { display: none !important; }

/* Loading Spinner */
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

#loading-section {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    min-height: 400px; padding: 40px; text-align: center;
}
.spinner {
    width: 40px; height: 40px;
    border: 4px solid #e2e8f0; border-top: 4px solid #3182ce;
    border-radius: 50%; animation: spin 1s linear infinite; margin-bottom: 20px;
}

/* Error Section */
#error-section {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    min-height: 400px; padding: 40px; text-align: center;
    background: #fff5f5; border: 1px solid #fed7d7; border-radius: 8px; margin: 20px 0;
}
#error-section h2 { font-size: 24px; color: #2d3748; margin-bottom: 15px; }
#error-section p { font-size: 16px; color: #4a5568; max-width: 500px; line-height: 1.5; }
#error-section ul { text-align: left; margin-top: 15px; }
#error-section li { margin: 8px 0; color: #4a5568; }

/* Autoantibody Grid */
.autoantibody-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, 160px);
    gap: 10px;
    margin-bottom: 20px;
    justify-content: center;
}

@media (min-width: 601px) and (max-width: 950px) {
    .autoantibody-grid {
        display: flex;
        flex-wrap: wrap;
        max-width: 500px; /* 3×160px + 2×10px gaps */
        justify-content: center;
        margin-left: auto;
        margin-right: auto;
    }
    .autoantibody-grid > div {
        flex: 0 0 160px;
    }
}

@media (max-width: 600px) {
    .autoantibody-grid {
        display: flex;
        flex-wrap: wrap;
        max-width: 330px; /* 2×160px + 1×10px gap */
        justify-content: center;
        margin-left: auto;
        margin-right: auto;
    }
    .autoantibody-grid > div {
        flex: 0 0 160px;
    }
}

/* Error Section (index.html) — moved out of inline style="..." to satisfy CSP style-src 'self' */
.error-icon {
    width: 60px; height: 60px; background: #e53e3e; border-radius: 50%;
    display: flex; align-items: center; justify-content: center; margin-bottom: 20px;
}
.error-icon-mark { color: white; font-size: 24px; font-weight: bold; }
.error-help { margin-top: 25px; color: #718096; font-size: 14px; }

/* Loading & fallback (data.js) */
.dp-loading-card {
    display: flex; justify-content: center; align-items: center; min-height: 380px;
}
.dp-fallback-message { color: #718096; }

.dp-error-banner {
    border: 2px solid #fc8181; border-radius: 8px; background: #fff5f5;
    padding: 24px; text-align: center;
}
.dp-error-banner-title { font-size: 16px; font-weight: 700; color: #9b2c2c; margin-bottom: 6px; }
.dp-error-banner-desc { font-size: 14px; color: #742a2a; }

.dp-dashboard { border: 2px solid #3d5a80; border-radius: 8px; overflow: hidden; }
.dp-dashboard-header {
    background: #3d5a80; color: white;
    display: flex; align-items: center; justify-content: center;
    padding: 16px 20px; font-size: 15px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 1px;
}
.dp-dashboard-body { background: #fff; padding: 20px; }
.dp-section-title {
    font-size: 16px; font-weight: 600; color: #2d3748;
    margin-bottom: 10px; text-align: center;
}

.dp-value-scroller {
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    display: flex; justify-content: center;
}
/* grid-auto-flow + grid-auto-columns lets JS keep adding 160px columns
   without setting grid-template-columns inline. */
.dp-value-grid {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 160px;
    gap: 10px;
}
.dp-value-column { display: flex; flex-direction: column; align-items: stretch; gap: 6px; }
.dp-value-column-title { font-size: 16px; font-weight: 600; color: #2d3748; text-align: center; }

.dp-marker-card {
    background: #fff; border: 2px solid #cbd5e0; border-radius: 8px;
    padding: 14px 12px; text-align: center;
    width: 160px; min-width: 160px; max-width: 160px; min-height: 100px;
    position: relative;
    display: flex; flex-direction: column; justify-content: center; align-items: center;
}
.dp-marker-tooltip {
    position: absolute; top: 5px; right: 7px;
    width: 16px; height: 16px; border-radius: 50%;
    border: 1.5px solid #a0aec0; color: #a0aec0;
    font-size: 11px; font-weight: 700; line-height: 15px;
    text-align: center; cursor: help; font-family: serif;
}
.dp-marker-card-title { font-size: 14px; font-weight: 700; color: #2d3748; margin-bottom: 6px; }
.dp-marker-card--value .dp-marker-card-title { font-size: 16px; }

.dp-marker-card-interpretation {
    font-size: 13px; font-weight: 600; color: #718096;
    text-transform: uppercase; margin-bottom: 4px;
}
.dp-marker-card-value { font-size: 16px; font-weight: 700; color: #718096; }
.dp-marker-card-value--muted {
    font-size: 13px; font-weight: 600; color: #718096; text-transform: uppercase;
}
.dp-marker-card-date { font-size: 11px; color: #718096; margin-top: 3px; }
.dp-marker-card--value .dp-marker-card-date { font-size: 12px; }
