/* AG102 Muscle Explorer — Light Theme */
:root {
    --ag-primary: #8B4513;
    --ag-accent: #B85042;
    --ag-dark: #2D1B14;
    --ag-cream: #F5F0EB;
    --ag-card: #FAF7F4;
    --ag-text: #3D2B1F;
    --ag-muted: #7A6B63;
    --ag-border: #E5E0DB;
}

/* Reset — global.css handles box-sizing but not margin/padding reset */
* { margin: 0; padding: 0; }

body {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--ag-bg, #F5F0EB);
    color: var(--ag-text, #2D1B14);
}

.muscle-explorer {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

h1 {
    text-align: center;
    color: var(--ag-primary);
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 32px;
    margin-bottom: 4px;
}

.subtitle {
    text-align: center;
    color: var(--ag-text);
    font-size: 15px;
    margin-bottom: 24px;
}

/* ============================
   CONTROLS
   ============================ */

.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    justify-content: center;
    margin-bottom: 20px;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.control-group label {
    font-weight: 600;
    color: var(--ag-muted);
    font-size: 14px;
}

.view-btn, .layer-btn, .sex-btn {
    padding: 8px 16px;
    border: 2px solid var(--ag-primary);
    background: white;
    color: var(--ag-primary);
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.view-btn:hover, .layer-btn:hover, .sex-btn:hover {
    background: #FDF8F5;
}

.view-btn.active, .sex-btn.active {
    background: var(--ag-primary);
    color: white;
}

.layer-btn.active[data-layer="superficial"] {
    background: #D94444;
    color: white;
    border-color: #D94444;
}
.layer-btn.active[data-layer="intermediate"] {
    background: #CC6633;
    color: white;
    border-color: #CC6633;
}
.layer-btn.active[data-layer="deep"] {
    background: #993333;
    color: white;
    border-color: #993333;
}

/* ============================
   LAYOUT: BODY + PANEL
   ============================ */

.explorer-layout {
    display: flex;
    gap: 24px;
    align-items: flex-start;
}

.body-column {
    flex: 0 0 auto;
    max-width: 500px;
    width: 100%;
}

.body-container {
    position: relative;
    background: white;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}

.body-container svg {
    width: 100%;
    height: auto;
    display: block;
}

.body-loading {
    text-align: center;
    padding: 100px 20px;
    color: var(--ag-muted);
    font-style: italic;
}

/* ============================
   MUSCLE NAVIGATOR DROPDOWN
   ============================ */

.muscle-navigator {
    margin-bottom: 12px;
}

.muscle-navigator select {
    width: 100%;
    padding: 10px 36px 10px 14px;
    font-size: 14px;
    font-family: inherit;
    border: 2px solid var(--ag-primary);
    border-radius: 8px;
    background: white;
    color: var(--ag-text);
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238B4513' stroke-width='2' fill='none'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

.muscle-navigator select:focus {
    outline: none;
    border-color: var(--ag-accent);
    box-shadow: 0 0 0 3px rgba(184, 80, 66, 0.15);
}

.muscle-navigator select optgroup {
    font-weight: 700;
    color: var(--ag-primary);
    font-size: 13px;
}

.muscle-navigator select option {
    font-weight: 400;
    color: var(--ag-text);
    padding: 4px 8px;
}

/* ============================
   SVG MUSCLE INTERACTION
   ============================ */

.body-container .muscle {
    cursor: pointer;
    transition: opacity 0.15s, filter 0.15s;
}

.body-container .muscle:hover {
    filter: brightness(1.3) drop-shadow(0 0 4px rgba(255,215,0,0.6));
}

.body-container .muscle.selected {
    filter: brightness(1.4) drop-shadow(0 0 8px rgba(255,140,0,0.8));
}

/* ============================
   TOOLTIP
   ============================ */

.muscle-tooltip {
    position: absolute;
    background: var(--ag-dark);
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    pointer-events: none;
    display: none;
    z-index: 10;
    white-space: nowrap;
    box-shadow: 0 3px 10px rgba(0,0,0,0.25);
}

/* ============================
   INFO PANEL
   ============================ */

.info-panel {
    flex: 1;
    min-width: 320px;
    max-width: 500px;
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    display: none;
    position: sticky;
    top: 20px;
    max-height: 85vh;
    overflow-y: auto;
}

.info-panel.visible {
    display: block;
}

.close-panel {
    position: absolute;
    top: 12px;
    right: 16px;
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: var(--ag-muted);
    line-height: 1;
    padding: 4px;
}

.close-panel:hover {
    color: var(--ag-dark);
}

/* Panel content */
.muscle-title {
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 24px;
    color: var(--ag-primary);
    margin-bottom: 4px;
    padding-right: 32px;
}

.muscle-region {
    font-size: 14px;
    color: var(--ag-muted);
    margin-bottom: 16px;
}

.info-section {
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--ag-border);
}

.info-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.info-section h3 {
    font-size: 15px;
    color: var(--ag-accent);
    margin-bottom: 8px;
    font-weight: 700;
}

.info-section p {
    font-size: 14px;
    line-height: 1.55;
    color: var(--ag-text);
}

/* ============================
   EMG TIER ACCORDION
   ============================ */

.emg-tier {
    border: 1px solid var(--ag-border);
    border-radius: 8px;
    margin-bottom: 8px;
    overflow: hidden;
}

.emg-tier-header {
    padding: 10px 14px;
    background: var(--ag-card);
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
}

.emg-tier-header::after {
    content: '\25B8';
    font-size: 12px;
    transition: transform 0.2s;
    flex-shrink: 0;
    margin-left: 8px;
}

.emg-tier.open .emg-tier-header::after {
    transform: rotate(90deg);
}

.emg-tier-body {
    display: none;
    padding: 12px 14px;
    font-size: 13px;
    line-height: 1.6;
}

.emg-tier.open .emg-tier-body {
    display: block;
}

.emg-tier-body p {
    margin-bottom: 6px;
    font-size: 13px;
}

.citation {
    font-size: 11px;
    color: var(--ag-muted);
    font-style: italic;
    margin-top: 8px;
    word-break: break-word;
}

/* ============================
   EXERCISE PHASE CARDS
   ============================ */

.phase-cards {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.phase-card {
    background: var(--ag-card);
    border-radius: 8px;
    padding: 12px;
    border-left: 4px solid var(--ag-accent);
}

.phase-card h4 {
    font-size: 13px;
    color: var(--ag-primary);
    margin-bottom: 4px;
}

.phase-card p {
    font-size: 12px;
    line-height: 1.5;
}

/* ============================
   CLINICAL WARNING
   ============================ */

.clinical-warning {
    background: #FFF8F0;
    border-left: 4px solid #E8A838;
    border-radius: 0 8px 8px 0;
    padding: 12px;
    font-size: 13px;
    line-height: 1.5;
}

/* ============================
   MUSCLE COUNT
   ============================ */

.muscle-count {
    text-align: center;
    color: var(--ag-muted);
    font-size: 13px;
    margin-top: 12px;
}

/* ============================
   SCROLLBAR STYLING
   ============================ */

.info-panel::-webkit-scrollbar {
    width: 6px;
}
.info-panel::-webkit-scrollbar-track {
    background: transparent;
}
.info-panel::-webkit-scrollbar-thumb {
    background: var(--ag-border);
    border-radius: 3px;
}

/* ============================
   RESPONSIVE
   ============================ */

@media (max-width: 900px) {
    .explorer-layout {
        flex-direction: column;
    }

    .body-container {
        max-width: 100%;
    }

    .info-panel {
        position: static;
        max-width: 100%;
        max-height: none;
    }
}

@media (max-width: 768px) {
    .muscle-explorer {
        padding: 12px;
    }

    h1 { font-size: 24px; }
    .subtitle { font-size: 13px; }

    .controls {
        gap: 10px;
    }

    .view-btn, .layer-btn, .sex-btn {
        padding: 6px 12px;
        font-size: 13px;
    }

    .info-panel {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        max-width: 100%;
        max-height: 60vh;
        border-radius: 16px 16px 0 0;
        z-index: 100;
        box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
        overflow-y: auto;
    }

    .info-panel.visible {
        display: block;
    }
}

@media (max-width: 480px) {
    .control-group {
        flex-wrap: wrap;
    }
    .control-group label {
        width: 100%;
        margin-bottom: 2px;
    }
}

/* ============================================
   EXERCISE LINKS IN INFO PANEL (Phase 6)
   ============================================ */

.exercise-role-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--ag-muted, #999);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 10px 0 4px 0;
}

.exercise-links {
    list-style: none;
    padding: 0;
    margin: 0 0 8px 0;
}

.exercise-links li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.exercise-links li:last-child {
    border-bottom: none;
}

.exercise-link {
    color: var(--ag-accent, #e8a87c);
    text-decoration: none;
    font-size: 14px;
    transition: color 0.15s;
}

.exercise-link:hover {
    color: #f0c8a0;
    text-decoration: underline;
}

.activation-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 10px;
    background: rgba(232, 85, 61, 0.2);
    color: #e8553d;
    flex-shrink: 0;
    margin-left: 8px;
}

.activation-badge.secondary {
    background: rgba(74, 144, 217, 0.2);
    color: #4a90d9;
}

.view-all-link {
    display: inline-block;
    margin-top: 10px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--ag-accent, #e8a87c);
    border: 1px solid var(--ag-accent, #e8a87c);
    border-radius: 6px;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}

.view-all-link:hover {
    background: var(--ag-accent, #e8a87c);
    color: #1a1a2e;
}
