/* ================================================================
   app.css — Sistema de Gestão de Documentos PDF com QR Code
   Sprint 1 — Layout base, Sidebar, Autenticação
   ================================================================ */

/* ── Variáveis CSS ──────────────────────────────────────────────── */
:root {
    --sidebar-width:       260px;
    --sidebar-width-collapsed: 0px;
    --sidebar-bg:          #1a2638;
    --sidebar-text:        #9aacbf;
    --sidebar-text-active: #ffffff;
    --sidebar-hover-bg:    #243447;
    --sidebar-active-bg:   #0d6efd;
    --sidebar-section:     #4e6680;
    --sidebar-footer-bg:   #131e2b;
    --topbar-height:       62px;
    --primary:             #0d6efd;
    --body-bg:             #f0f4f8;
    --card-radius:         12px;
    --transition-speed:    0.25s;
}

/* ── Reset / Base ───────────────────────────────────────────────── */
*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--body-bg);
    color: #1a202c;
    margin: 0;
}

/* ── Wrapper Principal ──────────────────────────────────────────── */
#wrapper {
    min-height: 100vh;
}

/* ================================================================
   SIDEBAR
   ================================================================ */

.sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    transition: width var(--transition-speed) ease;
    scrollbar-width: thin;
    scrollbar-color: #2d4460 transparent;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: #2d4460; border-radius: 2px; }

/* Estado colapsado (desktop) */
.sidebar.collapsed {
    width: 0;
    overflow: hidden;
}

/* ── Logo / Cabeçalho ───────────────────────────────────────────── */
.sidebar-header {
    padding: 1.25rem 1.5rem;
    color: #ffffff;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
    flex-shrink: 0;
    min-height: var(--topbar-height);
    display: flex;
    align-items: center;
}

/* ── Navegação ──────────────────────────────────────────────────── */
.sidebar-nav {
    flex: 1;
    list-style: none;
    margin: 0;
    padding: 0.5rem 0;
}

.sidebar-nav .nav-link {
    color: var(--sidebar-text);
    padding: 0.65rem 1.5rem;
    font-size: 0.875rem;
    font-weight: 400;
    border-radius: 0;
    display: flex;
    align-items: center;
    transition: background var(--transition-speed) ease,
                color var(--transition-speed) ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-nav .nav-link:hover {
    background: var(--sidebar-hover-bg);
    color: var(--sidebar-text-active);
}

.sidebar-nav .nav-link.active {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-text-active);
    font-weight: 500;
}

/* Seções / Separadores */
.sidebar-nav .nav-section {
    list-style: none;
    padding: 1rem 1.5rem 0.35rem;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--sidebar-section);
    white-space: nowrap;
    overflow: hidden;
}

/* ── Rodapé da Sidebar ──────────────────────────────────────────── */
.sidebar-footer {
    padding: 0.75rem 1.5rem;
    background: var(--sidebar-footer-bg);
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
}

/* ================================================================
   ÁREA PRINCIPAL
   ================================================================ */

#page-content {
    min-height: 100vh;
    overflow-x: hidden;
    transition: margin-left var(--transition-speed) ease;
}

/* ── Topbar ─────────────────────────────────────────────────────── */
.topbar {
    height: var(--topbar-height);
    position: sticky;
    top: 0;
    z-index: 1020;
    flex-shrink: 0;
}

/* ── Conteúdo ───────────────────────────────────────────────────── */
.main-content {
    min-height: calc(100vh - var(--topbar-height) - 48px);
}

/* ── Rodapé ─────────────────────────────────────────────────────── */
.footer {
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* ================================================================
   CARDS / ESTATÍSTICAS
   ================================================================ */

.card {
    border-radius: var(--card-radius);
}

.stat-card {
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

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

.stat-icon {
    width: 58px;
    height: 58px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* ================================================================
   LAYOUT DE AUTENTICAÇÃO
   ================================================================ */

.auth-body {
    background: linear-gradient(135deg, #1a2638 0%, #0d6efd 100%);
    min-height: 100vh;
}

.auth-wrapper {
    width: 100%;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    border-radius: 16px !important;
}

.auth-icon {
    width: 64px;
    height: 64px;
    background: rgba(13, 110, 253, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ── Input group sem borda dupla ────────────────────────────────── */
.auth-card .input-group-text,
.auth-card .form-control,
.auth-card .btn-outline-secondary {
    border-color: #dee2e6;
}

.auth-card .form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.15);
    z-index: 3;
}

/* ================================================================
   DATATABLES
   ================================================================ */

.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter {
    margin-bottom: 1rem;
}

.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate {
    margin-top: 1rem;
}

/* ================================================================
   RESPONSIVIDADE MOBILE
   ================================================================ */

/* Overlay escuro quando sidebar está aberta no mobile */
#sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 1040;
    cursor: pointer;
}

#sidebar-overlay.active {
    display: block;
}

@media (max-width: 991.98px) {

    /* Sidebar vira drawer flutuante no mobile */
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        z-index: 1050;
        width: var(--sidebar-width);
        transform: translateX(-100%);
        transition: transform var(--transition-speed) ease;
    }

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

    /* Sidebar colapsada no mobile (via botão desktop) não conflita */
    .sidebar.collapsed {
        transform: translateX(-100%);
        width: var(--sidebar-width);
    }

}

/* ================================================================
   UTILITÁRIOS
   ================================================================ */

/* Texto com 2 linhas máximo (útil em títulos de documentos) */
.text-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Badges de status */
.badge-status-ativo    { background-color: #d1f2eb; color: #0e6655; }
.badge-status-vencido  { background-color: #fadbd8; color: #922b21; }
.badge-status-inativo  { background-color: #eaecee; color: #555; }

/* Hover em linhas de tabela */
.table-hover tbody tr:hover td {
    background-color: rgba(13, 110, 253, 0.04);
}

/* ================================================================
   UPLOAD AREA — Sprint 2+3
   ================================================================ */

.upload-area {
    border: 2px dashed #c4cdd5;
    border-radius: 12px;
    cursor: pointer;
    transition: border-color 0.2s ease, background-color 0.2s ease;
    overflow: hidden;
}

.upload-area:hover {
    border-color: var(--primary);
    background-color: rgba(13, 110, 253, 0.03);
}

.upload-area.drag-over {
    border-color: var(--primary);
    background-color: rgba(13, 110, 253, 0.06);
    border-style: solid;
}

.upload-area.border-danger {
    border-color: #dc3545;
}

/* ================================================================
   QR CODE PREVIEW — Sprint 3
   ================================================================ */

.qr-preview {
    display: inline-block;
    transition: transform 0.15s ease;
}

.qr-preview:hover {
    transform: scale(1.03);
}

/* ================================================================
   FORMULÁRIOS — Melhorias visuais
   ================================================================ */

.form-label.fw-semibold {
    font-size: 0.85rem;
    color: #495057;
}

.form-text {
    font-size: 0.78rem;
}

/* Input group autofocus glow */
.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.12);
}

/* ================================================================
   DASHBOARD — Sprint 4: Gráficos, Indicadores, KPIs
   ================================================================ */

/* KPI cards com stat-icon centralizados */
.stat-card .stat-icon {
    width: 48px;
    height: 48px;
}

/* Legend dots para gráficos */
.dash-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

/* Progress bar animação ao entrar */
.progress-bar {
    transition: width 0.8s ease-in-out;
}

/* List-group hover para alertas e atividade */
.list-group-item.list-group-item-action:hover {
    background-color: rgba(13, 110, 253, 0.03);
}

/* Card header sem borda inferior (graficos) */
.card-header.border-bottom-0 {
    border-bottom: none !important;
}

/* Chart canvas responsivo */
canvas {
    width: 100% !important;
}

/* Animação suave de entrada nos cards do dashboard */
@keyframes dashFadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

.stat-card {
    animation: dashFadeIn 0.4s ease-out both;
}

.stat-card:nth-child(1) { animation-delay: 0.05s; }
.stat-card:nth-child(2) { animation-delay: 0.10s; }
.stat-card:nth-child(3) { animation-delay: 0.15s; }
.stat-card:nth-child(4) { animation-delay: 0.20s; }
.stat-card:nth-child(5) { animation-delay: 0.25s; }
.stat-card:nth-child(6) { animation-delay: 0.30s; }

/* Badge de vencimento urgente (pulsante) */
.badge.bg-danger {
    animation: pulse-danger 2s infinite;
}

@keyframes pulse-danger {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    50%      { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
}
