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

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #16a34a;
    --warning: #d97706;
    --danger: #dc2626;
    --info: #0891b2;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-500: #6b7280;
    --gray-700: #374151;
    --gray-900: #111827;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--gray-50);
    color: var(--gray-900);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* === Navbar === */
.navbar {
    background: white;
    border-bottom: 1px solid var(--gray-200);
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    height: 56px;
    gap: 2rem;
    box-shadow: var(--shadow);
}
.nav-brand a { font-weight: 700; color: var(--primary); text-decoration: none; font-size: 1.1rem; }
.nav-links { display: flex; gap: 1rem; flex: 1; }
.nav-links a { color: var(--gray-700); text-decoration: none; padding: 0.25rem 0.5rem; border-radius: var(--radius); font-size: 0.9rem; }
.nav-links a:hover { background: var(--gray-100); color: var(--primary); }
.nav-user { display: flex; align-items: center; gap: 0.75rem; font-size: 0.9rem; }

/* === Container === */
.container { max-width: 1200px; margin: 0 auto; padding: 1.5rem; flex: 1; width: 100%; }

/* === Cards === */
.card { background: white; border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.5rem; margin-bottom: 1rem; }
.card-header { font-size: 1.1rem; font-weight: 600; margin-bottom: 1rem; padding-bottom: 0.75rem; border-bottom: 1px solid var(--gray-200); }

/* === Dashboard Grid === */
.dashboard-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card { background: white; border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); text-align: center; }
.stat-card .stat-value { font-size: 2rem; font-weight: 700; color: var(--primary); }
.stat-card .stat-label { font-size: 0.85rem; color: var(--gray-500); margin-top: 0.25rem; }

/* === Badges === */
.badge {
    display: inline-block; padding: 0.2rem 0.6rem; border-radius: 9999px;
    font-size: 0.75rem; font-weight: 600; text-transform: uppercase;
}
.badge-cliente { background: #dbeafe; color: #1e40af; }
.badge-logistica { background: #fef3c7; color: #92400e; }
.badge-financeiro { background: #d1fae5; color: #065f46; }
.badge-admin { background: #fce7f3; color: #9d174d; }

/* Status badges */
.badge-aberta { background: #dbeafe; color: #1e40af; }
.badge-em_analise { background: #fef3c7; color: #92400e; }
.badge-aguardando_nf_devolucao { background: #fed7aa; color: #9a3412; }
.badge-nf_enviada { background: #e0e7ff; color: #3730a3; }
.badge-envio_confirmado { background: #cffafe; color: #155e75; }
.badge-aprovada { background: #d1fae5; color: #065f46; }
.badge-em_reembolso { background: #ede9fe; color: #5b21b6; }
.badge-concluida { background: #d1fae5; color: #065f46; }
.badge-recusada { background: #fee2e2; color: #991b1b; }
.badge-cancelada { background: var(--gray-200); color: var(--gray-700); }

/* === Buttons === */
.btn {
    display: inline-flex; align-items: center; gap: 0.5rem;
    padding: 0.5rem 1rem; border-radius: var(--radius); border: none;
    font-size: 0.9rem; font-weight: 500; cursor: pointer;
    text-decoration: none; transition: all 0.15s;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { opacity: 0.9; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { opacity: 0.9; }
.btn-warning { background: var(--warning); color: white; }
.btn-outline { background: transparent; border: 1px solid var(--gray-300); color: var(--gray-700); }
.btn-outline:hover { background: var(--gray-100); }
.btn-sm { padding: 0.25rem 0.75rem; font-size: 0.8rem; }
.btn-block { width: 100%; justify-content: center; }

/* === Forms === */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-weight: 500; margin-bottom: 0.35rem; font-size: 0.9rem; color: var(--gray-700); }
.form-control {
    width: 100%; padding: 0.5rem 0.75rem; border: 1px solid var(--gray-300);
    border-radius: var(--radius); font-size: 0.9rem; transition: border-color 0.15s;
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }
select.form-control { appearance: auto; }
textarea.form-control { resize: vertical; min-height: 80px; }

/* === Tables === */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { padding: 0.75rem; text-align: left; border-bottom: 1px solid var(--gray-200); }
th { background: var(--gray-50); font-weight: 600; color: var(--gray-700); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; }
tr:hover { background: var(--gray-50); }

/* === Alerts === */
.alerts { margin-bottom: 1rem; }
.alert { padding: 0.75rem 1rem; border-radius: var(--radius); margin-bottom: 0.5rem; display: flex; justify-content: space-between; align-items: center; }
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.alert-info { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }
.alert-close { background: none; border: none; font-size: 1.2rem; cursor: pointer; color: inherit; opacity: 0.7; }

/* === Login === */
.login-wrapper {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%);
}
.login-card { background: white; border-radius: 12px; padding: 2.5rem; width: 100%; max-width: 400px; box-shadow: var(--shadow-md); }
.login-card h1 { text-align: center; margin-bottom: 0.5rem; color: var(--gray-900); }
.login-card p { text-align: center; color: var(--gray-500); margin-bottom: 1.5rem; font-size: 0.9rem; }

/* === Timeline (histórico) === */
.timeline { position: relative; padding-left: 2rem; }
.timeline::before { content: ''; position: absolute; left: 0.5rem; top: 0; bottom: 0; width: 2px; background: var(--gray-200); }
.timeline-item { position: relative; margin-bottom: 1.5rem; }
.timeline-item::before {
    content: ''; position: absolute; left: -1.65rem; top: 0.25rem;
    width: 10px; height: 10px; border-radius: 50%; background: var(--primary); border: 2px solid white;
}
.timeline-item .time { font-size: 0.8rem; color: var(--gray-500); }
.timeline-item .event { font-weight: 500; }
.timeline-item .detail { font-size: 0.85rem; color: var(--gray-700); margin-top: 0.25rem; }

/* === Pagination === */
.pagination { display: flex; justify-content: center; gap: 0.25rem; margin-top: 1.5rem; }
.pagination a, .pagination span {
    padding: 0.4rem 0.8rem; border: 1px solid var(--gray-300); border-radius: var(--radius);
    text-decoration: none; color: var(--gray-700); font-size: 0.85rem;
}
.pagination a:hover { background: var(--gray-100); }
.pagination .active { background: var(--primary); color: white; border-color: var(--primary); }

/* === Utilities === */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--gray-500); }
.text-sm { font-size: 0.85rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.hidden { display: none; }

/* === Responsive === */
@media (max-width: 768px) {
    .navbar { flex-wrap: wrap; height: auto; padding: 0.75rem; }
    .nav-links { order: 3; width: 100%; overflow-x: auto; }
    .dashboard-grid { grid-template-columns: repeat(2, 1fr); }
    .container { padding: 1rem; }
}

/* === HTMX loading indicator === */
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator { display: inline-block; }
.spinner { width: 1rem; height: 1rem; border: 2px solid var(--gray-200); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* === File upload === */
.file-upload { border: 2px dashed var(--gray-300); border-radius: var(--radius); padding: 2rem; text-align: center; cursor: pointer; transition: border-color 0.15s; }
.file-upload:hover { border-color: var(--primary); }
.file-upload input[type="file"] { display: none; }
.file-list { margin-top: 0.5rem; }
.file-item { display: flex; justify-content: space-between; align-items: center; padding: 0.5rem; background: var(--gray-50); border-radius: var(--radius); margin-bottom: 0.25rem; font-size: 0.85rem; }
