/* assets/css/astro-music.css */

#icosmo-astro-music-container {
    max-width: 1200px;
    margin: 20px auto;
    padding: 20px;
    background-color: transparent;
    color: #e0e0e0;
    border-radius: 8px;
    font-family: Arial, sans-serif;
    box-sizing: border-box;
}

.astro-music-header {
    text-align: center;
    margin-bottom: 30px;
}

.astro-music-header h2 {
    font-size: 2.2em;
    color: #f0f0f0;
    margin-bottom: 10px;
}

.astro-music-header p {
    color: #aaa;
    font-weight: lighter;
}

/* --- MAIN UI GRID ---
   FIX: Use explicit repeat(2, 1fr) instead of auto-fit minmax().
   auto-fit reflows the entire grid when the visual module switches from
   display:none to display:block, causing the top two panels to collapse
   when a scrollbar appears and nudges the container width. With an
   explicit 2-column template the top row is always stable.
*/
.astro-music-ui-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    align-items: start;
    width: 100%;
}

/* Module Styling */
#icosmo-astro-music-container .module {
    border: 1px solid #4f4f4f;
    padding: 15px;
    border-radius: 6px;
    background-color: #191919;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.45);
    display: flex;
    flex-direction: column;
    /* Prevent either panel from collapsing below its initial size */
    min-height: 320px;
}

#astro-music-input-module {
    min-height: 340px;
}

#astro-music-player-module {
    min-height: 220px;
}

#icosmo-astro-music-container .control-group-heading {
    display: flex;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 8px;
    border-bottom: 1px solid #4f4f4f;
    font-size: 0.95em;
    font-weight: bold;
    color: #f0f0f0;
    text-transform: uppercase;
    letter-spacing: 1px;
}

#am-visual-title {
    font-size: 0.85em;
    line-height: 1.4;
    flex: 1;
}

#am-export-pdf-btn {
    transition: transform 0.1s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 10px;
}

#am-export-pdf-btn:hover  { transform: scale(1.2); }
#am-export-pdf-btn:active { transform: scale(0.9); }

/* --- COMPACT FORM STYLING --- */
.am-compact-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex-grow: 1;
}

.am-row-main,
.am-row-geo,
.am-row-city {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.am-row-geo  { margin-top: 5px; }
.am-row-city { margin-top: 5px; }

.am-input-group {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.am-input-group label {
    font-size: 0.7em;
    color: #888;
    text-transform: uppercase;
    margin-bottom: 3px;
    font-weight: bold;
}

.am-input-group input,
.am-input-group select {
    background-color: #0a0a0a;
    border: 1px solid #444;
    color: #ccc;
    padding: 8px;
    border-radius: 4px;
    font-size: 0.95em;
    width: 100%;
    box-sizing: border-box;
    height: 38px;
}

/* Safari fix */
.am-input-group input[type="date"],
.am-input-group input[type="time"] {
    -webkit-appearance: none;
    appearance: none;
    min-width: 0;
}

.date-grp { flex: 2; }
.time-grp { flex: 1.2; }
.tz-grp   { flex: 1; }

/* --- BUTTONS --- */
#am-geocode-btn {
    height: 38px;
    padding: 0 15px;
    background-color: #2a2a2a;
    color: #e0e0e0;
    border: 1px solid #444;
    border-radius: 4px;
    font-size: 0.85em;
    font-weight: normal;
    cursor: pointer;
}

#am-geocode-btn:hover {
    background-color: #3a3a3a;
    color: #fff;
    border-color: #666;
}

#am-now-btn {
    flex: 1;
    background-color: #2a2a2a;
    color: #e0e0e0;
    border: 1px solid #444;
    border-radius: 4px;
    padding: 10px 15px;
    height: 38px;
    font-size: 0.9em;
    font-weight: normal;
    cursor: pointer;
    transition: all 0.2s ease;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#am-now-btn:hover {
    background-color: #3a3a3a;
    color: #fff;
    border-color: #666;
}

#am-form-generate-btn {
    flex: 1;
    background-color: #888888;
    color: #111;
    border: none;
    border-radius: 4px;
    padding: 10px 15px;
    height: 38px;
    font-size: 0.9em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#am-form-generate-btn:hover { background-color: #e7e7e7; }

.am-bottom-buttons {
    display: flex;
    gap: 10px;
    margin-top: 8px !important;
    align-items: stretch;
    flex-shrink: 0;
}

/* --- GENERATOR & PLAYER CONTROLS --- */
.astro-music-controls {
    display: flex;
    flex-direction: column;
    gap: 15px;
    flex-grow: 1;
    justify-content: flex-start;
}

.status-text {
    font-size: 0.9em;
    color: #ccc;
    text-align: center;
    min-height: 1.4em;
    font-style: italic;
}

#am-progress-container { margin-top: 5px; margin-bottom: 0; }

.matrix-divider {
    border: 0;
    height: 1px;
    background-color: #333;
    margin: 10px 0;
}

.audio-player-ui {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.am-action-row {
    display: flex;
    gap: 10px;
    width: 100%;
    flex-shrink: 0;
}

.am-action-row button,
.am-action-row div {
    flex: 1;
}

#icosmo-astro-music-container .play-stop {
    background-color: #2a2a2a;
    color: #e0e0e0;
    border: 1px solid #444;
    border-radius: 5px;
    padding: 10px 15px;
    height: 38px;
    font-weight: normal;
    cursor: pointer;
    transition: background 0.2s;
    font-size: 0.95em;
    display: flex;
    align-items: center;
    justify-content: center;
}

#icosmo-astro-music-container .play-stop:hover:not(:disabled) {
    background-color: #3a3a3a;
    border-color: #666;
}

#icosmo-astro-music-container .button-primary {
    background-color: #888888;
    color: #111;
    border: none;
    padding: 10px 15px;
    height: 38px;
    font-weight: bold;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.95em;
    display: flex;
    align-items: center;
    justify-content: center;
}

#icosmo-astro-music-container .button-primary:hover:not(:disabled) {
    background-color: #e7e7e7;
    transform: translateY(-1px);
}

#generate-reel-btn {
    background-color: #888888;
    color: #111;
    border: none;
    padding: 10px 15px;
    height: 38px;
    font-weight: bold;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.95em;
    display: flex;
    align-items: center;
    justify-content: center;
}

#generate-reel-btn:hover { background-color: #e7e7e7; }

#icosmo-astro-music-container button:disabled {
    opacity: 0.2;
    cursor: not-allowed;
}

/* --- VISUAL ANALYSIS SECTION --- */
#astro-music-visual-module {
    /* Spans both grid columns — always full width below the two panels */
    grid-column: 1 / -1;
    margin-top: 5px;
    /* Override the default module min-height — this panel grows with content */
    min-height: 0 !important;
}

/* Summary block — lighter than before, matches Oracle's #1e1e1e */
.am-summary-text {
    background-color: #1e1e1e;
    padding: 18px;
    border-radius: 6px;
    margin-bottom: 25px;
    line-height: 1.7;
    font-size: 1.05em;
    border-left: 5px solid #8cc74b;
    color: #ccc;
}

/* Key colour pills row */
.am-keys-row {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 25px;
    flex-wrap: wrap;
}

.am-key-box {
    width: 42px;
    height: 42px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.1em;
    border: 1px solid rgba(0, 0, 0, 0.4);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Two-column grid: chart on left, details on right */
.am-visual-grid {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 30px;
    align-items: start;
}

/* Chart column — Oracle uses #1e1e1e, not #0a0a0a */
.am-chart-column {
    background-color: #1e1e1e;
    padding: 20px;
    border-radius: 10px;
    display: flex;
    justify-content: center;
    border: 1px solid #3a3a3a;
}

.am-chart-column svg {
    width: 100%;
    max-width: 450px;
    height: auto;
}

.am-details-column {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

/* -------------------------------------------------------
   LEGEND — Oracle-identical style
   Classes match oracle.css exactly so the look is unified.
------------------------------------------------------- */
.oracle-legend-row {
    display: flex;
    gap: 20px;
    margin-bottom: 10px;
}

.legend-column {
    flex: 1;
    background-color: #1e1e1e;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #3a3a3a;
}

.legend-column h5 {
    margin-top: 0;
    margin-bottom: 15px;
    border-bottom: 1px solid #4f4f4f;
    padding-bottom: 8px;
    color: #f0f0f0;
    font-size: 1em;
}

.legend-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.legend-entry {
    font-size: 0.85em;
    color: #ccc;
    display: flex;
    align-items: center;
}

/* Symbol glyph inside a legend entry or table cell */
.symbol {
    margin-right: 8px;
    font-size: 1.2em;
    line-height: 1;
    font-family: "Segoe UI Symbol", "Apple Symbols", "Arial Unicode MS", sans-serif;
}

/* -------------------------------------------------------
   HARMONICS TABLE — Oracle-identical style
   Use .oracle-table without the old .compact dark overrides.
------------------------------------------------------- */
.table-wrapper { overflow-x: auto; }

.oracle-table {
    border-collapse: collapse;
    width: 100%;
    margin-top: 0;
    background-color: #333;
    border-radius: 6px;
    overflow: hidden;
}

.oracle-table th,
.oracle-table td {
    border: 1px solid #4f4f4f;
    padding: 10px;
    text-align: left;
    font-size: 0.9em;
    color: #e0e0e0;
}

.oracle-table th {
    background-color: #4a4a4a;
    font-weight: bold;
    text-transform: uppercase;
    font-size: 0.78em;
    letter-spacing: 0.5px;
    color: #bbb;
}

.oracle-table tr:nth-child(even) { background-color: #3a3a3a; }

/* Geocode status line */
#am-geocode-status {
    font-size: 0.8em;
    color: #888;
    min-height: 1.2em;
    font-style: italic;
    margin-top: 2px;
}

/* Make purchase section more compact and inline */
#purchase-section {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 10px;
    flex-wrap: wrap;
}

#purchase-section p {
    margin: 0;
    color: #aaa;
    font-size: 0.85em;
}

#purchase-section > div {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
}

#buy-mp3-btn {
    min-width: 160px;
}

/* === AUDIO VISUALIZER STYLES === */
#am-visualizer-container {
    background: #0a0a0a;
    border-radius: 8px;
    padding: 8px;
    border: 1px solid #333;
    box-shadow: inset 0 0 20px rgba(0,0,0,0.6);
}

#am-visualizer-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #0a0a0a;
    border-radius: 8px;
    padding: 8px;
    border: 1px solid #333;
    margin-bottom: 10px;
    min-height: 215px;
}

#am-audio-visualizer {
    width: 100% !important;
    height: 100% !important;
    max-height: 220px;
    border-radius: 6px;
}

/* Make right panel balanced with left */
#astro-music-player-module {
    min-height: 375px;           /* Adjusted to better match left panel */
    display: flex;
    flex-direction: column;
}

#astro-music-player-module .am-action-row {
    margin-top: 8px;               /* reduced top gap */
}

.audio-player-ui {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.am-action-row {
    display: flex;
    gap: 10px;
    margin-top: 8px !important;
}

/* Compact & elegant */
#astro-music-visual-module {
    margin-top: 20px;
}

/* -------------------------------------------------------
   RESPONSIVE
------------------------------------------------------- */
@media (max-width: 1000px) {
    .am-visual-grid {
        grid-template-columns: 1fr;
    }
    .am-chart-column svg {
        max-width: 380px;
    }
    .oracle-legend-row {
        flex-direction: column;
    }
}

/* URGENT FIXES - HIGH SPECIFICITY */
#am-visualizer-wrapper {
    margin-bottom: 10px !important;
    min-height: 215px !important;
}

#astro-music-player-module .am-action-row {
    margin-top: 6px !important;
}

#purchase-section {
    margin-top: 8px !important;
}

#purchase-section > div {
    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
    justify-content: center !important;
    flex-wrap: wrap !important;
}

#astro-music-player-module {
    min-height: 370px !important;
}

/* Stack both main panels on smaller screens */
@media (max-width: 1050px) {
    .astro-music-ui-grid {
        grid-template-columns: 1fr !important;
    }

    #astro-music-visual-module {
        grid-column: 1;
    }

    /* Make sure both panels behave nicely when stacked */
    #astro-music-player-module,
    #astro-music-input-module {
        min-height: auto;
    }
}

@media (max-width: 700px) {
    .am-row-main,
    .am-row-geo,
    .am-row-city,
    .am-action-row,
    .am-bottom-buttons {
        flex-direction: column;
        align-items: stretch;
    }

    .am-input-group {
        width: 100%;
    }

    .am-input-group label {
        margin-top: 5px;
    }
}
