:root {
    --bg-body: #0f1014;
    --bg-sidebar: #16181d;
    --bg-card: #1e2128;
    --bg-card-hover: #252932;
    --primary: #1861e8;
    --primary-hover: #2e73f4;
    --danger: #ef4444;
    --text-main: #ffffff;
    --text-muted: #9ca3af;
    --border: #2e323b;
    --radius: 16px;
    --font-main: 'Poppins', sans-serif;
    --font-mono: 'Roboto Mono', monospace;
    --tag-team-bg: rgba(16, 185, 129, 0.15);
    --tag-team-color: #34d399;
    --tag-team-border: rgba(16, 185, 129, 0.2);
    --cal-escala: #6366f1;
    --cal-ensaio: #f59e0b;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-body);
    color: var(--text-main);
    font-family: var(--font-main);
    height: 100vh;
    overflow: hidden;
}

.hidden {
    display: none !important;
}

/* LOGIN */
.login-container {
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: #000000;
    background-image: radial-gradient(circle at center, #16181d 0%, #000000 100%);
}

.login-box {
    background-color: var(--bg-card);
    padding: 40px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    width: 90%;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.login-logo {
    max-height: 80px;
    margin-bottom: 20px;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

.login-box h2 {
    margin-bottom: 5px;
    font-weight: 600;
}

.login-box p {
    color: var(--text-muted);
    margin-bottom: 30px;
    font-size: 0.9rem;
}

.error-msg {
    color: var(--danger) !important;
    margin-top: 15px;
    font-size: 0.85rem;
    height: 20px;
}

.login-footer {
    margin-top: 20px;
    color: var(--text-muted);
    font-size: 0.75rem;
    opacity: 0.5;
}

/* APP LAYOUT */
.app-container {
    display: grid;
    grid-template-columns: 260px 1fr;
    height: 100vh;
    transition: all 0.3s;
}

.sidebar {
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 24px;
    transition: transform 0.3s ease;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-main);
    margin-bottom: 40px;
}

nav ul {
    list-style: none;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 8px;
    font-weight: 500;
}

.nav-item:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
}

.nav-item.active {
    background-color: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.user-profile {
    margin-top: auto;
    display: flex;
    align-items: center;
    gap: 12px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ff0080, #7928ca);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    flex-shrink: 0;
}

.user-info {
    flex: 1;
}

.user-info .name {
    display: block;
    font-size: 0.9rem;
}

.user-info .role {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.btn-logout {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 5px;
    transition: color 0.2s;
    font-size: 1.2rem;
}

.btn-logout:hover {
    color: var(--danger);
}

.content {
    padding: 30px 40px;
    overflow-y: auto;
    position: relative;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

h2 {
    font-weight: 600;
    font-size: 1.8rem;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 12px;
    font-family: var(--font-main);
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.3s;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
}

.btn-secondary {
    background-color: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
    padding: 10px 20px;
    border-radius: 12px;
    cursor: pointer;
    margin-right: 10px;
}

.btn-secondary:hover {
    color: white;
    border-color: white;
}

.btn-delete {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.2rem;
    transition: color 0.2s;
    padding: 8px;
    border-radius: 8px;
    z-index: 2;
}

.btn-delete:hover {
    color: var(--danger);
    background-color: rgba(239, 68, 68, 0.1);
}

.view {
    display: none;
    animation: fadeIn 0.4s ease;
}

.view.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.card {
    background-color: var(--bg-card);
    border-radius: var(--radius);
    padding: 24px;
    border: 1px solid transparent;
}

.stat-card .big-text {
    font-size: 2.5rem;
    font-weight: 600;
    margin: 10px 0;
    color: var(--primary);
}

.empty-message {
    text-align: center;
    color: var(--text-muted);
    padding: 40px;
    font-style: italic;
    width: 100%;
    grid-column: 1 / -1;
}

.dashboard-panels {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.panel-box {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    border: 1px solid transparent;
    max-height: 400px;
    display: flex;
    flex-direction: column;
}

.panel-header {
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-main);
}

.ranking-list {
    overflow-y: auto;
    flex: 1;
}

.ranking-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 5px;
    background: rgba(255, 255, 255, 0.02);
}

.ranking-item:nth-child(1) {
    background: rgba(255, 215, 0, 0.1);
    border: 1px solid rgba(255, 215, 0, 0.2);
}

.ranking-item:nth-child(2) {
    background: rgba(192, 192, 192, 0.1);
}

.ranking-item:nth-child(3) {
    background: rgba(205, 127, 50, 0.1);
}

.count-badge {
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.8rem;
    font-weight: bold;
}

.grid-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
}

.filter-bar {
    margin-bottom: 20px;
}

.ministro-card {
    background-color: var(--bg-card);
    padding: 20px;
    border-radius: var(--radius);
    text-align: center;
    position: relative;
}

.ministro-card .btn-delete {
    position: absolute;
    top: 10px;
    right: 10px;
}

.ministro-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: #333;
    margin: 0 auto 10px;
    display: grid;
    place-items: center;
    font-size: 1.2rem;
}

.tag {
    font-size: 0.75rem;
    padding: 4px 8px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.1);
    display: inline-block;
    margin-top: 8px;
}

.song-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--bg-card);
    padding: 16px 20px;
    border-radius: 12px;
    margin-bottom: 10px;
    border-left: 4px solid var(--primary);
}

.song-info h4 {
    margin-bottom: 4px;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
}

.song-meta {
    display: flex;
    gap: 12px;
    color: var(--text-muted);
    font-size: 0.85rem;
    align-items: center;
    flex-wrap: wrap;
}

.song-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.tom-badge {
    background-color: rgba(99, 102, 241, 0.2);
    color: #a5b4fc;
    padding: 2px 8px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.8rem;
    border: 1px solid rgba(99, 102, 241, 0.3);
}

.btn-link {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--primary);
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
}

.btn-link:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.escala-card,
.ensaio-card {
    background-color: var(--bg-card);
    border-radius: var(--radius);
    padding: 24px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: transform 0.2s, border-color 0.2s;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.escala-card:hover,
.ensaio-card:hover {
    transform: translateY(-5px);
    border-color: var(--primary);
    background-color: var(--bg-card-hover);
}

.escala-card .btn-delete,
.ensaio-card .btn-delete {
    position: absolute;
    top: 15px;
    right: 15px;
}

.escala-header {
    display: flex;
    align-items: center;
    gap: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.escala-info h3 {
    font-size: 1.1rem;
    margin-bottom: 4px;
}

.date-badge {
    background-color: rgba(99, 102, 241, 0.1);
    color: var(--primary);
    padding: 8px 12px;
    border-radius: 10px;
    text-align: center;
    min-width: 60px;
    line-height: 1.1;
}

.date-badge .d {
    display: block;
    font-size: 1.4rem;
    font-weight: bold;
}

.date-badge .m {
    font-size: 0.75rem;
    text-transform: uppercase;
}

.card-mini-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.mini-item {
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mini-tom {
    background-color: rgba(99, 102, 241, 0.2);
    color: #a5b4fc;
    font-size: 0.75rem;
    padding: 1px 6px;
    border-radius: 4px;
    font-weight: bold;
    margin-left: auto;
}

.song-version {
    font-size: 0.75rem;
    color: #666;
    margin-left: 6px;
    font-style: italic;
}

.team-tag {
    background-color: var(--tag-team-bg);
    border: 1px solid var(--tag-team-border);
    color: var(--tag-team-color);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    display: inline-block;
    margin-right: 4px;
    margin-bottom: 4px;
}

/* Calendário */
.calendar-wrapper {
    background-color: var(--bg-card);
    padding: 20px;
    border-radius: var(--radius);
}

.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.cal-nav-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: white;
    border-radius: 8px;
    padding: 8px 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.cal-nav-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 10px;
    font-weight: 500;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
}

.day-cell {
    min-height: 100px;
    background-color: var(--bg-body);
    border-radius: 8px;
    padding: 8px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    border: 1px solid transparent;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.day-cell:hover {
    border-color: var(--border);
    background-color: rgba(255, 255, 255, 0.02);
}

.day-cell.today {
    border: 1px solid var(--primary);
}

.day-number {
    font-size: 0.9rem;
    font-weight: 600;
    display: block;
    margin-bottom: 4px;
    color: var(--text-muted);
}

.day-cell.inactive {
    opacity: 0.3;
    pointer-events: none;
}

.calendar-event-name {
    font-size: 0.75rem;
    padding: 3px 6px;
    border-radius: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    margin-bottom: 2px;
}

.calendar-event-name.type-escala {
    background-color: rgba(99, 102, 241, 0.15);
    color: #a5b4fc;
    border-left: 2px solid var(--cal-escala);
}

.calendar-event-name.type-ensaio {
    background-color: rgba(245, 158, 11, 0.15);
    color: #fcd34d;
    border-left: 2px solid var(--cal-ensaio);
}

.calendar-day-details {
    margin-top: 20px;
    border-top: 1px solid var(--border);
    padding-top: 20px;
    animation: fadeIn 0.3s;
}

.day-event-item {
    background-color: var(--bg-body);
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 8px;
    display: flex;
    gap: 10px;
    align-items: flex-start;
    border-left: 4px solid transparent;
}

.day-event-item.type-escala {
    border-left-color: var(--cal-escala);
}

.day-event-item.type-ensaio {
    border-left-color: var(--cal-ensaio);
}

.cal-songs-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 8px;
}

.cal-songs-list span {
    font-size: 0.85rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

.cal-songs-list span:before {
    content: "•";
    color: var(--primary);
}

/* Modal & Forms */
.song-list-detail {
    margin-top: 10px;
    list-style: none;
}

.song-list-detail li {
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-main);
    justify-content: space-between;
}

.song-list-detail li .song-main {
    display: flex;
    align-items: center;
    gap: 10px;
}

.song-list-detail li .song-main:before {
    content: "♪";
    color: var(--primary);
}

.member-list-detail {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 10px;
    margin-bottom: 20px;
}

/* --- ATUALIZAÇÃO PARA O MODAL DE DETALHES --- */

/* Ajuste do chip de membro para mostrar Nome e Função */
.member-chip {
    background: var(--bg-body);
    border: 1px solid var(--border);
    padding: 6px 12px;
    border-radius: 8px; /* Menos arredondado para caber o texto */
    display: flex;
    flex-direction: column; /* Um embaixo do outro */
    align-items: flex-start;
    gap: 2px;
    min-width: 100px;
}

.member-chip strong {
    font-size: 0.85rem;
    color: var(--text-main);
}

.member-chip span {
    font-size: 0.7rem;
    color: var(--primary); /* Cor de destaque para a função */
    opacity: 0.9;
    text-transform: uppercase;
    font-weight: 600;
}

/* Ajuste da lista de músicas no modal */
.song-list-detail li {
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    display: block; /* Mudado para block para controlar via flex interno */
}

.song-row-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.song-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.song-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Botão pequeno para o modal */
.btn-link.sm {
    width: 28px;
    height: 28px;
    font-size: 1rem;
}

.member-chip span {
    opacity: 0.7;
    font-size: 0.8rem;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-overlay.open {
    display: flex;
}

.modal {
    background: var(--bg-card);
    width: 90%;
    max-width: 500px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    max-height: 90vh;
}

.modal-large {
    width: 95% !important;
    max-width: 1200px !important;
    height: 95vh !important;
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.close-modal {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 1.2rem;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
}

.modal-footer {
    padding: 20px;
    border-top: 1px solid var(--border);
    text-align: right;
    flex-shrink: 0;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.form-input {
    width: 100%;
    background: var(--bg-body);
    border: 1px solid var(--border);
    padding: 10px;
    border-radius: 8px;
    color: white;
    font-family: var(--font-main);
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
}

textarea.form-input {
    resize: vertical;
    min-height: 80px;
    font-family: var(--font-main);
}

.suggestions-box {
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    max-height: 150px;
    overflow-y: auto;
    position: absolute;
    width: 100%;
    z-index: 10;
    margin-top: 4px;
    display: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.suggestion-item {
    padding: 10px;
    cursor: pointer;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 0.9rem;
    transition: background 0.2s;
}

.suggestion-item:hover {
    background-color: var(--primary);
    color: white;
}

.selected-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.item-tag {
    background-color: rgba(99, 102, 241, 0.2);
    border: 1px solid rgba(99, 102, 241, 0.3);
    color: #a5b4fc;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

.item-tag.team {
    background-color: var(--tag-team-bg);
    border-color: var(--tag-team-border);
    color: var(--tag-team-color);
}

.remove-btn {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    font-weight: bold;
    font-size: 1rem;
    display: grid;
    place-items: center;
}

.search-wrapper {
    position: relative;
}

.cifra-editor-area {
    width: 100%;
    height: 100%;
    background-color: #16181d;
    color: #e0e0e0;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 15px;
    font-family: var(--font-mono);
    font-size: 14px;
    line-height: 1.5;
    resize: none;
    outline: none;
    white-space: pre;
    overflow-x: auto;
}

.cifra-content-view {
    font-family: var(--font-mono);
    font-size: 14px;
    line-height: 1.5;
    color: #e0e0e0;
    white-space: pre;
    overflow-x: auto;
}

.editor-toolbar {
    margin-bottom: 10px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* MOBILE */
.mobile-menu-btn {
    display: none;
    background: transparent;
    border: none;
    color: var(--text-main);
    font-size: 1.5rem;
    cursor: pointer;
    margin-right: 15px;
}

.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
    z-index: 99;
    display: none;
}

@media (max-width: 768px) {
    .app-container {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        bottom: 0;
        width: 260px;
        z-index: 100;
        box-shadow: 5px 0 15px rgba(0, 0, 0, 0.5);
    }

    .sidebar.active {
        transform: translateX(280px);
    }

    .sidebar-overlay.active {
        display: block;
    }

    .content {
        padding: 20px;
    }

    .mobile-menu-btn {
        display: block;
    }

    header {
        justify-content: flex-start;
    }

    #page-title {
        flex: 1;
        font-size: 1.4rem;
    }

    .btn-primary {
        padding: 8px 12px;
        font-size: 0.9rem;
    }

    .cards-grid {
        grid-template-columns: 1fr;
    }

    .dashboard-panels {
        grid-template-columns: 1fr;
    }

    .grid-list {
        grid-template-columns: 1fr;
    }

    .song-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .song-actions {
        width: 100%;
        justify-content: flex-end;
        border-top: 1px solid rgba(255, 255, 255, 0.05);
        padding-top: 10px;
    }

    .modal {
        width: 100%;
        height: 100%;
        border-radius: 0;
        max-height: 100vh;
    }

    .modal-large {
        width: 100% !important;
        height: 100vh !important;
    }
}

/* --- Estilos das Tags de Categoria --- */
.categoria-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    /* Deixa arredondado */
    font-size: 0.75rem;
    /* Um pouco menor que o título */
    font-weight: bold;
    margin-right: 8px;
    /* Espaço entre a tag e o nome da música */
    text-transform: uppercase;
    vertical-align: middle;
}

/* Estilo Azul para Avivada */
.cat-avivada {
    background-color: #2196F3;
    /* Azul vibrante */
    color: white;
}

/* Estilo Amarelo Leve para Adoração */
.cat-adoracao {
    background-color: #FFF9C4;
    /* Amarelo bem clarinho */
    color: #5d4037;
    /* Texto marrom escuro para leitura fácil */
    border: 1px solid #FFE082;
    /* Borda sutil */
}