@import url('https://fonts.googleapis.com/css2?family=Droid+Sans+Mono&display=swap');

/**
 * Estilos do Cancioneiro Verbum Dei Lisboa
 */

:root {
    --vd-primary: #1e5631;
    /* Verde Verbum Dei */
    --vd-primary-hover: #164225;
    --vd-accent: #0056b3;
    /* Azul harmónico para nota base */
    --vd-chord-ext: #b3261e;
    /* Vermelho sóbrio para extensões */
    --vd-chord-bass: #5f6368;
    /* Cinzento para nota de baixo */
    --vd-bg-light: #f8f9fa;
    --vd-border: #e0e0e0;
    --vd-text: #212529;
}

#cancioneiro-app {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--vd-text);
    line-height: 1.5;
    max-width: 100%;
}

/* Barra de Pesquisa e Filtros */
.vd-cancioneiro-header {
    background: #fff;
    border: 1px solid var(--vd-border);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    scroll-margin-top: 10px;
}

.vd-search-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.vd-search-input {
    flex: 1;
    padding: 10px 14px;
    font-size: 16px;
    border: 1px solid var(--vd-border);
    border-radius: 6px;
    outline: none;
    direction: ltr !important;
    text-align: left !important;
    unicode-bidi: normal !important;
    transition: border-color 0.2s;
}

.vd-search-input:focus {
    border-color: var(--vd-primary);
}

/* Abas de Coleções */
.vd-tabs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.vd-tab-btn {
    padding: 8px 12px;
    border: 1px solid var(--vd-border);
    background: #fff;
    color: var(--vd-text);
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.vd-tab-btn:hover {
    background: var(--vd-bg-light);
}

.vd-tab-btn.active {
    background: var(--vd-primary);
    color: #fff;
    border-color: var(--vd-primary);
}

/* Barra do Alfabeto A-Z */
.vd-alpha-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    padding: 8px 0 4px 0;
    border-top: 1px solid var(--vd-border);
    transition: opacity 0.2s ease;
}

.vd-alpha-bar.is-searching {
    opacity: 0.7;
}

.vd-alpha-btn {
    min-width: 28px;
    height: 28px;
    padding: 2px 6px;
    background: transparent;
    border: none;
    border-bottom: 2.5px solid transparent;
    border-radius: 4px 4px 0 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--vd-primary);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
    text-decoration: none;
}

.vd-alpha-btn:hover:not(.disabled) {
    background: rgba(30, 86, 49, 0.08);
    color: var(--vd-primary-hover);
}

.vd-alpha-btn.active {
    color: var(--vd-primary);
    font-weight: 700;
    border-bottom-color: var(--vd-primary);
    background: rgba(30, 86, 49, 0.1);
}

.vd-alpha-btn.disabled {
    color: #ccc;
    cursor: default;
    pointer-events: none;
    border-bottom-color: transparent;
}

/* Listagem de Cânticos (Índice) */
.vd-songs-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 10px;
    margin-bottom: 30px;
    contain: layout style;
}

.vd-song-item {
    background: #fff;
    border: 1px solid var(--vd-border);
    border-radius: 6px;
    padding: 12px 12px 12px 14px;
    text-decoration: none !important;
    color: inherit;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

/* Adia o cálculo de layout/paint dos cartões fora do ecrã inicial (abaixo da dobra) */
.vd-song-item:nth-child(n+25) {
    content-visibility: auto;
    contain-intrinsic-size: auto 46px;
}

@supports not (content-visibility: auto) {
    .vd-song-item:nth-child(n+25) {
        contain: layout style paint;
    }
}

/* Realce suave do cântico ao voltar ao índice */
@keyframes vd-pulse-item {
    0% {
        background-color: #d8edea;
        border-color: var(--vd-primary);
        box-shadow: 0 0 0 3px rgba(19, 140, 133, 0.3);
    }

    100% {
        background-color: #fff;
        border-color: var(--vd-border);
        box-shadow: none;
    }
}

.vd-song-item.vd-item-highlight {
    animation: vd-pulse-item 2s ease-out;
}

.vd-song-item:hover {
    border-color: var(--vd-primary);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    transform: translateY(-1px);
}

.vd-song-title {
    font-weight: 500;
    font-size: 14px;
    color: #111;
    flex: 1;
    min-width: 0;
    padding-right: 12px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    line-height: 1.4;
}

.vd-song-meta-line {
    font-size: 14px;
    color: #666;
    margin-bottom: 14px;
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    align-items: center;
}

.vd-vd-icon {
    width: 14px;
    height: 14px;
    object-fit: contain;
    opacity: 0.5;
    flex-shrink: 0;
    vertical-align: middle;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.vd-song-item:hover .vd-vd-icon {
    opacity: 0.9;
}

.vd-song-num-badge {
    opacity: 0.75;
    transition: opacity 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11.5px;
    font-weight: 600;
    padding: 2px 7px;
    background: var(--vd-bg-light);
    color: #555;
    border: 1px solid var(--vd-border);
    border-radius: 4px;
    white-space: nowrap;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, monospace;
    margin-left: auto;
    flex-shrink: 0;
}

.vd-song-item:hover .vd-song-num-badge {
    opacity: 1;
}

.vd-song-meta-badge {
    font-size: 11px;
    padding: 2px 6px;
    background: var(--vd-bg-light);
    color: #666;
    border-radius: 4px;
    margin-left: 8px;
    white-space: nowrap;
}

/* Vista Individual do Cântico */
.vd-song-view {
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 0;
    box-shadow: none;
}

.vd-song-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    color: var(--vd-primary);
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 16px;
    font-size: 14px;
    padding: 0;
}

.vd-song-title-header {
    margin-top: 0;
    margin-bottom: 12px;
    border-bottom: none;
    padding-bottom: 0;
}

.vd-song-subinfo {
    font-size: 13px;
    color: #666;
    margin-bottom: 20px;
}

/* Barra de Ferramentas / Controlos do Cântico (Discreta, estilo original) */
.vd-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 16px;
    background: transparent;
    border: none;
    padding: 0;
    margin-bottom: 24px;
    align-items: center;
    justify-content: space-between;
}

.vd-tool-chords {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.vd-tool-optional {
    display: inline-flex;
    align-items: center;
}

.vd-transposer {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.vd-btn {
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 5px 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
    user-select: none;
    color: #333;
}

.vd-btn:hover {
    background: #f1f3f4;
    border-color: #999;
}

.vd-btn-primary {
    background: var(--vd-primary);
    color: #fff;
    border-color: var(--vd-primary);
}

.vd-btn-primary:hover {
    background: var(--vd-primary-hover);
}

.vd-key-badge {
    padding: 5px 10px;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-family: 'Droid Sans Mono', Menlo, Monaco, Consolas, "Courier New", Courier, monospace !important;
    font-size: 13px;
    font-weight: bold;
    color: var(--vd-accent);
    cursor: pointer;
    user-select: none;
}

.vd-key-badge.changed {
    color: var(--vd-primary);
}

.vd-btn-reset {
    width: 31px;
    height: 31px;
    padding: 0 !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: bold;
    color: var(--vd-primary);
    border-radius: 4px;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    user-select: none;
}

.vd-btn-reset.is-hidden {
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
}

.vd-btn-reset.is-visible {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
}

.vd-btn-reset:hover {
    background: #eef5f0;
    border-color: var(--vd-primary);
}

/* Barra de Cópia (Discreta, no final da letra da música) */
.vd-copy-toolbar {
    margin-top: 18px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
    align-items: center;
}

/* Área de Cifra e Letra Monoespaçada */
.vd-chord-sheet {
    font-family: 'Droid Sans Mono', Menlo, Monaco, Consolas, "Courier New", Courier, monospace !important;
    font-size: 14px;
    line-height: 1.4;
    background: transparent;
    border: none;
    padding: 0;
    margin: 0;
    overflow-x: auto;
}

/* Estrofes estruturadas (Zero espaço vazio quando letra opcional está oculta) */
.vd-stanza {
    margin-bottom: 0;
}

.vd-stanza-gap {
    line-height: 1.4;
    user-select: text;
    -webkit-user-select: text;
}

.vd-stanza:last-child .vd-stanza-gap {
    display: none !important;
}

.vd-stanza.vd-chorus {
    font-weight: 700 !important;
    color: #000000 !important;
}

.vd-stanza.vd-optional {
    color: #888888 !important;
}

.vd-stanza.vd-optional.vd-chorus {
    font-weight: 700 !important;
    color: #555555 !important;
}

.vd-optional-inline {
    color: #888888 !important;
    font-style: italic;
}

.hide-optional .vd-stanza.vd-optional,
.hide-optional .optional-line,
.hide-optional .vd-optional-inline {
    display: none !important;
    user-select: none !important;
    -webkit-user-select: none !important;
}

.chord-line {
    line-height: 1.35;
    color: var(--vd-accent);
    white-space: pre !important;
}

.lyric-line {
    line-height: 1.35;
    white-space: pre !important;
}

/* Quando os acordes estão ocultos, a letra quebra fluidamente sem scroll horizontal */
.hide-chords .lyric-line {
    white-space: pre-wrap !important;
}

/* Letra Opcional Inline */
.optional-line {
    color: #888 !important;
}

/* Cores e Destaques dos Acordes na Grelha Monospace */
.chord-token {
    display: inline;
}

.chord-token .c-root {
    font-weight: bold;
    color: var(--vd-accent);
}

.chord-token .c-mod {
    font-weight: 600;
    color: var(--vd-chord-ext);
}

.chord-token .c-bass {
    font-weight: 500;
    color: var(--vd-chord-bass);
}

/* Quando os acordes estão ocultos ("Esconder Acordes") */
.hide-chords .chord-line,
.hide-chords #vd-transposer-controls,
.hide-chords #vd-copy-chords {
    display: none !important;
    user-select: none !important;
    -webkit-user-select: none !important;
}

/* Estilos de Refrão e Estrofe Opcional */
.chorus,
.vd-chorus {
    font-weight: 700 !important;
    color: #000000 !important;
}

.lyric-line.chorus,
.lyric-line.vd-chorus,
.lyric-line.vd-chorus-tag {
    font-weight: 700 !important;
    color: #000000 !important;
}

.lyric-line.vd-chorus-tag {
    letter-spacing: 0.5px;
}

.chord-line.chorus,
.chord-line.vd-chorus {
    font-weight: 700 !important;
    color: #000000 !important;
}

.song_optional {
    color: #777;
}

/* Áudio Leve (YouTube / Leitor) */
.vd-audio-player {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
    margin-bottom: 6px;
}

/* Notificação Toast "Copiado com sucesso" */
.vd-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: #323232;
    color: #fff;
    padding: 10px 18px;
    border-radius: 4px;
    font-size: 13px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.25s ease;
    z-index: 99999;
    pointer-events: none;
}

.vd-toast.show {
    opacity: 1;
    transform: translateY(0);
}

@media (max-width: 767px) {
    .vd-chord-sheet {
        font-size: 12px;
    }

    .vd-song-view {
        padding: 0;
    }

    .vd-song-title-header {
        font-size: 24px !important;
        margin-top: 5px !important;
        margin-bottom: 4px !important;
    }

    .vd-song-meta-line {
        margin-bottom: 8px !important;
        font-size: 13px !important;
    }

    .vd-toolbar {
        margin-bottom: 12px !important;
        gap: 6px !important;
    }

    .vd-tool-chords {
        display: flex;
        align-items: center;
        flex-wrap: wrap;
        gap: 6px;
    }
}