/* ========================================
   INSTITUIÇÕES CSS
   Sistema de Cores e Variáveis
   ======================================== */

:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-card: #1a1a24;
    --bg-card-hover: #22222e;
    --accent-primary: #e74c3c;
    --accent-secondary: #ff6b5b;
    --accent-gradient: linear-gradient(135deg, #e74c3c 0%, #ff6b5b 100%);
    --text-primary: #ffffff;
    --text-secondary: #8a8a9a;
    --text-muted: #5a5a6a;
    --success: #00d4aa;
    --warning: #ffc107;
    --danger: #ff4757;
    --info: #3498db;
    --border-color: rgba(255, 255, 255, 0.08);
    --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 40px rgba(231, 76, 60, 0.15);
}

/* ========================================
   RESET E BASE
   ======================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
}

/* ========================================
   LOADING SCREEN
   ======================================== */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    flex-direction: column;
    gap: 20px;
}

.loading-screen.hidden {
    display: none;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border-color);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-text {
    color: var(--text-secondary);
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ========================================
   LAYOUT PRINCIPAL
   ======================================== */
.dashboard-container {
    display: flex;
    min-height: 100vh;
}

.dashboard-container.hidden {
    display: none;
}

/* ========================================
   SIDEBAR
   ======================================== */
.sidebar {
    width: 260px;
    min-width: 260px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    padding: 30px 20px;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 30px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 30px;
}

.logo-icon {
    width: 45px;
    height: 45px;
    background: var(--accent-gradient);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    box-shadow: var(--shadow-glow);
}

.logo-text {
    font-size: 18px;
    font-weight: 700;
}

.logo-text span {
    color: var(--accent-primary);
}

.nav-section {
    margin-bottom: 30px;
}

.nav-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    margin-bottom: 15px;
    padding-left: 15px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 15px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: 5px;
    text-decoration: none;
}

.nav-item:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--accent-gradient);
    color: white;
    box-shadow: var(--shadow-glow);
}

.nav-icon {
    font-size: 20px;
    width: 24px;
    text-align: center;
}

/* ========================================
   CONTEÚDO PRINCIPAL
   ======================================== */
.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 30px 40px;
    width: calc(100% - 260px);
}

/* ========================================
   HEADER
   ======================================== */
.header {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.header-left h1 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 5px;
}

.header-left p {
    color: var(--text-secondary);
    font-size: 15px;
}

.header-right {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 15px;
}

/* ========================================
   BOTÕES
   ======================================== */
.btn-primary {
    background: var(--accent-gradient);
    border: none;
    color: white;
    padding: 12px 24px;
    border-radius: 10px;
    font-family: 'Outfit', sans-serif;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

.btn-logout {
    background: rgba(255, 71, 87, 0.1);
    border: 1px solid rgba(255, 71, 87, 0.3);
    color: var(--danger);
    padding: 10px 16px;
    border-radius: 10px;
    cursor: pointer;
    font-family: 'Outfit', sans-serif;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-logout:hover {
    background: var(--danger);
    color: white;
}

/* ========================================
   CARDS DE ESTATÍSTICAS
   ======================================== */
.stats-row {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 25px;
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-card);
}

.stat-header {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.stat-icon {
    width: 45px;
    height: 45px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
}

.stat-icon.blue { background: rgba(52, 152, 219, 0.15); }
.stat-icon.green { background: rgba(0, 212, 170, 0.15); }
.stat-icon.orange { background: rgba(255, 193, 7, 0.15); }
.stat-icon.purple { background: rgba(168, 85, 247, 0.15); }
.stat-icon.pink { background: rgba(255, 107, 129, 0.15); }

.stat-trend {
    font-size: 12px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 20px;
}

.stat-trend.up {
    color: var(--success);
    background: rgba(0, 212, 170, 0.1);
}

.stat-trend.down {
    color: var(--danger);
    background: rgba(255, 71, 87, 0.1);
}

.stat-value {
    font-size: 32px;
    font-weight: 800;
    font-family: 'Space Mono', monospace;
    margin-bottom: 5px;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 14px;
}

/* ========================================
   FILTROS
   ======================================== */
.filters-bar {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.search-box {
    display: flex;
    align-items: center;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 0 15px;
    flex: 1;
    max-width: 400px;
}

.search-box input {
    background: none;
    border: none;
    color: var(--text-primary);
    padding: 12px;
    font-family: 'Outfit', sans-serif;
    font-size: 14px;
    width: 100%;
    outline: none;
}

.search-box input::placeholder {
    color: var(--text-muted);
}

.search-icon {
    color: var(--text-muted);
    font-size: 18px;
}

.filter-group {
    display: flex;
    flex-direction: row;
    gap: 10px;
}

.filter-select {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-primary);
    padding: 12px 15px;
    font-family: 'Outfit', sans-serif;
    font-size: 14px;
    cursor: pointer;
    outline: none;
}

.filter-select option {
    background: var(--bg-secondary);
}

/* ========================================
   TABELA
   ======================================== */
.table-card {
    background: var(--bg-card);
    border-radius: 16px;
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.table-header {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    border-bottom: 1px solid var(--border-color);
}

.table-header h3 {
    font-size: 18px;
    font-weight: 600;
}

.table-count {
    color: var(--text-muted);
    font-size: 14px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    text-align: left;
    padding: 15px 25px;
    color: var(--text-muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    background: var(--bg-secondary);
}

.data-table td {
    padding: 20px 25px;
    border-bottom: 1px solid var(--border-color);
    font-size: 14px;
}

.data-table tbody tr {
    transition: background 0.3s ease;
}

.data-table tbody tr:hover {
    background: var(--bg-card-hover);
}

/* ========================================
   CÉLULAS DA TABELA
   ======================================== */
.institution-cell {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
}

.institution-icon {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
}

.institution-icon.escola { background: rgba(52, 152, 219, 0.15); }
.institution-icon.empresa { background: rgba(168, 85, 247, 0.15); }
.institution-icon.clinica { background: rgba(0, 212, 170, 0.15); }
.institution-icon.ong { background: rgba(255, 193, 7, 0.15); }

.institution-info .name {
    font-weight: 600;
    margin-bottom: 3px;
}

.institution-info .cnpj {
    font-size: 12px;
    color: var(--text-muted);
    font-family: 'Space Mono', monospace;
}

/* ========================================
   BADGES
   ======================================== */
.type-badge {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
}

.type-badge.escola { background: rgba(52, 152, 219, 0.15); color: #3498db; }
.type-badge.empresa { background: rgba(168, 85, 247, 0.15); color: #a855f7; }
.type-badge.clinica { background: rgba(0, 212, 170, 0.15); color: var(--success); }
.type-badge.ong { background: rgba(255, 193, 7, 0.15); color: var(--warning); }

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.status-badge.ativa { background: rgba(0, 212, 170, 0.15); color: var(--success); }
.status-badge.inativa { background: rgba(138, 138, 154, 0.15); color: var(--text-secondary); }
.status-badge.pendente { background: rgba(255, 193, 7, 0.15); color: var(--warning); }
.status-badge.bloqueada { background: rgba(255, 71, 87, 0.15); color: var(--danger); }

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.status-badge.ativa .status-dot { background: var(--success); }
.status-badge.inativa .status-dot { background: var(--text-secondary); }
.status-badge.pendente .status-dot { background: var(--warning); }
.status-badge.bloqueada .status-dot { background: var(--danger); }

.plan-badge {
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
}

.plan-badge.basico { background: rgba(138, 138, 154, 0.15); color: var(--text-secondary); }
.plan-badge.premium { background: rgba(231, 76, 60, 0.15); color: var(--accent-primary); }
.plan-badge.empresarial { background: rgba(168, 85, 247, 0.15); color: #a855f7; }

.users-count {
    font-weight: 600;
    color: var(--text-primary);
}

.users-count .label {
    font-weight: 400;
    font-size: 12px;
    color: var(--text-muted);
    margin-left: 4px;
}

/* ========================================
   AÇÕES
   ======================================== */
.actions-cell {
    display: flex;
    flex-direction: row;
    gap: 8px;
}

.action-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.3s ease;
}

.action-btn:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.action-btn.view:hover {
    background: rgba(52, 152, 219, 0.2);
    color: var(--info);
}

.action-btn.edit:hover {
    background: rgba(0, 212, 170, 0.2);
    color: var(--success);
}

.action-btn.delete:hover {
    background: rgba(255, 71, 87, 0.2);
    color: var(--danger);
}

/* ========================================
   PAGINAÇÃO
   ======================================== */
.pagination {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    border-top: 1px solid var(--border-color);
}

.pagination-info {
    color: var(--text-muted);
    font-size: 14px;
}

.pagination-controls {
    display: flex;
    flex-direction: row;
    gap: 8px;
}

.page-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    cursor: pointer;
    font-family: 'Outfit', sans-serif;
    font-size: 14px;
    transition: all 0.3s ease;
}

.page-btn:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.page-btn.active {
    background: var(--accent-gradient);
    color: white;
    border-color: var(--accent-primary);
}

/* ========================================
   SCROLLBAR PERSONALIZADA
   ======================================== */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 4px;
}

/* ========================================
   RESPONSIVIDADE
   ======================================== */
@media (max-width: 1600px) {
    .stats-row {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 1200px) {
    .stats-row {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 900px) {
    .sidebar {
        display: none;
    }
    
    .main-content {
        margin-left: 0;
        width: 100%;
        padding: 20px;
    }
    
    .header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    
    .stats-row {
        grid-template-columns: 1fr;
    }
    
    .filters-bar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .search-box {
        max-width: none;
    }
}

/* ========================================
   ANIMAÇÕES
   ======================================== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.stat-card, .table-card {
    animation: fadeInUp 0.5s ease forwards;
}