/* ===== CSS Variables ===== */
/* Identidade visual SistemaLaserSGE v1.0 (2026-10-21) — paleta oficial; ver docs/identidade-visual/ */
:root {
    --sge-azul: #00B4FF;          /* Azul SGE (destaque/laser) */
    --sge-azul-neon: #0D6EFD;     /* Azul Neon (ação primária) */
    --sge-azul-profundo: #0A1F3D;
    --sge-grafite: #0B1220;
    --sge-cinza-tecnico: #8E9AA7;
    --sge-off-white: #F5F7FA;
    --sge-azul-claro: #38BDF8;
    --sge-azul-escuro: #1E3A8A;
    --sge-prata: #C0C4CC;
    --font-interface: 'Inter', system-ui, -apple-system, 'Segoe UI', Arial, sans-serif;
    --font-marca: 'Orbitron', 'Rajdhani', 'Inter', Arial, sans-serif;

    --primary: var(--sge-azul-neon);
    --primary-dark: var(--sge-azul-escuro);
    --primary-light: #E8F4FF;
    --secondary: #64748b;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: var(--sge-azul);
    --dark: var(--sge-grafite);
    --light: var(--sge-off-white);
    --topbar-height: 60px;
    --card-shadow: 0 1px 3px rgba(11,18,32,.10), 0 1px 2px rgba(11,18,32,.06);
    --card-radius: 12px;
    --transition: 0.25s ease;
}

/* ===== Base ===== */
*, *::before, *::after { box-sizing: border-box; }
body {
    font-family: var(--font-interface);
    background: var(--sge-off-white);
    color: #334155;
    margin: 0;
    font-size: 0.9rem;
    overflow-x: hidden;
}
a { text-decoration: none; color: var(--primary); }
a:hover { color: var(--primary-dark); }

/* ===== Layout ===== */
.app-shell {
    padding-top: var(--topbar-height);
}
.wrapper {
    min-height: 100vh;
}
.main-content {
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - var(--topbar-height));
}

/* ===== Top Nav (Menu Superior) ===== */
.topnav {
    min-height: var(--topbar-height);
    background: linear-gradient(90deg, var(--sge-grafite) 0%, var(--sge-azul-profundo) 100%);
    border-bottom: 1px solid rgba(0,180,255,0.35);
    box-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 12px rgba(0,180,255,0.12);
}
.topnav .navbar-brand {
    font-weight: 700;
    letter-spacing: 0.01em;
}
/* O ícone oficial tem placa branca: exibido como "tile" de aplicativo */
.brand-sge-icone {
    object-fit: contain;
    background: #fff;
    border-radius: 8px;
    padding: 2px;
    box-shadow: 0 0 0 1px rgba(0,180,255,0.55), 0 0 12px rgba(0,180,255,0.35);
}
.brand-sge-nome {
    font-family: var(--font-marca);
    font-weight: 700;
    font-size: 1.02rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #fff;
}
.brand-sge-destaque { color: var(--sge-azul); }
@media (max-width: 575.98px) {
    .brand-sge-nome { font-size: 0.8rem; letter-spacing: 0.02em; }
    .brand-sge-icone { width: 28px; height: 28px; }
}
.topnav .nav-link.active,
.topnav .nav-link.show {
    color: #fff;
    box-shadow: inset 0 -2px 0 var(--sge-azul);
}
.topnav .nav-link {
    font-weight: 600;
}
.topnav .dropdown-menu {
    border-radius: 12px;
    border: 1px solid rgba(226, 232, 240, 0.9);
    box-shadow: 0 18px 45px rgba(15, 23, 42, 0.18);
    padding: 0.4rem;
}
.topnav .dropdown-item {
    border-radius: 10px;
    padding: 0.55rem 0.75rem;
    font-weight: 600;
}
.topnav .dropdown-item.active,
.topnav .dropdown-item:active {
    background: var(--primary);
}

@media (min-width: 992px) {
    .topnav .dropdown:hover > .dropdown-menu {
        display: block;
    }
    .topnav .dropdown-menu {
        margin-top: 0;
    }
}

/* ===== Content Area ===== */
.content-area {
    padding: 1.5rem;
    flex: 1;
    overflow-x: hidden;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
}

/* ===== Page Title Bar ===== */
.page-title-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}
.page-title {
    font-family: var(--font-marca);
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--sge-azul-profundo);
    margin: 0;
}
.page-title i { color: var(--sge-azul-neon); }

/* Shared page/form patterns */
.form-card {
    width: 100%;
}
.form-card-sm { max-width: 520px; }
.form-card-md { max-width: 640px; }
.form-card-lg { max-width: 760px; }
.form-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 0.35rem;
}

/* ===== Form view mode ===== */
.form-control-readonly {
    background-color: #f1f5f9 !important;
    border-color: #e2e8f0 !important;
    box-shadow: none !important;
    cursor: default;
}

.form-view-mode input, .form-view-mode select, .form-view-mode textarea {
    background-color: #f1f5f9;
    border-color: #e2e8f0;
}

.form-view-mode input:focus, .form-view-mode select:focus, .form-view-mode textarea:focus {
    box-shadow: none;
}

.company-logo-preview {
    width: 72px;
    height: 72px;
    object-fit: contain;
}
.company-logo-fallback {
    width: 72px;
    height: 72px;
}

/* ===== Cards ===== */
.card {
    border: 1px solid #e2e8f0;
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);
    background: #fff;
}
.card-header {
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    padding: 1rem 1.25rem;
    border-radius: var(--card-radius) var(--card-radius) 0 0;
}
.card-title { font-weight: 600; color: #0f172a; font-size: 0.95rem; }
.card-body { padding: 1.25rem; }

/* ===== Stat Cards ===== */
.stat-card {
    background: #fff;
    border-radius: var(--card-radius);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    box-shadow: var(--card-shadow);
    border: 1px solid #e2e8f0;
    position: relative;
    overflow: hidden;
}
.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    border-radius: var(--card-radius) 0 0 var(--card-radius);
}
.stat-card-primary::before { background: var(--primary); }
.stat-card-success::before { background: var(--success); }
.stat-card-warning::before { background: var(--warning); }
.stat-card-danger::before { background: var(--danger); }
.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    align-self: flex-start;
}
.stat-card-primary .stat-icon { background: var(--primary-light); color: var(--primary); }
.stat-card-success .stat-icon { background: #ecfdf5; color: var(--success); }
.stat-card-warning .stat-icon { background: #fffbeb; color: var(--warning); }
.stat-card-danger .stat-icon { background: #fef2f2; color: var(--danger); }
.stat-value { font-size: 1.6rem; font-weight: 700; color: #0f172a; line-height: 1; }
.stat-label { font-size: 0.8rem; color: var(--secondary); margin-top: 2px; }
.stat-link {
    font-size: 0.75rem;
    color: var(--secondary);
    margin-top: auto;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}
.stat-link:hover { color: var(--primary); }

/* ===== Tables ===== */
.table th {
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--secondary);
    border-bottom: 2px solid #e2e8f0;
}
.table td { vertical-align: middle; font-size: 0.875rem; }
.table-hover tbody tr:hover { background: #f8fafc; }
.table > :not(caption) > * > * { padding: 0.6rem 0.75rem; }

/* DataTables override */
div.dataTables_wrapper div.dataTables_filter input { border-radius: 6px; border: 1px solid #e2e8f0; }
div.dataTables_wrapper div.dataTables_length select { border-radius: 6px; border: 1px solid #e2e8f0; }
.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: var(--primary) !important;
    color: #fff !important;
    border-radius: 6px;
    border: none !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: var(--primary-light) !important;
    color: var(--primary) !important;
    border: none !important;
}

/* ===== Forms ===== */
.form-label {
    font-size: 0.85rem;
    font-weight: 500;
    color: #374151;
    margin-bottom: 0.35rem;
}
.form-control, .form-select {
    border-color: #d1d5db;
    border-radius: 8px;
    font-size: 0.875rem;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(13,110,253,0.15);
}
.input-group-text {
    background: #f8fafc;
    border-color: #d1d5db;
    font-size: 0.875rem;
}

/* ===== Buttons ===== */
.btn {
    border-radius: 10px;
    font-size: 0.875rem;
    font-weight: 600;
    border-width: 1px;
    transition: all var(--transition);
}
.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-color: rgba(147, 197, 253, 0.35);
    box-shadow: 0 6px 14px rgba(13,110,253,0.22);
}
.btn-primary:hover {
    background: linear-gradient(135deg, #0b5ed7 0%, var(--sge-azul-escuro) 100%);
    border-color: rgba(147, 197, 253, 0.5);
    transform: translateY(-1px);
    box-shadow: 0 10px 18px rgba(13,110,253,0.28);
}
.btn-outline-primary,
.btn-outline-secondary,
.btn-outline-success,
.btn-outline-warning,
.btn-outline-info,
.btn-outline-danger {
    background: rgba(255,255,255,0.84);
}
.btn-outline-primary:hover,
.btn-outline-secondary:hover,
.btn-outline-success:hover,
.btn-outline-warning:hover,
.btn-outline-info:hover,
.btn-outline-danger:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 14px rgba(15,23,42,0.12);
}
.btn-outline-secondary {
    border-color: #cbd5e1;
    color: #334155;
}
.btn-outline-secondary:hover {
    border-color: #94a3b8;
    background: #f8fafc;
    color: #1e293b;
}
.btn:disabled,
.btn.disabled {
    opacity: 0.6;
    transform: none !important;
    box-shadow: none !important;
}
.btn-sm { padding: 0.32rem 0.7rem; font-size: 0.8rem; border-radius: 8px; }
.btn-group-sm .btn { border-radius: 8px; }

/* ===== Badges ===== */
.badge { font-weight: 500; letter-spacing: 0.02em; }

/* ===== Alerts ===== */
.alert {
    border-radius: var(--card-radius);
    border: none;
    font-size: 0.875rem;
}

/* ===== Modal ===== */
.modal-content { border-radius: var(--card-radius); border: none; box-shadow: 0 20px 40px rgba(0,0,0,0.15); }
.modal-header { border-bottom: 1px solid #e2e8f0; padding: 1.25rem; }
.modal-footer { border-top: 1px solid #e2e8f0; padding: 1rem 1.25rem; }

/* ===== Log Viewer ===== */
.log-list {
    max-height: 520px;
    overflow-y: auto;
    padding-right: 4px;
}
.log-list-item {
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    margin-bottom: 0.75rem;
    transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}
.log-list-item:last-child { margin-bottom: 0; }
.log-list-item.active {
    border-color: var(--primary);
    box-shadow: 0 12px 30px rgba(13,110,253,0.18);
    transform: translateY(-2px);
}
.log-list-item .tiny { font-size: 0.7rem; }
.log-viewer-meta {
    border: 1px dashed #cbd5f5;
    border-radius: 10px;
    padding: 0.85rem 1rem;
    background: #f8fafc;
}
.log-raw {
    background: #0f172a;
    color: #f8fafc;
    border-radius: 12px;
    padding: 1rem 1.25rem;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.85rem;
    max-height: 420px;
    min-height: 220px;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
}
.log-cell-payload {
    background: #010a1f;
    color: #fef3c7;
    border-radius: 8px;
    padding: 0.5rem 0.75rem;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.75rem;
    max-height: 180px;
    overflow: auto;
    margin: 0;
}
.log-cell-payload::-webkit-scrollbar,
.log-raw::-webkit-scrollbar,
.log-list::-webkit-scrollbar {
    width: 6px;
}
.log-cell-payload::-webkit-scrollbar-thumb,
.log-raw::-webkit-scrollbar-thumb,
.log-list::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
    border-radius: 3px;
}
.log-cell-payload::-webkit-scrollbar-track,
.log-raw::-webkit-scrollbar-track,
.log-list::-webkit-scrollbar-track {
    background: transparent;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .dt-table th,
    .dt-table td,
    .table th,
    .table td {
        font-size: 0.78rem;
        white-space: nowrap;
    }
    .btn,
    .btn-sm {
        min-height: 38px;
    }
}

@media (max-width: 575.98px) {
    .content-area { padding: 1rem; }
    .page-title { font-size: 1.2rem; }
    .page-title-bar {
        align-items: flex-start;
    }
    .stat-value { font-size: 1.3rem; }
    .form-actions .btn {
        flex: 1 1 calc(50% - 0.5rem);
    }
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #f1f5f9; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ===== Loading spinner ===== */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255,255,255,0.8);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ===== Money input hint ===== */
.money-input { text-align: right; }

/* ===== Sticky header table ===== */
.table-responsive { border-radius: 0 0 var(--card-radius) var(--card-radius); }

/* ===== Custom select ===== */
.form-select { background-size: 14px; }

