/* --- SISTEMA DE CORES E DESIGN SYSTEM --- */
:root {
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --primary-light: #eff6ff;
    
    --success: #10b981;
    --success-hover: #059669;
    --success-light: #ecfdf5;
    
    --warning: #f59e0b;
    --warning-hover: #d97706;
    --warning-light: #fffbeb;
    
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --danger-light: #fef2f2;
    
    --slate-50: #f8fafc;
    --slate-100: #f1f5f9;
    --slate-200: #e2e8f0;
    --slate-300: #cbd5e1;
    --slate-400: #94a3b8;
    --slate-500: #64748b;
    --slate-600: #475569;
    --slate-700: #334155;
    --slate-800: #1e293b;
    --slate-900: #0f172a;
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --font: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
}

/* --- RESET & LAYOUT GLOBAL --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font);
    background-color: var(--slate-50);
    color: var(--slate-800);
    overflow: hidden;
    height: 100vh;
    -webkit-font-smoothing: antialiased;
}

.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

/* --- BARRA LATERAL (SIDEBAR) --- */
.sidebar {
    width: 280px;
    background: linear-gradient(185deg, var(--slate-900) 0%, var(--slate-800) 100%);
    color: white;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--slate-700);
    flex-shrink: 0;
}

.sidebar-header {
    padding: 2rem 1.5rem;
    border-bottom: 1px solid var(--slate-700);
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    font-size: 1.8rem;
}

.sidebar-header h1 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(to right, #ffffff, #93c5fd);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    display: flex;
    flex-direction: column;
}

.badge-adm {
    font-size: 0.7rem;
    background-color: var(--primary);
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    width: max-content;
    margin-top: 4px;
    -webkit-text-fill-color: initial;
}

.sidebar-nav {
    flex: 1;
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sidebar-nav .nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 0.8rem 1rem;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--slate-300);
    font-size: 0.95rem;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: var(--transition);
}

.sidebar-nav .nav-item:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: white;
}

.sidebar-nav .nav-item.active {
    background-color: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.35);
}

.sidebar-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--slate-700);
    font-size: 0.8rem;
    color: var(--slate-400);
}

.sidebar-footer .version {
    display: block;
    margin-top: 4px;
    font-size: 0.75rem;
    color: var(--slate-500);
}

/* --- CONTEÚDO PRINCIPAL --- */
.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 2.2rem;
    background-color: var(--slate-100);
}

.tab-pane {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-pane.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.tab-header {
    margin-bottom: 2rem;
}

.tab-header h2 {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--slate-800);
    letter-spacing: -0.5px;
}

.tab-header .subtitle {
    font-size: 0.95rem;
    color: var(--slate-500);
    margin-top: 4px;
}

/* --- CARDS E CONTEÚDOS --- */
.card {
    background-color: white;
    border-radius: var(--radius-md);
    border: 1px solid var(--slate-200);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.5rem;
}

/* --- DASHBOARD --- */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.metric-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-left: 4px solid var(--primary);
    transition: var(--transition);
}

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

.metric-card.compact {
    padding: 1rem 1.2rem;
}

.metric-info {
    display: flex;
    flex-direction: column;
}

.metric-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--slate-400);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.metric-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--slate-800);
    margin-top: 4px;
    line-height: 1.1;
}

.metric-icon {
    font-size: 2rem;
    opacity: 0.85;
}

.secondary-metrics .metric-card {
    border-left: 4px solid var(--slate-300);
}

.secondary-metrics .metric-card:nth-child(1),
.secondary-metrics .metric-card:nth-child(2) {
    border-left-color: #f59e0b; /* Cão */
}

.secondary-metrics .metric-card:nth-child(3),
.secondary-metrics .metric-card:nth-child(4) {
    border-left-color: #10b981; /* Gato */
}

/* Dashboard Details Layout */
.dashboard-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.detail-panel h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--slate-700);
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--slate-100);
    padding-bottom: 0.5rem;
}

/* --- TABELAS SIMPLES --- */
.table-wrapper {
    overflow-x: auto;
    max-height: 350px;
}

.simple-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    text-align: left;
}

.simple-table th {
    background-color: var(--slate-50);
    color: var(--slate-500);
    font-weight: 600;
    padding: 0.75rem 1rem;
    border-bottom: 2px solid var(--slate-100);
    position: sticky;
    top: 0;
}

.simple-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--slate-100);
    color: var(--slate-600);
}

.simple-table tr:hover td {
    background-color: var(--slate-50);
}

/* --- ABA CONSULTA (BUSCA E FILTROS) --- */
.search-filter-card {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.search-row {
    display: flex;
    gap: 1rem;
}

.search-row input {
    flex: 1;
    padding: 0.8rem 1rem;
    font-size: 0.95rem;
    border: 1px solid var(--slate-200);
    border-radius: var(--radius-sm);
    outline: none;
    transition: var(--transition);
}

.search-row input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.filter-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.filter-group label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--slate-500);
    text-transform: uppercase;
}

.filter-group select {
    padding: 0.6rem;
    font-size: 0.9rem;
    border: 1px solid var(--slate-200);
    border-radius: var(--radius-sm);
    outline: none;
    background-color: var(--slate-50);
    cursor: pointer;
    transition: var(--transition);
}

.filter-group select:focus {
    border-color: var(--primary);
}

/* --- TABELA DE EXPLORAÇÃO AMPLA --- */
.data-explorer-card {
    padding: 0;
    overflow: hidden;
}

.explorer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.2rem 1.5rem;
    background-color: white;
    border-bottom: 1px solid var(--slate-200);
}

.results-count {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--slate-500);
}

.selection-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideDown 0.2s ease;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

#bulk-selected-text {
    font-size: 0.85rem;
    color: var(--primary-hover);
    font-weight: 600;
    margin-right: 8px;
}

.main-table-wrapper {
    overflow-x: auto;
    max-height: calc(100vh - 380px);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    text-align: left;
}

.data-table th {
    background-color: var(--slate-50);
    color: var(--slate-500);
    font-weight: 600;
    padding: 1rem;
    border-bottom: 2px solid var(--slate-200);
    position: sticky;
    top: 0;
    z-index: 10;
}

.data-table td {
    padding: 0.9rem 1rem;
    border-bottom: 1px solid var(--slate-200);
    color: var(--slate-700);
    vertical-align: middle;
}

.data-table tr.selected td {
    background-color: var(--primary-light) !important;
}

.data-table tr:hover td {
    background-color: var(--slate-50);
}

/* Expandable Detail View Row */
.details-row td {
    background-color: var(--slate-50) !important;
    padding: 0.5rem 1.5rem 1rem 1.5rem !important;
    border-bottom: 2px solid var(--slate-200);
}

.expanded-card {
    background: white;
    border: 1px solid var(--slate-200);
    border-radius: var(--radius-sm);
    padding: 1rem;
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);
}

.exp-section {
    flex: 1;
    min-width: 200px;
}

.exp-section h4 {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--slate-500);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px dashed var(--slate-200);
    padding-bottom: 4px;
}

.exp-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 6px 12px;
    font-size: 0.85rem;
}

.exp-label {
    color: var(--slate-400);
    font-weight: 500;
}

.exp-value {
    color: var(--slate-700);
    font-weight: 600;
    text-align: right;
}

/* --- BADGES E STATUS --- */
.badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-align: center;
}

.badge-concluido { background-color: var(--success-light); color: var(--success); }
.badge-ausente { background-color: var(--warning-light); color: var(--warning); }
.badge-recusado { background-color: var(--danger-light); color: var(--danger); }

/* --- BOTOES --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 0.7rem 1.2rem;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    transition: var(--transition);
}

.btn-primary {
    background-color: var(--primary);
    color: white;
}
.btn-primary:hover { background-color: var(--primary-hover); }

.btn-secondary {
    background-color: white;
    border-color: var(--slate-300);
    color: var(--slate-600);
}
.btn-secondary:hover {
    background-color: var(--slate-50);
    border-color: var(--slate-400);
}

.btn-success {
    background-color: var(--success);
    color: white;
}
.btn-success:hover { background-color: var(--success-hover); }

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

.btn-small {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
}

.btn-block {
    width: 100%;
}

.actions-cell {
    display: flex;
    gap: 6px;
}

.btn-action {
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid var(--slate-300);
    background-color: white;
    cursor: pointer;
    font-size: 0.8rem;
    transition: var(--transition);
}

.btn-action:hover {
    background-color: var(--slate-100);
}

.btn-edit-action { color: var(--primary); }
.btn-delete-action { color: var(--danger); }

/* --- IMPORTACAO --- */
.import-columns {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 1.5rem;
}

.drop-zone {
    border: 2px dashed var(--slate-300);
    border-radius: var(--radius-md);
    background-color: var(--slate-50);
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
}

.drop-zone:hover, .drop-zone.dragover {
    border-color: var(--primary);
    background-color: var(--primary-light);
}

.drop-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 12px;
}

.drop-zone p {
    font-size: 0.95rem;
    color: var(--slate-500);
    font-weight: 500;
}

.import-separator {
    display: flex;
    align-items: center;
    text-align: center;
    color: var(--slate-400);
    font-size: 0.8rem;
    font-weight: 700;
    margin: 1.5rem 0;
}

.import-separator::before,
.import-separator::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid var(--slate-200);
}

.import-separator span {
    padding: 0 10px;
}

/* Console Logger */
.log-console {
    background-color: var(--slate-900);
    color: #38bdf8;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.85rem;
    padding: 1.2rem;
    border-radius: var(--radius-sm);
    height: 320px;
    overflow-y: auto;
    border: 1px solid var(--slate-800);
    box-shadow: inset 0 2px 8px rgba(0,0,0,0.5);
}

.log-console p {
    margin-bottom: 6px;
    line-height: 1.4;
}

.log-console .system-log { color: #a1a1aa; }
.log-console .success-log { color: #4ade80; }
.log-console .warning-log { color: #fbbf24; }
.log-console .error-log { color: #f87171; }

/* --- EXPORTACAO --- */
.export-options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1.5rem;
}

.export-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: space-between;
    height: 100%;
}

.export-card.accent-card {
    border: 2px solid var(--primary);
    background-color: var(--primary-light);
}

.card-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
}

.export-card h3 {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--slate-800);
    margin-bottom: 8px;
}

.export-card .description {
    font-size: 0.9rem;
    color: var(--slate-500);
    line-height: 1.5;
    margin-bottom: 1.5rem;
}

.form-group-row {
    display: flex;
    gap: 1rem;
    width: 100%;
    margin-bottom: 1rem;
}

.form-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.form-group label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--slate-500);
    text-transform: uppercase;
}

.form-group select,
.form-group input {
    padding: 0.65rem;
    font-size: 0.9rem;
    border: 1px solid var(--slate-200);
    border-radius: var(--radius-sm);
    outline: none;
    background-color: white;
}

/* --- MODAL --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease;
}

.modal-content {
    background-color: white;
    border-radius: var(--radius-md);
    width: 90%;
    max-width: 650px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    padding: 1.2rem 1.5rem;
    border-bottom: 1px solid var(--slate-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--slate-800);
}

.btn-close {
    background: transparent;
    border: none;
    font-size: 1.8rem;
    cursor: pointer;
    color: var(--slate-400);
    line-height: 1;
}

.btn-close:hover {
    color: var(--slate-600);
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding-top: 1.2rem;
    border-top: 1px solid var(--slate-200);
}

.gps-lock-banner {
    background-color: var(--primary-light);
    color: var(--primary-hover);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    margin-bottom: 1rem;
    border-left: 3px solid var(--primary);
}

/* --- TOAST --- */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background-color: var(--slate-900);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    z-index: 10000;
    font-size: 0.9rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    animation: slideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideIn {
    from { transform: translateY(12px) scale(0.95); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}

/* Helpers */
.hidden { display: none !important; }
.text-center { text-align: center; }
.text-muted { color: var(--slate-400); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }
.text-primary { color: var(--primary); }
.cursor-pointer { cursor: pointer; }
.py-5 { padding-top: 3rem; padding-bottom: 3rem; }

/* Custom toggle buttons for the Edit Form */
.toggle-group {
    display: flex;
    gap: 8px;
    width: 100%;
}

.btn-toggle {
    flex: 1;
    padding: 0.5rem;
    background-color: white;
    border: 1px solid var(--slate-300);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--slate-600);
    cursor: pointer;
    transition: var(--transition);
}

.btn-toggle.active {
    background-color: var(--primary);
    border-color: var(--primary);
    color: white;
}
