/* ============================================================
   KendoWeb — Estilos customizados
   ============================================================ */

:root {
    --sidebar-width: 240px;
    --sidebar-collapsed-width: 64px;
    --navbar-height: 56px;
    --kendo-red: #c0392b;
    --kendo-dark: #1a1a2e;
    --kendo-accent: #e8b84b;
}

/* ----- Layout Geral ----- */
body {
    background-color: #f4f6f9;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* ----- Sidebar ----- */
.sidebar {
    position: fixed;
    top: var(--navbar-height);
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--kendo-dark);
    transition: width 0.25s ease;
    overflow-x: hidden;
    overflow-y: auto;
    z-index: 1030;
    box-shadow: 2px 0 8px rgba(0,0,0,0.15);
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

.sidebar-inner {
    min-width: var(--sidebar-width);
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 18px;
    color: #b0b8c8;
    text-decoration: none;
    font-size: 0.9rem;
    white-space: nowrap;
    border-left: 3px solid transparent;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.sidebar-link i {
    font-size: 1.15rem;
    flex-shrink: 0;
    width: 22px;
    text-align: center;
}

.sidebar-link:hover {
    background: rgba(255,255,255,0.07);
    color: #ffffff;
    border-left-color: var(--kendo-accent);
}

.sidebar-link.active {
    background: rgba(232, 184, 75, 0.12);
    color: var(--kendo-accent);
    border-left-color: var(--kendo-accent);
    font-weight: 600;
}

.sidebar-divider {
    border-color: rgba(255,255,255,0.1);
    margin: 8px 16px;
}

.sidebar.collapsed .sidebar-link span {
    display: none;
}

/* ----- Grupos do menu (acordeão) ----- */
.sidebar-group-header {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 11px 18px;
    color: #b0b8c8;
    background: transparent;
    border: none;
    border-left: 3px solid transparent;
    font-size: 0.9rem;
    white-space: nowrap;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.sidebar-group-header i {
    font-size: 1.15rem;
    flex-shrink: 0;
    width: 22px;
    text-align: center;
}
.sidebar-group-header:hover {
    background: rgba(255,255,255,0.07);
    color: #ffffff;
}
/* Chevron à direita, gira quando o grupo está aberto (via aria-expanded) */
.sidebar-group-chevron {
    margin-left: auto;
    font-size: 0.8rem !important;
    width: auto !important;
    transition: transform 0.2s ease;
}
.sidebar-group-header[aria-expanded="true"] .sidebar-group-chevron {
    transform: rotate(180deg);
}

/* Itens dentro de um grupo: leve recuo para hierarquia visual */
.sidebar-subitem {
    padding-left: 30px;
    font-size: 0.86rem;
}

/* Menu recolhido: esconde textos e o chevron dos grupos */
.sidebar.collapsed .sidebar-group-header span,
.sidebar.collapsed .sidebar-group-chevron {
    display: none;
}

/* ----- Conteúdo Principal ----- */
.main-content {
    margin-left: var(--sidebar-width);
    margin-top: var(--navbar-height);
    transition: margin-left 0.25s ease;
    min-height: calc(100vh - var(--navbar-height));
}

.main-content.expanded {
    margin-left: var(--sidebar-collapsed-width);
}

/* ----- Cards do Dashboard ----- */
.card-stat {
    border: none;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.07);
    transition: transform 0.15s, box-shadow 0.15s;
}

.card-stat:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.12);
}

.card-stat .stat-icon {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
}

/* ----- Tabelas ----- */
.table-card {
    border: none;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
    overflow: hidden;
}

.table-card .table {
    margin-bottom: 0;
}

.table thead th {
    background-color: #f8f9fa;
    font-weight: 600;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #6c757d;
    border-bottom: 2px solid #dee2e6;
}

.table tbody tr:hover {
    background-color: #f8f9ff;
}

/* ----- Formulários ----- */
.form-card {
    border: none;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.07);
}

.form-label {
    font-weight: 500;
    font-size: 0.88rem;
    color: #495057;
    margin-bottom: 4px;
}

.form-control:focus, .form-select:focus {
    border-color: var(--kendo-accent);
    box-shadow: 0 0 0 0.2rem rgba(232, 184, 75, 0.25);
}

/* ----- Foto preview ----- */
#foto-preview {
    max-width: 150px;
    max-height: 150px;
    border-radius: 8px;
    object-fit: cover;
    border: 2px solid #dee2e6;
}

/* ----- Formsets de Responsável ----- */
.formset-item {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
    border: 1px solid #e9ecef;
}

/* O botão Remover fica na própria coluna, alinhado à base dos inputs */
.formset-item .btn-remove-formset {
    white-space: nowrap;
}

/* ----- Badges de situação ----- */
.badge-ativo        { background-color: #198754; }
.badge-em_pausa     { background-color: #ffc107; color: #000; }
.badge-afastado_saude { background-color: #0d6efd; }
.badge-inativo      { background-color: #6c757d; }

/* ----- Select2 integration ----- */
.select2-container--bootstrap-5 .select2-selection {
    min-height: 38px;
}

/* ----- Página de login ----- */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--kendo-dark) 0%, #16213e 50%, #0f3460 100%);
}

.login-card {
    border: none;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    width: 100%;
    max-width: 400px;
}

.login-logo {
    font-size: 3rem;
    color: var(--kendo-accent);
}

/* ----- Page header ----- */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1a1a2e;
    margin: 0;
}

/* ----- Responsivo Mobile ----- */
@media (max-width: 768px) {
    .sidebar {
        width: 0;
        overflow: hidden;
    }
    .sidebar.mobile-open {
        width: var(--sidebar-width);
    }
    .main-content {
        margin-left: 0 !important;
    }
}

/* ============================================================
   Marcação de Presença (mobile-first, touch-friendly)
   ============================================================ */
.lista-presenca {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Cada praticante é uma linha grande e totalmente tocável */
.presenca-linha {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 56px;            /* área de toque generosa (> 48px) */
    padding: 8px 14px;
    background: #fff;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.12s, border-color 0.12s;
    margin: 0;
}

/* O checkbox real fica oculto — o estado é dado pela linha inteira */
.presenca-check {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

.presenca-foto {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #adb5bd;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    font-size: 1.2rem;
}
.presenca-foto img { width: 100%; height: 100%; object-fit: cover; }

.presenca-nome {
    flex: 1;
    font-size: 1.05rem;
    font-weight: 600;
    color: #212529;
    line-height: 1.2;
}

/* Ícone de check: escondido quando ausente, visível quando presente */
.presenca-icone {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #e9ecef;
    color: #adb5bd;
    font-size: 1.2rem;
    transition: background 0.12s, color 0.12s;
}

/* Estado PRESENTE: linha verde destacada, ícone de check aceso */
.presenca-linha:has(.presenca-check:checked) {
    background: #d1e7dd;
    border-color: #198754;
}
.presenca-linha:has(.presenca-check:checked) .presenca-icone {
    background: #198754;
    color: #fff;
}

/* Fallback para navegadores sem :has() — usa irmão adjacente */
.presenca-check:checked ~ .presenca-icone {
    background: #198754;
    color: #fff;
}

.presenca-linha:active { transform: scale(0.995); }

/* Linha desabilitada (somente leitura) */
.presenca-linha:has(.presenca-check:disabled) { cursor: default; opacity: 0.85; }

/* Barra fixa de salvar (alcançável com o polegar) */
.barra-salvar {
    position: fixed;
    bottom: 0;
    left: var(--sidebar-width);
    right: 0;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.97);
    border-top: 1px solid #dee2e6;
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.08);
    z-index: 1020;
    transition: left 0.25s ease;
}

@media (max-width: 768px) {
    .barra-salvar { left: 0; }
    .presenca-nome { font-size: 1rem; }
}
