/* ============================================
   TRACK TAG MANAGER
   Built on AG Insights Design System v2.0
   ============================================ */

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

/* ============================================
   BODY & BASE STYLES
   ============================================ */
html {
    background: linear-gradient(135deg, #000000 0%, #1a1445 50%, #211951 100%);
    min-height: 100%;
}

body {
    font-family: 'Sora', sans-serif;
    color: #1C2833;
    line-height: 1.65;
    font-size: 0.95rem;
    padding-bottom: 60px;
    min-height: 100%;
}

/* ============================================
   HEADER / APP TITLE
   Deliberate deviation from AG Insights "Instrument Serif only" rule —
   see MEMORY.md. Audiowide + split colour is the V1.0 identity.
   ============================================ */
.app-title {
    font-family: 'Audiowide', sans-serif;
    text-align: center;
    font-size: 3rem;
    font-weight: 400;
    line-height: 1;
    margin: 40px 0 6px 0;
    letter-spacing: 0;
}

.app-title__track { color: #FFFFFF; }
.app-title__iq    { color: #28B463; }

.app-subtitle {
    font-family: 'Sora', sans-serif;
    text-align: center;
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.65);
    font-style: italic;
    letter-spacing: 0.02em;
    margin: 0 0 30px 0;
}

@media (max-width: 768px) {
    .app-title    { font-size: 2.2rem; margin-top: 30px; }
    .app-subtitle { font-size: 0.85rem; margin-bottom: 20px; }
}

@media (max-width: 480px) {
    .app-title    { font-size: 1.8rem; }
}

/* ============================================
   CONTAINER
   ============================================ */
.container {
    max-width: 1700px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ============================================
   WHITE SECTIONS
   ============================================ */
.section {
    background: #ffffff;
    border-radius: 8px;
    padding: 32px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    margin-bottom: 24px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

.section-title {
    font-family: 'Instrument Serif', serif;
    font-size: 1.4rem;
    font-weight: 400;
    color: #1C2833;
    margin-bottom: 8px;
    text-align: left;
    letter-spacing: -0.01em;
}

.section-lede {
    color: #5D6D7E;
    font-size: 0.95rem;
    margin-bottom: 24px;
}

/* Compact padding for the player bar */
.section--player {
    padding: 16px 24px;
}

.section--editor {
    padding: 24px;
}

/* ============================================
   UPLOAD DROP ZONE
   ============================================ */
.upload-box {
    display: block;
    border: 2px dashed #D0D5DB;
    border-radius: 8px;
    background: #F9FAFB;
    padding: 48px 32px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.upload-box:hover,
.upload-box.is-drag-over {
    border-color: #4A90E2;
    background: #F4F6F8;
}

.upload-box__icon {
    font-size: 2rem;
    color: #4A90E2;
    line-height: 1;
    margin-bottom: 8px;
}

.upload-box__title {
    font-weight: 600;
    font-size: 1.05rem;
    color: #1C2833;
}

.upload-box__hint {
    font-size: 0.9rem;
    color: #85929E;
    margin-top: 4px;
}

/* ============================================
   PLAYER
   ============================================ */
.player {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.player__track-name {
    font-weight: 600;
    color: #1C2833;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.player__controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.player__btn {
    font-family: 'Sora', sans-serif;
    background: #F4F6F8;
    color: #1C2833;
    border: 1px solid #DDE2E6;
    border-radius: 6px;
    width: 40px;
    height: 40px;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.player__btn:hover { background: #E8ECEF; }
.player__btn--play { background: #4A90E2; color: #fff; border-color: #4A90E2; }
.player__btn--play:hover { background: #357ABD; border-color: #357ABD; }

.player__time,
.player__duration {
    font-family: 'Sora', sans-serif;
    font-variant-numeric: tabular-nums;
    font-size: 0.875rem;
    color: #5D6D7E;
    min-width: 3.5ch;
    text-align: center;
}

.player__waveform-wrap {
    flex: 1;
    min-width: 0;
    height: 60px;
    background: #F9FAFB;
    border: 1px solid #E8ECEF;
    border-radius: 6px;
    overflow: hidden;
    position: relative;
    cursor: pointer;
}

.player__waveform {
    display: block;
    width: 100%;
    height: 100%;
}

.player__volume-label {
    display: flex;
    align-items: center;
    gap: 6px;
}

.player__volume-icon {
    font-size: 1rem;
    color: #5D6D7E;
}

.player__volume {
    -webkit-appearance: none;
    appearance: none;
    width: 100px;
    height: 4px;
    background: #DDE2E6;
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}

.player__volume::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    background: #4A90E2;
    border-radius: 50%;
    cursor: pointer;
}

.player__volume::-moz-range-thumb {
    width: 14px;
    height: 14px;
    background: #4A90E2;
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

/* ============================================
   EDITOR LAYOUT
   ============================================ */
.editor {
    display: grid;
    grid-template-columns: 290px 1fr;
    gap: 20px;
    align-items: start;
}

/* ============================================
   TRACK LIST (left column)
   ============================================ */
.track-list-wrap {
    background: #F4F6F8;
    border: 1px solid #DDE2E6;
    border-radius: 6px;
    overflow: hidden;
    max-height: 640px;
    display: flex;
    flex-direction: column;
}

.track-list-header {
    padding: 12px 14px;
    border-bottom: 1px solid #DDE2E6;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    background: #FFFFFF;
    flex-wrap: wrap;
}

.track-list-actions {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
}

.track-list-actions .btn-primary[disabled] {
    background: #DDE2E6;
    color: #85929E;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

.track-list-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: #5D6D7E;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.track-list-count {
    color: #85929E;
    font-weight: 500;
    margin-left: 4px;
}

.track-list {
    list-style: none;
    overflow-y: auto;
    flex: 1;
    padding: 6px 0;
}

.track-list__item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    font-size: 0.875rem;
    color: #1C2833;
    cursor: pointer;
    border-left: 3px solid transparent;
    transition: background 0.1s ease;
    word-break: break-word;
}

.track-list__item:hover { background: #E8ECEF; }

.track-list__item.is-selected {
    background: #FFFFFF;
    border-left-color: #4A90E2;
    font-weight: 500;
}

.track-list__dot {
    color: #F39C12;
    font-size: 0.875rem;
    line-height: 1;
    width: 10px;
    flex-shrink: 0;
    text-align: center;
}

.track-list__dot.is-tagged { color: transparent; }

.track-list__name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.track-list__empty {
    padding: 24px 14px;
    text-align: center;
    color: #85929E;
    font-size: 0.875rem;
}

/* ============================================
   TAG EDITOR (right column)
   ============================================ */
.tag-editor {
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-width: 0;
}

.tag-editor__body {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.tag-editor__preset {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: #F4F6F8;
    border: 1px solid #DDE2E6;
    border-radius: 6px;
    margin-bottom: 8px;
}

.tag-editor__preset-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: #5D6D7E;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin: 0;
    flex-shrink: 0;
}

.tag-editor__preset-select {
    flex: 1;
    min-width: 0;
    padding: 6px 28px 6px 10px;
    font-size: 0.875rem;
    font-weight: 500;
    color: #1C2833;
    background: #FFFFFF;
    border: 1px solid #DDE2E6;
    border-radius: 4px;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%235D6D7E' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
}

.tag-editor__preset-select:focus {
    outline: none;
    border-color: #4A90E2;
    box-shadow: 0 0 0 3px rgba(74,144,226,0.12);
}

.tag-editor__note {
    font-size: 0.8rem;
    font-style: italic;
    color: #85929E;
    margin: 0 2px 4px;
    line-height: 1.4;
}

.tag-editor__autofill {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
}

.tag-editor__autofill:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.tag-editor__autofill-icon {
    font-size: 1rem;
    line-height: 1;
}

/* AI-suggested state: amber outline + subtle glow. Distinct from the blue
   "active" fill — a tag can be both (AI picked it AND it's currently active). */
.tag-btn.is-ai-suggested {
    box-shadow: 0 0 0 2px #F39C12, 0 0 8px rgba(243, 156, 18, 0.35);
}

.tag-btn.is-active.is-ai-suggested {
    box-shadow: 0 0 0 2px #F39C12, 0 0 10px rgba(243, 156, 18, 0.45);
}

/* Don't let the hover dark-blue transition override the amber ring */
.tag-btn.is-ai-suggested:hover {
    box-shadow: 0 0 0 2px #F39C12, 0 0 10px rgba(243, 156, 18, 0.5);
}

.tag-group__label {
    font-size: 0.75rem;
    font-weight: 600;
    color: #5D6D7E;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-bottom: 8px;
}

.tag-group__buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

/* Tag button — base (for Style/Mood/Vibe/Crowd/Vocals/Instruments) */
.tag-btn {
    font-family: 'Sora', sans-serif;
    background: #F4F6F8;
    color: #1C2833;
    border: 1px solid #DDE2E6;
    border-radius: 6px;
    padding: 7px 12px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.12s ease;
    white-space: nowrap;
}

.tag-btn:hover {
    background: #E8ECEF;
    border-color: #D0D5DB;
}

.tag-btn.is-active {
    background: #4A90E2;
    color: #FFFFFF;
    border-color: #4A90E2;
}

.tag-btn.is-active:hover {
    background: #357ABD;
    border-color: #357ABD;
}

/* Energy variant — coloured when active, each level has its own colour */
.tag-btn--energy {
    padding: 8px 16px;
    font-weight: 600;
}

.tag-btn--energy[data-level="start"].is-active   { background: #28B463; border-color: #28B463; }
.tag-btn--energy[data-level="build"].is-active   { background: #4A90E2; border-color: #4A90E2; }
.tag-btn--energy[data-level="peak"].is-active    { background: #E74C3C; border-color: #E74C3C; }
.tag-btn--energy[data-level="sustain"].is-active { background: #8E44AD; border-color: #8E44AD; }
.tag-btn--energy[data-level="release"].is-active { background: #F39C12; border-color: #F39C12; }

.tag-btn--energy.is-active { color: #FFFFFF; }

/* Rating variant */
.tag-btn--rating {
    padding: 8px 14px;
}

/* ============================================
   ACTIONS BAR (save / prev / next / save+next)
   ============================================ */
.tag-editor__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    padding-top: 16px;
    border-top: 1px solid #E8ECEF;
}

.save-status {
    margin-left: auto;
    font-size: 0.875rem;
    font-style: italic;
    color: #85929E;
    min-height: 1.5em;
}

.save-status.is-dirty  { color: #F39C12; font-style: normal; }
.save-status.is-saved  { color: #28B463; font-style: normal; }
.save-status.is-error  { color: #E74C3C; font-style: normal; }

/* kbd keycap style */
kbd {
    display: inline-block;
    padding: 1px 5px;
    margin-left: 4px;
    font-family: 'Sora', sans-serif;
    font-size: 0.7rem;
    font-weight: 600;
    color: rgba(255,255,255,0.85);
    background: rgba(0,0,0,0.18);
    border-radius: 3px;
    vertical-align: baseline;
}

.btn-secondary kbd {
    color: #5D6D7E;
    background: #DDE2E6;
}

/* ============================================
   BUTTONS (AG Insights design system)
   ============================================ */
.btn {
    font-family: 'Sora', sans-serif;
    display: inline-block;
    padding: 10px 22px;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    text-align: center;
}

.btn-primary {
    background: #4A90E2;
    color: white;
}

.btn-primary:hover {
    background: #357ABD;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(74,144,226,0.3);
}

.btn-primary:active { transform: translateY(0); }

.btn-secondary {
    background: #F4F6F8;
    color: #1C2833;
    border: 1px solid #DDE2E6;
}

.btn-secondary:hover {
    background: #E8ECEF;
    border-color: #D0D5DB;
    transform: translateY(-1px);
}

.btn-tertiary {
    background: transparent;
    color: #4A90E2;
    border: none;
    padding: 6px 12px;
    font-weight: 500;
    font-size: 0.875rem;
    cursor: pointer;
}

.btn-tertiary:hover { background: rgba(74,144,226,0.1); }

.btn-sm { padding: 6px 14px; font-size: 0.8rem; }

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ============================================
   FOOTER
   ============================================ */
.footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #000000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    box-shadow: 0 -3px 15px rgba(0,0,0,0.3);
    z-index: 1000;
}

.footer-version {
    position: absolute;
    right: 20px;
    font-size: 0.7rem;
    color: #6B7280;
}

.footer-source {
    position: absolute;
    left: 20px;
    font-size: 0.7rem;
    color: #6B7280;
    text-decoration: none;
    transition: color 0.15s ease;
}

.footer-source:hover {
    color: #9CA3AF;
    text-decoration: underline;
}

.footer-logo {
    max-height: 28px;
    width: auto;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 1024px) {
    .container {
        max-width: 100%;
        padding: 0 16px;
    }

    .editor {
        grid-template-columns: 240px 1fr;
    }
}

@media (max-width: 768px) {
    .section {
        padding: 20px;
    }

    .section--editor {
        padding: 16px;
    }

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

    .track-list-wrap {
        max-height: 280px;
    }

    .player__controls {
        flex-wrap: wrap;
    }

    .player__waveform-wrap {
        width: 100%;
        flex-basis: 100%;
        order: 10;
    }

    .player__volume-label {
        margin-left: auto;
    }

    .footer { padding: 8px 15px; }
    .footer-logo { max-height: 24px; }
    .footer-version { font-size: 0.6rem; right: 15px; }
    .footer-source  { display: none; }   /* attribution hidden on mobile to keep footer clean */
}

@media (max-width: 480px) {
    .container { padding: 0 12px; }
    .section { padding: 16px; margin-bottom: 16px; }
    .tag-editor__actions .btn { flex: 1 1 45%; }
    .save-status { flex-basis: 100%; margin-left: 0; text-align: center; }
}
