/* ============================================================
   SISConvenção — Estilos Globais
   Design System, Variáveis e Utilitários
   ============================================================ */

:root {
    /* Cores — Paleta Principal (Azul institucional e neutros) */
    --color-primary: #1d4ed8;
    --color-primary-hover: #1e3a8a;
    --color-primary-light: #eff6ff;

    --color-secondary: #475569;
    --color-secondary-hover: #334155;

    --color-success: #15803d;
    --color-success-bg: #f0fdf4;

    --color-danger: #b91c1c;
    --color-danger-bg: #fef2f2;

    --color-warning: #b45309;
    --color-warning-bg: #fffbeb;

    --color-info: #0369a1;
    --color-info-bg: #f0f9ff;

    --color-dark: #0f172a;
    --color-dark-hover: #1e293b;

    /* Tons de cinza */
    --color-gray-50: #f8fafc;
    --color-gray-100: #f1f5f9;
    --color-gray-200: #e2e8f0;
    --color-gray-300: #cbd5e1;
    --color-gray-400: #94a3b8;
    --color-gray-500: #64748b;
    --color-gray-600: #475569;
    --color-gray-700: #334155;
    --color-gray-800: #1e293b;
    --color-gray-900: #0f172a;

    --color-bg: #f8fafc;
    --color-surface: #ffffff;
    --color-border: #e2e8f0;

    --text-main: #334155;
    --text-muted: #64748b;
    --text-light: #94a3b8;
    --text-inverse: #ffffff;

    /* Sombras (Glassmorphism sutil) */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-inner: inset 0 2px 4px 0 rgb(0 0 0 / 0.05);

    /* Raios de borda */
    --radius-sm: 0.25rem;
    --radius-md: 0.375rem;
    --radius-lg: 0.5rem;
    --radius-xl: 0.75rem;
    --radius-full: 9999px;

    /* Fontes */
    --font-family: 'Inter', system-ui, -apple-system, sans-serif;
    
    /* Transições */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: var(--font-family);
    background-color: var(--color-bg);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--color-primary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--color-primary-hover);
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

ul {
    list-style: none;
}

/* ============================================================
   Tipografia
   ============================================================ */
h1, h2, h3, h4, h5, h6 {
    color: var(--color-dark);
    font-weight: 600;
    line-height: 1.2;
    margin-bottom: 0.5em;
}

h1 { font-size: 2.25rem; }
h2 { font-size: 1.875rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }

/* ============================================================
   Forms & Inputs
   ============================================================ */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--color-gray-700);
    font-size: 0.875rem;
}

.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 0.625rem 0.875rem;
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--text-main);
    background-color: var(--color-surface);
    background-clip: padding-box;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    font-family: var(--font-family);
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-light);
}

.form-input::placeholder, .form-textarea::placeholder {
    color: var(--text-light);
}

.input-password-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-password-wrapper .form-input {
    padding-right: 2.5rem;
}

.btn-show-pass {
    position: absolute;
    right: 0.75rem;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.btn-show-pass:hover {
    color: var(--color-primary);
}

/* ============================================================
   Botões
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-weight: 500;
    text-align: center;
    vertical-align: middle;
    cursor: pointer;
    user-select: none;
    border: 1px solid transparent;
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    line-height: 1.5;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    font-family: var(--font-family);
}

.btn i {
    font-size: 1.125rem;
}

.btn-block {
    display: flex;
    width: 100%;
}

.btn-primary {
    color: var(--text-inverse);
    background-color: var(--color-primary);
    border-color: var(--color-primary);
}

.btn-primary:hover {
    background-color: var(--color-primary-hover);
    border-color: var(--color-primary-hover);
    color: var(--text-inverse);
}

.btn-secondary:hover {
    background-color: var(--color-secondary-hover);
    border-color: var(--color-secondary-hover);
    color: var(--text-inverse);
}

.btn-outline {
    color: var(--text-main);
    background-color: transparent;
    border-color: var(--color-border);
}

.btn-outline:hover {
    background-color: var(--color-gray-100);
    border-color: var(--color-gray-300);
    color: var(--color-primary);
}

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

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

.spin {
    animation: spin 1s linear infinite;
}

/* ============================================================
   Página de Autenticação (Layout)
   ============================================================ */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background-color: var(--color-gray-100);
}

.auth-wrapper {
    width: 100%;
    max-width: 400px;
    padding: 1rem;
}

.auth-card {
    background-color: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl); /* Usando uma sombra mais forte pra destacar */
    box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    padding: 2.5rem 2rem;
}

.auth-header {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3.5rem;
    height: 3.5rem;
    background-color: var(--color-primary-light);
    color: var(--color-primary);
    border-radius: var(--radius-full);
    margin-bottom: 1rem;
    font-size: 1.75rem;
}

.auth-title {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
}

.auth-subtitle {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.auth-footer {
    text-align: center;
    margin-top: 1.5rem;
    color: var(--text-light);
    font-size: 0.75rem;
}

.auth-links {
    margin-top: 1.25rem;
    text-align: center;
}

.link-forgot {
    font-size: 0.875rem;
}

/* ============================================================
   Alertas e Badges
   ============================================================ */
.alert {
    position: relative;
    padding: 0.75rem 1rem;
    margin-bottom: 1.25rem;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
}

.alert i {
    font-size: 1.25rem;
}

.alert-success {
    color: var(--color-success);
    background-color: var(--color-success-bg);
    border-color: #bbf7d0;
}

.alert-danger, .alert-error {
    color: var(--color-danger);
    background-color: var(--color-danger-bg);
    border-color: #fecaca;
}

.alert-warning {
    color: var(--color-warning);
    background-color: var(--color-warning-bg);
    border-color: #fde68a;
}

.alert-info {
    color: var(--color-info);
    background-color: var(--color-info-bg);
    border-color: #bae6fd;
}

.badge {
    display: inline-block;
    padding: 0.25em 0.5em;
    font-size: 75%;
    font-weight: 600;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
    vertical-align: baseline;
    border-radius: var(--radius-sm);
}

.badge-success { background-color: var(--color-success-bg); color: var(--color-success); border: 1px solid #bbf7d0;}
.badge-danger { background-color: var(--color-danger-bg); color: var(--color-danger); border: 1px solid #fecaca;}
.badge-warning { background-color: var(--color-warning-bg); color: var(--color-warning); border: 1px solid #fde68a;}
.badge-info { background-color: var(--color-info-bg); color: var(--color-info); border: 1px solid #bae6fd;}
.badge-secondary { background-color: var(--color-gray-100); color: var(--color-gray-700); border: 1px solid var(--color-gray-300);}
.badge-primary { background-color: var(--color-primary-light); color: var(--color-primary); border: 1px solid #bfdbfe;}
.badge-dark { background-color: var(--color-gray-800); color: var(--color-gray-50); border: 1px solid var(--color-gray-900);}

/* ============================================================
   Main Layout (Dashboard, etc.)
   ============================================================ */
.app-body {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* --- Sidebar --- */
.sidebar {
    width: 250px;
    background-color: var(--color-dark);
    color: var(--color-gray-300);
    display: flex;
    flex-direction: column;
    transition: width var(--transition-fast);
    z-index: 1000;
}

.sidebar.collapsed {
    width: 64px;
}

.sidebar-header {
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    border-bottom: 1px solid var(--color-gray-800);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--color-primary-light);
    font-size: 1.25rem;
    font-weight: 700;
    overflow: hidden;
    white-space: nowrap;
}

.sidebar.collapsed .sidebar-brand {
    display: none;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--color-gray-400);
    cursor: pointer;
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-toggle:hover {
    color: var(--text-inverse);
}

.sidebar.collapsed .sidebar-toggle {
    transform: rotate(180deg);
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 0;
}

/* Custom Scrollbar for Sidebar */
.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}
.sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}
.sidebar-nav::-webkit-scrollbar-thumb {
    background: var(--color-gray-700);
    border-radius: var(--radius-full);
}

.nav-section {
    padding: 1rem 1.5rem 0.5rem;
}

.nav-section-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-gray-500);
    font-weight: 600;
}

.sidebar.collapsed .nav-section {
    display: none;
}

.nav-item {
    margin-bottom: 0.25rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    color: var(--color-gray-300);
    transition: all var(--transition-fast);
}

.nav-link:hover, .nav-link.active {
    background-color: var(--color-gray-800);
    color: var(--text-inverse);
}

.nav-link.active {
    border-left: 3px solid var(--color-primary);
    padding-left: calc(1.5rem - 3px);
}

.nav-icon {
    font-size: 1.25rem;
    min-width: 1.25rem;
}

.sidebar.collapsed .nav-link {
    padding: 0.75rem;
    justify-content: center;
}
.sidebar.collapsed .nav-link.active {
    padding-left: calc(0.75rem - 3px);
}

.sidebar.collapsed .nav-label {
    display: none;
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--color-gray-800);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    overflow: hidden;
}

.user-avatar {
    width: 2rem;
    height: 2rem;
    background-color: var(--color-primary);
    color: var(--text-inverse);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    min-width: 2rem;
}

.user-info {
    display: flex;
    flex-direction: column;
    white-space: nowrap;
}

.user-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-gray-100);
}

.user-role {
    font-size: 0.75rem;
    color: var(--color-gray-500);
}

.sidebar.collapsed .user-info {
    display: none;
}

.btn-logout {
    color: var(--color-gray-400);
    font-size: 1.25rem;
}

.btn-logout:hover {
    color: var(--color-danger);
}

.sidebar.collapsed .btn-logout {
    display: none;
}

/* --- Main Content Area --- */
.main-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--color-bg);
    overflow: hidden;
}

/* Topbar */
.topbar {
    height: 64px;
    background-color: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    z-index: 100;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.topbar-menu-btn {
    display: none; /* Só mostra no mobile */
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-main);
    cursor: pointer;
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.breadcrumb a {
    color: var(--text-muted);
}
.breadcrumb a:hover {
    color: var(--color-primary);
}
.breadcrumb .ph-caret-right {
    font-size: 0.75rem;
}
.breadcrumb-current {
    color: var(--text-main);
    font-weight: 500;
}

.topbar-right {
    position: relative;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.topbar-icon-btn {
    background: none;
    border: none;
    position: relative;
    font-size: 1.25rem;
    color: var(--text-main);
    cursor: pointer;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color var(--transition-fast);
}

.topbar-icon-btn:hover {
    background-color: var(--color-gray-100);
}

.notif-badge {
    position: absolute;
    top: 0.25rem;
    right: 0.25rem;
    background-color: var(--color-danger);
    color: var(--text-inverse);
    font-size: 0.65rem;
    font-weight: 700;
    min-width: 1rem;
    height: 1rem;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 0.25rem;
    border: 2px solid var(--color-surface);
}

.notif-dropdown {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    width: 320px;
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    overflow: hidden;
}

.notif-header {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.875rem;
    font-weight: 600;
}

.notif-header a {
    font-size: 0.75rem;
    font-weight: 400;
}

.notif-list {
    max-height: 300px;
    overflow-y: auto;
}

.notif-empty {
    padding: 1rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Flash Messages */
.flash-container {
    padding: 1rem 1.5rem 0;
}
.flash-msg {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    position: relative;
    animation: slideInDown 300ms ease-out;
}
@keyframes slideInDown {
    from { transform: translateY(-100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.flash-close {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    margin-left: auto;
    font-size: 1rem;
    opacity: 0.7;
}
.flash-close:hover { opacity: 1; }

.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

.main-footer {
    padding: 1rem 1.5rem;
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    background-color: var(--color-surface);
    border-top: 1px solid var(--color-border);
}

/* ============================================================
   Cards
   ============================================================ */
.card {
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.5rem;
}

.card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-body {
    padding: 1.5rem;
}

/* ============================================================
   Responsividade
   ============================================================ */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -250px;
        height: 100vh;
    }
    .sidebar.mobile-open {
        left: 0;
        box-shadow: var(--shadow-xl);
    }
    .topbar-menu-btn {
        display: block;
    }
    .sidebar-toggle {
        display: none; /* Esconde o botão de collapse no mobile, só usa o toggle do topbar */
    }
    .main-wrapper {
        width: 100%;
    }
}
/* ============================================================
   Ajustes Fase 2 — Dashboards, Cards e Grids
   ============================================================ */

/* Compatibilidade de Classes (Alias) */
.form-control {
    width: 100%;
    padding: 0.625rem 0.875rem;
    font-size: 0.875rem;
    color: var(--text-main);
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}
.form-control:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-light);
}

/* Header de Ações das Páginas */
.header-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-dark);
    margin-bottom: 0.25rem;
}

.section-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--color-gray-800);
    margin: 1.5rem 0 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--color-gray-100);
}

/* Dashboard Stat Cards */
.dashboard-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    padding: 1.5rem;
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-icon {
    width: 3.5rem;
    height: 3.5rem;
    border-radius: var(--radius-lg);
    background-color: var(--color-primary-light);
    color: var(--color-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    flex-shrink: 0;
}

.stat-details {
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-dark);
}

/* Grid Utilitário para Formulários */
.form-grid {
    display: grid;
    gap: 1rem;
}

/* Helpers de espaçamento */
.mt-3 { margin-top: 1rem !important; }
.mt-4 { margin-top: 1.5rem !important; }
.mb-3 { margin-bottom: 1rem !important; }
.mb-4 { margin-bottom: 1.5rem !important; }
.text-right { text-align: right !important; }
.text-center { text-align: center !important; }
.text-gray { color: var(--text-muted) !important; }
.text-primary { color: var(--color-primary) !important; }
.text-success { color: var(--color-success) !important; }
.text-sm { font-size: 0.875rem !important; }

/* Modal Improvements */
.modal {
    display: flex; /* Override via JS inline */
    animation: fadeIn 200ms ease-out;
}

.modal-content {
    animation: zoomIn 250ms cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes zoomIn {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* Estilos de Busca/Filtro */
.search-form {
    background: var(--color-gray-50);
    padding: 1rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
}
