/* ========================================
   Portal Web - Orquestra Trombetas de Jerusalém
   Cores e estilo idênticos ao app Flutter
   ======================================== */

:root {
    --vermelho: #6E0400;
    --vermelho-claro: #712F2F;
    --dourado: #EBB424;
    --dourado-escuro: #E5AE2B;
    --branco: #FFFFFF;
    --superficie: #F7F3EA;
    --texto: #333333;
    --texto-claro: #666666;
    --borda: #E0E0E0;
    --sombra: rgba(0, 0, 0, 0.1);
    --sidebar-width: 260px;
    --navbar-height: 60px;
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--superficie);
    color: var(--texto);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

a {
    text-decoration: none;
    color: var(--vermelho);
}

a:hover {
    color: var(--dourado-escuro);
}

/* ========== NAVBAR ========== */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--navbar-height);
    background: var(--vermelho);
    color: var(--branco);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 1000;
    box-shadow: 0 2px 8px var(--sombra);
}

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

.navbar-logo {
    height: 36px;
    width: auto;
}

.navbar-title {
    font-weight: 700;
    font-size: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.navbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.navbar-user {
    font-size: 0.875rem;
    font-weight: 500;
    margin-right: 8px;
}

.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    color: var(--branco);
    transition: background 0.2s;
    border: none;
    background: none;
    cursor: pointer;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.15);
    color: var(--branco);
}

.btn-menu {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    color: var(--branco);
    border: none;
    background: none;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-menu:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* ========== SIDEBAR ========== */
.sidebar {
    position: fixed;
    top: var(--navbar-height);
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--branco);
    border-right: 1px solid var(--borda);
    z-index: 900;
    display: flex;
    flex-direction: column;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    overflow-y: auto;
}

.sidebar.open {
    transform: translateX(0);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: var(--navbar-height);
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 899;
}

.sidebar-overlay.show {
    display: block;
}

.sidebar-header {
    padding: 20px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--borda);
}

.sidebar-logo {
    height: 40px;
    width: auto;
}

.sidebar-header h3 {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--vermelho);
    line-height: 1.3;
}

.sidebar-nav {
    flex: 1;
    padding: 8px 0;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: var(--texto);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.sidebar-link:hover {
    background: rgba(235, 180, 36, 0.1);
    color: var(--vermelho);
}

.sidebar-link.active {
    background: rgba(235, 180, 36, 0.15);
    color: var(--vermelho);
    border-left-color: var(--dourado);
    font-weight: 700;
}

.sidebar-link .material-icons-outlined {
    font-size: 22px;
    color: var(--vermelho);
}

.sidebar-footer {
    border-top: 1px solid var(--borda);
    padding: 8px 0;
}

/* ========== MAIN CONTENT ========== */
.main-content {
    margin-top: var(--navbar-height);
    padding: 24px;
    min-height: calc(100vh - var(--navbar-height) - 50px);
    transition: margin-left 0.3s ease;
    overflow-x: hidden;
}

.main-content-full {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ========== LOGIN PAGE ========== */
.login-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--vermelho);
    padding: 20px;
    min-height: 100vh;
}

.login-card {
    background: var(--superficie);
    border-radius: 28px;
    padding: 32px;
    width: 100%;
    max-width: 440px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
}

.login-logo {
    display: block;
    margin: 0 auto 16px;
    height: 160px;
    width: auto;
}

.login-title {
    text-align: center;
    color: var(--vermelho);
    font-weight: 800;
    font-size: 1.25rem;
    margin-bottom: 24px;
}

.login-credits {
    text-align: center;
    color: #999;
    font-size: 0.75rem;
    margin-top: 16px;
}

/* ========== FORMS ========== */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--texto);
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    /* Borda preta por padrão para melhor contraste (corrige campos sem borda/ branca) */
    border: 1px solid #000;
    border-radius: 14px;
    background: var(--branco);
    font-family: inherit;
    font-size: 0.9rem;
    color: var(--texto);
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
}

.form-control:focus {
    border-color: var(--dourado);
    box-shadow: 0 0 0 3px rgba(235, 180, 36, 0.2);
}

.form-control::placeholder {
    color: #999;
}

.form-icon-group {
    position: relative;
}

.form-icon-group .material-icons-outlined {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
    font-size: 20px;
}

.form-icon-group .form-control {
    padding-left: 44px;
}

.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
}

.form-check input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: var(--dourado);
    cursor: pointer;
}

.form-check label {
    font-size: 0.875rem;
    cursor: pointer;
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23666'%3e%3cpath d='M7 10l5 5 5-5z'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 24px;
    padding-right: 40px;
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
}

/* Campos de formulário que NÃO usam a classe .form-control
   — garante borda preta consistente para inputs/textarea/select */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="date"],
input[type="number"],
input[type="tel"],
input[type="url"],
textarea,
select {
    border: 1px solid #000;
    border-radius: 14px;
    padding: 10px 14px;
    background: var(--branco);
    color: var(--texto);
    font-family: inherit;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="search"]:focus,
input[type="date"]:focus,
input[type="number"]:focus,
input[type="tel"]:focus,
input[type="url"]:focus,
textarea:focus,
select:focus {
    border-color: var(--dourado);
    box-shadow: 0 0 0 3px rgba(235, 180, 36, 0.15);
}

/* ========== BUTTONS ========== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border: none;
    border-radius: 14px;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    background: var(--dourado);
    color: #222;
}

.btn-primary:hover {
    background: var(--dourado-escuro);
    color: #222;
    box-shadow: 0 4px 12px rgba(235, 180, 36, 0.4);
}

.btn-danger {
    background: var(--vermelho);
    color: var(--branco);
}

.btn-danger:hover {
    background: var(--vermelho-claro);
    color: var(--branco);
}

.btn-outline {
    background: transparent;
    color: var(--vermelho);
    border: 2px solid var(--vermelho);
}

.btn-outline:hover {
    background: var(--vermelho);
    color: var(--branco);
}

.btn-block {
    width: 100%;
}

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

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

/* ========== CARDS ========== */
.card {
    background: var(--branco);
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 2px 8px var(--sombra);
    transition: box-shadow 0.2s, transform 0.2s;
}

.card:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

.card-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--vermelho);
    margin-bottom: 12px;
}

/* Home Tiles (igual app) */
.home-tiles {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    margin-bottom: 24px;
}

.home-tile {
    width: 160px;
    height: 120px;
    background: var(--branco);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 4px 12px var(--sombra);
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    color: var(--texto);
}

.home-tile:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
    color: var(--texto);
}

.home-tile .material-icons-outlined {
    font-size: 34px;
    color: var(--vermelho);
}

.home-tile span:last-child {
    font-weight: 600;
    font-size: 0.95rem;
}

/* ========== TABLE ========== */
.table-container {
    overflow-x: auto;
    border-radius: 16px;
    background: var(--branco);
    box-shadow: 0 2px 8px var(--sombra);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

thead th {
    background: var(--vermelho);
    color: var(--branco);
    padding: 14px 16px;
    text-align: left;
    font-weight: 600;
    white-space: nowrap;
}

thead th:first-child {
    border-radius: 16px 0 0 0;
}

thead th:last-child {
    border-radius: 0 16px 0 0;
}

tbody tr {
    border-bottom: 1px solid var(--borda);
    transition: background 0.15s;
}

tbody tr:hover {
    background: rgba(235, 180, 36, 0.05);
}

tbody td {
    padding: 12px 16px;
    vertical-align: middle;
}

/* ========== BADGES ========== */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    white-space: nowrap;
}

.badge-master {
    background: var(--vermelho);
    color: var(--branco);
}

.badge-adm {
    background: var(--dourado);
    color: #222;
}

.badge-regente {
    background: #4A90D9;
    color: var(--branco);
}

.badge-musicos {
    background: #7B7B7B;
    color: var(--branco);
}

.badge-ativo {
    background: #2ECC71;
    color: var(--branco);
}

.badge-inativo {
    background: #E74C3C;
    color: var(--branco);
}

.badge-notif {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #E74C3C;
    color: white;
    font-size: 0.65rem;
    min-width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-weight: 700;
}

/* ========== AGENDA CARD ========== */
.agenda-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px;
    border-radius: 16px;
    background: var(--branco);
    box-shadow: 0 2px 6px var(--sombra);
    border: 1px solid var(--borda);
    margin-bottom: 10px;
    transition: all 0.2s;
    cursor: pointer;
    opacity: 0.85;
}

.agenda-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    opacity: 1;
}

.agenda-card.is-today {
    background: linear-gradient(135deg, #66BB6A, #43A047);
    border-color: #2E7D32;
    color: white;
}

.agenda-card-icon {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    flex-shrink: 0;
}

.agenda-card-icon .material-icons-outlined {
    color: var(--vermelho);
    font-size: 28px;
}

.agenda-card.is-today .agenda-card-icon .material-icons-outlined {
    color: #2E7D32;
}

.agenda-card-body {
    flex: 1;
    min-width: 0;
}

.agenda-card-chips {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 4px;
}

.chip {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 700;
    background: rgba(235, 180, 36, 0.15);
    color: var(--vermelho);
}

.agenda-card.is-today .chip {
    background: white;
    color: #2E7D32;
}

.agenda-card-title {
    font-weight: 800;
    font-size: 1rem;
    margin-bottom: 2px;
}

.agenda-card-obs {
    font-size: 0.8rem;
    opacity: 0.8;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ========== PARTITURAS ========== */
.partitura-card {
    background: var(--branco);
    border-radius: 16px;
    padding: 16px;
    box-shadow: 0 2px 8px var(--sombra);
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: all 0.2s;
}

.partitura-card:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    transform: translateY(-1px);
}

.partitura-title {
    font-weight: 700;
    color: var(--vermelho);
    font-size: 1rem;
}

.partitura-meta {
    font-size: 0.8rem;
    color: var(--texto-claro);
}

.partitura-naipes {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.partitura-naipe-tag {
    padding: 2px 8px;
    border-radius: 8px;
    font-size: 0.7rem;
    background: rgba(235, 180, 36, 0.15);
    color: var(--vermelho);
    font-weight: 600;
}

/* ========== PDF VIEWER ========== */
.pdf-viewer-container {
    width: 100%;
    height: calc(100vh - var(--navbar-height) - 80px);
    border: none;
    border-radius: 8px;
    background: #333;
}

/* ========== ALERTS ========== */
.alert {
    padding: 14px 20px;
    border-radius: 14px;
    margin-bottom: 16px;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-success {
    background: #EAF8EF;
    color: #1E7E45;
    border: 1px solid #7ED8A8;
}

.alert-error {
    background: #FDECEC;
    color: #A82323;
    border: 1px solid #F3A5A5;
}

.alert-warning {
    background: #FFF8E6;
    color: #8A6A00;
    border: 1px solid #F1D37B;
}

.alert-info {
    background: #EAF3FF;
    color: #1E5FAF;
    border: 1px solid #9FC2F7;
}

/* ========== MODAL ========== */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay.show {
    display: flex;
}

.modal {
    background: var(--branco);
    border-radius: 16px;
    padding: 24px;
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.modal-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--vermelho);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

/* ========== PAGE HEADER ========== */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 24px;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--texto);
}

/* ========== SEARCH BAR ========== */
.search-bar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.search-bar .form-control {
    flex: 1;
    min-width: 200px;
}

/* ========== GRID ========== */
.grid {
    display: grid;
    gap: 16px;
}

.grid-2 {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.grid-3 {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}

/* ========== LOADING ========== */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(0, 0, 0, 0.1);
    border-left-color: var(--dourado);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-overlay {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: var(--texto-claro);
    gap: 12px;
}

/* ========== EMPTY STATE ========== */
.empty-state {
    text-align: center;
    padding: 40px;
    color: var(--texto-claro);
}

.empty-state .material-icons-outlined {
    font-size: 64px;
    color: var(--borda);
    margin-bottom: 12px;
}

/* ========== FOOTER ========== */
.footer {
    text-align: center;
    padding: 12px 16px;
    font-size: 0.7rem;
    color: var(--texto-claro);
    border-top: 1px solid var(--borda);
    margin-top: auto;
}

.footer a {
    color: var(--vermelho);
    font-weight: 600;
}

/* ========== WATERMARK ========== */
.watermark {
    max-width: 700px;
    margin: 0 auto;
    text-align: center;
    opacity: 0.06;
    pointer-events: none;
    padding: 0 24px 8px;
}

.watermark img {
    width: 100%;
    max-width: 600px;
    height: auto;
}

/* ========== GLOBAL NOTIFICATIONS (TOP CENTER) ========== */
#globalNotificationContainer {
    pointer-events: none;
}
.global-notif {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 18px;
    border-radius: 12px;
    font-weight: 700;
    box-shadow: 0 6px 24px rgba(0,0,0,0.18);
    background: #FFFFFF;
    color: var(--texto);
    border: 1px solid #DADADA;
}
.global-notif .material-icons-outlined {
    font-size: 20px;
}
.global-notif.alert-success {
    background: #EAF8EF;
    border-color: #7ED8A8;
    color: #1E7E45;
}
.global-notif.alert-error {
    background: #FDECEC;
    border-color: #F3A5A5;
    color: #A82323;
}
.global-notif.alert-info {
    background: #EAF3FF;
    border-color: #9FC2F7;
    color: #1E5FAF;
}

/* Responsividade para notificações globais */
@media (max-width: 600px) {
    #globalNotificationContainer {
        top: 8px;
        left: 50%;
        transform: translateX(-50%);
        padding: 0 8px;
    }
    .global-notif {
        width: calc(100% - 32px) !important;
        padding: 10px 12px;
        font-size: 0.9rem;
        border-radius: 10px;
        gap: 8px;
    }
    .global-notif .material-icons-outlined { font-size: 18px; }
}

@media (min-width: 601px) and (max-width: 920px) {
    .global-notif {
        width: calc(100% - 80px) !important;
        font-size: 0.98rem;
    }
}

/* ========== UTILITIES ========== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.font-bold { font-weight: 700; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.d-flex { display: flex; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.flex-wrap { flex-wrap: wrap; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-100 { width: 100%; }
.relative { position: relative; }

/* ========== RESPONSIVE ========== */

/* Desktop grande */
@media (min-width: 992px) {
    .sidebar {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: var(--sidebar-width);
    }
    
    .btn-menu {
        display: none;
    }
    
    .navbar-title {
        max-width: 400px;
    }
}

/* Tablet */
@media (max-width: 991px) {
    .navbar-title {
        display: none;
    }
    
    .navbar-user {
        display: none;
    }
}

/* Mobile */
@media (max-width: 600px) {
    .main-content {
        padding: 16px 12px;
    }
    
    .home-tile {
        width: 140px;
        height: 100px;
    }
    
    .home-tile .material-icons-outlined {
        font-size: 28px;
    }
    
    .home-tile span:last-child {
        font-size: 0.85rem;
    }
    
    .page-title {
        font-size: 1.2rem;
    }
    
    .login-card {
        padding: 24px 20px;
        border-radius: 20px;
    }
    
    .login-logo {
        height: 120px;
    }
    
    .modal {
        margin: 12px;
        border-radius: 12px;
    }
    
    table {
        font-size: 0.8rem;
    }
    
    thead th, tbody td {
        padding: 10px 12px;
    }
    
    .watermark {
        padding: 0 12px 8px;
    }
    
    .watermark img {
        width: 100%;
    }
}

/* Tema escuro para PDF viewer */
@media (prefers-color-scheme: dark) {
    /* Mantém tema claro mesmo em modo escuro do sistema */
}

/* Print */
@media print {
    .navbar, .sidebar, .sidebar-overlay, .btn, .footer {
        display: none !important;
    }
    
    .main-content {
        margin: 0 !important;
        padding: 0 !important;
    }
}
