/* ==================================================
   RESET LOCAL
================================================== */

#cancioneiro,
#cancioneiro * {
    box-sizing: border-box;
}


/* ==================================================
   ESTADOS GENÉRICOS
================================================== */

.hidden {
    display: none !important;
    visibility: hidden;
}


/* ==================================================
   LAYOUT GERAL
================================================== */

#cancioneiro {
    display: flex;
    gap: 16px;
    margin: 2rem;
}

#musica {
    width: 80%;
    padding-top: 20px;
}

#song-view {
    margin-top: 15px;
}


/* ==================================================
   HEADER DA LISTA
================================================== */

#lista-header {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 1rem;
}

#lista-header h2 {
    font-size: 1.75rem;
    color: var(--azul-petroleo);
    font-weight: 600;
    margin: 0;
    line-height: 1.2;
}

.lista-toggle {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    border: 1px solid rgba(56,94,114,.2);
    background: #fff;
    cursor: pointer;
    padding: 0;
}

.lista-toggle:hover {
    background: rgba(56,94,114,.06);
    border-color: rgba(56,94,114,.4);
}

.hamburger {
    position: relative;
    width: 18px;
    height: 2px;
    background: var(--azul-petroleo);
    transition: all .3s ease;
}

.hamburger::before,
.hamburger::after {
    content: '';
    position: absolute;
    width: 18px;
    height: 2px;
    background: var(--azul-petroleo);
    left: 0;
    transition: all .3s ease;
}

.hamburger::before {
    top: -6px;
}

.hamburger::after {
    top: 6px;
}


/* ==================================================
   LISTA DE MÚSICAS
================================================== */

#lista-wrapper {
    width: 20%;
    overflow: hidden;
    border-right: 1px solid #ddd;
    transition: width 0.3s ease;
}

#lista-wrapper.closed {
    width: 0;
    border-right: none;
}

#lista-musicas {
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    color: #374151;
}

#lista-musicas ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

#lista-musicas li {
    padding: .5rem .75rem;
    border-radius: 6px;
    transition: background .2s ease;
}

#lista-musicas li:hover {
    background: rgba(56,94,114,.06);
}

#lista-musicas li.active {
    background: rgba(56,94,114,.1);
    font-weight: 600;
}

#lista-musicas a {
    color: inherit;
    text-decoration: none;
}


/* ==================================================
   PESQUISA
================================================== */

#cancioneiro-search {
    position: sticky;
    top: 0;
    background: #fff;
    z-index: 10;
    padding: 0;
    margin-top: 10px;
    margin-right: 10px;
}

.search-wrapper {
    position: relative;
}

#pesquisa-cancioneiro {
    width: 100%;
    padding: 8px 36px 8px 10px;
    font-size: 16px;
}

#clear-search {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    border: none;
    background: none;
    font-size: 20px;
    cursor: pointer;
    display: none;
}

#no-results {
    margin-top: 1rem;
    color: #6b7280;
    font-size: .95rem;
}


/* ==================================================
   BOTÃO VOLTAR À LISTA
================================================== */

#back-to-list {
    background: none;
    border: none;
    color: #0073aa;
    font-size: 14px;
    cursor: pointer;
    padding: 4px 0;
    margin-bottom: 6px;
}

#back-to-list:hover {
    text-decoration: underline;
}


/* ==================================================
   TOOLBAR / MENU DE OPÇÕES
================================================== */

#song-toolbar {
    margin-bottom: 1rem;
}

.controls-toggle {
    display: inline-flex;
    align-items: center;
    gap: .55rem;
    min-height: 42px;
    padding: .65rem .9rem;
    border-radius: 999px;
    border: 1px solid rgba(56,94,114,.16);
    background: #fff;
    color: var(--azul-petroleo);
    font-size: .95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all .2s ease;
    box-shadow: 0 4px 14px rgba(56,94,114,.04);
}

.controls-toggle:hover {
    background: rgba(56,94,114,.04);
    border-color: rgba(56,94,114,.28);
}

.controls-toggle[aria-expanded="true"] {
    background: rgba(56,94,114,.06);
}

.controls-toggle__chevron {
    font-size: .8rem;
    transition: transform .2s ease;
}

.controls-toggle[aria-expanded="true"] .controls-toggle__chevron {
    transform: rotate(180deg);
}

.controls-panel {
    margin-top: 1rem;
    padding: 1rem;
    border: 1px solid rgba(56,94,114,.10);
    border-radius: 16px;
    background: #fafbfc;
}

.controls-meta {
    width: 100%;
    margin-bottom: .75rem;
    color: #374151;
    font-size: .95rem;
}

.controls-group {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    margin-top: .5rem;
}

#transposicao {
    color: #374151;
}

#transposicao button {
    margin: 0;
    border-radius: 8px;
    padding: .45rem .75rem;
    transition: all .2s ease;
    font-size: 14px;
    cursor: pointer;
    border: 1px solid #E4E7EC;
    color: var(--azul-petroleo);
    background: #FFFFFF;
}

#transposicao button:hover {
    background: rgba(56,94,114,.08);
    border-color: rgba(56,94,114,.25);
}


/* ==================================================
   LETRA + ACORDES
================================================== */

#letra {
    font-family: monospace;
    font-size: 16px;
    line-height: 1.25;
}

.song-line {
    display: block;
}

.song-line .chords {
    white-space: pre;
    font-weight: bold;
    color: #2563EB;
    line-height: 1;
}

.song-line .lyrics {
    white-space: pre;
    line-height: 1.25;
}

.song-paragraph {
    height: 2em;
}

.refrain-block {
    background: rgba(212,176,106,.14);
    border-left: 4px solid var(--dourado-suave, #d4b06a);
    padding: 8px 10px;
    border-radius: 8px;
    margin: .3rem 0 .8rem;
}


/* ==================================================
   LIMPEZA DE ESPAÇOS
================================================== */

.song-line,
.song-line .chords,
.song-line .lyrics {
    margin: 0 !important;
    padding: 0 !important;
}


/* ==================================================
   ACORDES CLICÁVEIS
================================================== */

.clickable-chord {
    cursor: pointer;
    color: #2563EB;
    font-weight: 600;
}

.clickable-chord:hover {
    text-decoration: underline;
}


/* ==================================================
   PAINEL DE ACORDES
================================================== */

#chord-panel {
    position: fixed;
    background: #fff;
    box-shadow: 0 -4px 16px rgba(0,0,0,0.2);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
}

.chord-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    border-bottom: 1px solid #ddd;
    font-weight: bold;
    margin-top: 20px;
}

#close-chord-panel {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
}

#chord-panel-content {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

#chord-panel-content img {
    max-width: 100%;
    max-height: 100%;
    display: block;
}


/* ==================================================
   PDF
================================================== */

#pdf-buffer {
    height: 60px;
}

.pdf-export {
    padding-bottom: 60px;
    padding-top: 10px;
    display: block;
}

.pdf-export .song-line .chords {
    line-height: 1.2;
}

.pdf-export .song-line .lyrics {
    line-height: 1.25;
}

.pdf-export .song-line.refrain {
    page-break-inside: avoid;
    break-inside: avoid;
}

.pdf-export .chords {
    margin-top: 0;
}


/* ==================================================
   DESKTOP
================================================== */

@media (min-width: 769px) {
    #cancioneiro {
        display: grid;
        grid-template-columns: 320px minmax(0, 1fr);
        gap: 28px;
        margin: 2rem auto;
        max-width: 1400px;
        align-items: start;
        padding: 0 2rem;
    }

    #lista-wrapper {
        width: 100%;
        border-right: none;
        background: #fff;
        border: 1px solid rgba(56,94,114,.10);
        border-radius: 18px;
        padding: 1.25rem;
        box-shadow: 0 10px 30px rgba(56,94,114,.06);
        position: sticky;
        top: 2rem;
        max-height: calc(100vh - 4rem);
        overflow: hidden;
    }

    #lista-wrapper.closed {
        width: 100%;
    }

    #lista-header {
        margin-bottom: 1rem;
    }

    #lista-header h2 {
        font-size: 2rem;
        line-height: 1.1;
        color: var(--azul-petroleo);
        font-weight: 700;
    }

    .lista-toggle {
        display: none;
    }

    #cancioneiro-search {
        margin: 0 0 1rem;
        position: relative;
        top: auto;
        background: transparent;
        z-index: 1;
        padding: 0;
    }

    #pesquisa-cancioneiro {
        width: 100%;
        height: 46px;
        padding: 0 42px 0 14px;
        border: 1px solid rgba(56,94,114,.18);
        border-radius: 12px;
        background: #fff;
        font-size: .98rem;
        color: #374151;
        outline: none;
        transition: all .2s ease;
    }

    #pesquisa-cancioneiro:focus {
        border-color: rgba(56,94,114,.42);
        box-shadow: 0 0 0 4px rgba(56,94,114,.08);
    }

    #clear-search {
        right: 12px;
        font-size: 18px;
        color: #6b7280;
    }

    #lista-musicas {
        max-height: calc(100vh - 14rem);
        overflow-y: auto;
        padding-right: .25rem;
    }

    #lista-musicas li {
        margin-bottom: .2rem;
        padding: 0;
        border-radius: 10px;
    }

    #lista-musicas li a {
        display: block;
        padding: .8rem .9rem;
        border-radius: 10px;
        text-decoration: none;
        color: #29485b;
        font-size: 1.05rem;
        line-height: 1.35;
        transition: all .18s ease;
    }

    #lista-musicas li:hover {
        background: transparent;
    }

    #lista-musicas li:hover a {
        background: rgba(56,94,114,.06);
    }

    #lista-musicas li.active {
        background: transparent;
    }

    #lista-musicas li.active a {
        background: rgba(56,94,114,.10);
        font-weight: 700;
        color: var(--azul-petroleo);
        box-shadow: inset 4px 0 0 var(--dourado-suave, #d4b06a);
    }

    #no-results {
        margin-top: 1rem;
        padding: .85rem 1rem;
        border-radius: 10px;
        background: rgba(56,94,114,.05);
        color: #556370;
        font-size: .95rem;
    }

    #musica {
        width: 100%;
        padding-top: 0;
        min-width: 0;
    }

    #song-view {
        margin-top: 0;
        background: #fff;
        border: 1px solid rgba(56,94,114,.10);
        border-radius: 22px;
        padding: 2rem 2.2rem 2.5rem;
        box-shadow: 0 12px 32px rgba(56,94,114,.05);
    }

    #song-view h2,
    #musica h2 {
        margin: 0 0 1.2rem;
        font-size: clamp(2.4rem, 4vw, 3.4rem);
        line-height: 1.05;
        color: var(--azul-petroleo);
        font-weight: 700;
        letter-spacing: -0.02em;
    }

    #song-toolbar {
        margin-bottom: 1.2rem;
    }

    .controls-toggle {
        min-height: 46px;
        padding: .75rem 1rem;
        font-size: 1rem;
    }

    .controls-panel {
        margin-top: 1rem;
        padding: 1rem;
        border: 1px solid rgba(56,94,114,.10);
        border-radius: 16px;
        background: #fafbfc;
        display: flex;
        flex-wrap: wrap;
        gap: .6rem;
        align-items: center;
    }

    .controls-panel.hidden {
        display: none !important;
    }

    .controls-meta {
        width: 100%;
        margin-bottom: .25rem;
    }

    #tom {
        display: inline-flex;
        align-items: center;
        min-height: 34px;
        padding: .35rem .8rem;
        border-radius: 999px;
        background: rgba(56,94,114,.08);
        color: var(--azul-petroleo);
        font-weight: 600;
    }

    #tags {
        color: #6b7280;
    }

    #transposicao button {
        min-height: 40px;
        padding: .55rem .9rem;
        border-radius: 10px;
        font-size: .95rem;
        font-weight: 600;
    }

    #letra {
        margin-top: 1.5rem;
        font-family: "Courier New", Courier, monospace;
        font-size: 1.2rem;
        line-height: 1.4;
        color: #111827;
    }

    .song-line {
        margin-bottom: .2rem;
    }

    .song-line .chords {
        color: #2563EB;
        font-weight: 700;
        line-height: 1.1;
    }

    .song-line .lyrics {
        line-height: 1.35;
    }

    .song-paragraph {
        height: 1.4rem;
    }

    .refrain-block {
        background: rgba(212,176,106,.14);
        border-left: 4px solid var(--dourado-suave, #d4b06a);
        padding: .9rem 1rem;
        border-radius: 12px;
        margin: .3rem 0 .8rem;
    }

    #back-to-list {
        display: none !important;
    }

    #chord-panel {
        top: 0;
        right: 0;
        width: 260px;
        height: 100%;
        transform: translateX(100%);
        border-left: 1px solid #ddd;
    }

    #chord-panel.active {
        transform: translateX(0);
    }
}


/* ==================================================
   MOBILE
================================================== */

@media (max-width: 768px) {
    #cancioneiro {
        flex-direction: column;
        margin: 0;
        padding: 0 1rem 2rem;
        gap: 1rem;
    }

    #lista-wrapper,
    #musica {
        width: 100%;
    }

    #lista-wrapper {
        border-right: none;
        background: #fff;
        border: 1px solid rgba(56,94,114,.12);
        border-radius: 14px;
        padding: 1rem;
        box-shadow: 0 8px 24px rgba(56,94,114,.08);
    }

    #lista-wrapper.closed {
        display: none;
    }

    #lista-header {
        justify-content: space-between;
    }

    #lista-header h2 {
        font-size: 1.6rem;
    }

    #cancioneiro-search {
        margin: 1rem 0 0;
        position: relative;
        top: auto;
        padding: 0;
    }

    #pesquisa-cancioneiro {
        width: 100%;
        height: 44px;
        padding: 0 42px 0 12px;
        border: 1px solid rgba(56,94,114,.18);
        border-radius: 12px;
        font-size: 1rem;
        outline: none;
    }

    #pesquisa-cancioneiro:focus {
        border-color: rgba(56,94,114,.42);
        box-shadow: 0 0 0 4px rgba(56,94,114,.08);
    }

    #lista-musicas {
        max-height: 65vh;
        margin-top: 1rem;
    }

    #lista-musicas li {
        padding: 0;
        margin-bottom: .2rem;
    }

    #lista-musicas li a {
        display: block;
        padding: .75rem .8rem;
        border-radius: 10px;
        font-size: 1rem;
    }

    #lista-musicas li.active {
        background: transparent;
    }

    #lista-musicas li.active a {
        background: rgba(56,94,114,.10);
        font-weight: 700;
        color: var(--azul-petroleo);
        box-shadow: inset 4px 0 0 var(--dourado-suave, #d4b06a);
    }

    #musica {
        margin-top: 0;
        padding-top: 0;
    }

    #back-to-list {
        position: sticky;
        top: 0;
        z-index: 20;
        display: inline-flex;
        align-items: center;
        gap: .35rem;
        width: fit-content;
        margin: 0 0 1rem;
        padding: .6rem .85rem;
        border: 1px solid rgba(56,94,114,.18);
        border-radius: 999px;
        background: #fff;
        color: var(--azul-petroleo);
        font-size: .95rem;
        font-weight: 600;
        text-decoration: none;
        box-shadow: 0 4px 14px rgba(56,94,114,.08);
    }

    #back-to-list:hover {
        background: rgba(56,94,114,.06);
        text-decoration: none;
    }

    #back-to-list.hidden {
        display: none !important;
    }

    #song-toolbar {
        margin-bottom: 1rem;
    }

    .controls-toggle {
        width: 100%;
        justify-content: space-between;
        min-height: 46px;
        padding: .75rem 1rem;
    }

    .controls-panel {
        padding: .85rem;
        border-radius: 14px;
        background: rgba(56,94,114,.04);
        border: 1px solid rgba(56,94,114,.10);
    }

    .controls-group {
        gap: .4rem;
    }

    #transposicao button {
        min-height: 40px;
        padding: .5rem .75rem;
        font-size: .9rem;
    }

    #song-view {
        margin-top: 0;
        background: #fff;
        border: 1px solid rgba(56,94,114,.10);
        border-radius: 18px;
        padding: 1.2rem;
        box-shadow: 0 8px 24px rgba(56,94,114,.05);
    }

    #song-view h2,
    #musica h2 {
        margin: 0 0 1rem;
        font-size: 2rem;
        line-height: 1.1;
        color: var(--azul-petroleo);
        font-weight: 700;
    }

    #letra {
        font-family: "Courier New", Courier, monospace;
        font-size: .95rem;
        line-height: 1.35;
        overflow-x: auto;
    }

    .song-line .chords,
    .song-line .lyrics {
        white-space: pre;
    }

    .refrain-block {
        padding: .75rem;
        border-radius: 10px;
        overflow-x: auto;
    }

    #chord-panel {
        left: 0;
        right: 0;
        bottom: 0;
        height: 40%;
        transform: translateY(100%);
        border-top-left-radius: 12px;
        border-top-right-radius: 12px;
    }

    #chord-panel.active {
        transform: translateY(0);
    }
}

/* ==================================================
   ESTADO VAZIO DA MÚSICA
================================================== */

.song-empty-state {
    background: #fff;
    border: 1px dashed rgba(56,94,114,.24);
    border-radius: 22px;
    padding: 3rem 2rem;
    text-align: center;
    color: #556370;
    box-shadow: 0 12px 32px rgba(56,94,114,.04);
}

.song-empty-state h2 {
    margin: 0 0 .75rem;
    color: var(--azul-petroleo);
    font-size: clamp(2rem, 4vw, 3rem);
    line-height: 1.1;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.song-empty-state p {
    margin: 0;
    font-size: 1.05rem;
    line-height: 1.6;
}

@media (min-width: 769px) {
    .song-empty-state {
        min-height: 360px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
    }
}

@media (max-width: 768px) {
    .song-empty-state {
        padding: 2rem 1.25rem;
        border-radius: 18px;
    }

    .song-empty-state h2 {
        font-size: 1.8rem;
    }

    .song-empty-state p {
        font-size: .98rem;
    }
}

.song-empty-state__icon {
    width: 64px;
    height: 64px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
    border-radius: 999px;
    background: rgba(56,94,114,.08);
    color: var(--azul-petroleo);
    font-size: 2rem;
    font-weight: 700;
}