/* ═══════════════════════════════════════════════════════════
   SISTEMA DE PRECATÓRIOS — Design System
   ═══════════════════════════════════════════════════════════ */

/* ─── Variáveis CSS ─── */
:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #dbeafe;
    --primary-dark: #1e40af;
    --secondary: #475569;
    --success: #16a34a;
    --success-light: #dcfce7;
    --danger: #dc2626;
    --danger-light: #fef2f2;
    --warning: #d97706;
    --warning-light: #fef3c7;
    --info: #0891b2;
    --info-light: #ecfeff;

    --bg-body: #f1f5f9;
    --bg-card: #ffffff;
    --bg-sidebar: #0f172a;
    --bg-sidebar-hover: #1e293b;

    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --text-sidebar: #cbd5e1;
    --text-sidebar-active: #ffffff;

    --border-color: #e2e8f0;
    --border-radius: 0.75rem;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px 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);

    --sidebar-width: 260px;
    --transition: all 0.2s ease;
}

/* ─── Reset & Base ─── */
* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-primary);
    margin: 0;
    padding: 0;
    min-height: 100vh;
}

/* ─── Links ─── */
a {
    color: var(--primary);
    text-decoration: none;
    transition: var(--transition);
}
a:hover {
    color: var(--primary-hover);
}

/* ═══════════════════════════════════════════════════════════
   LOGIN PAGE
   ═══════════════════════════════════════════════════════════ */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 50%, #2563eb 100%);
    padding: 1rem;
}

.login-card {
    background: var(--bg-card);
    border-radius: 1rem;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
    animation: slideUp 0.5s ease-out;
}

.login-logo {
    text-align: center;
    margin-bottom: 2rem;
}
.login-logo .icon {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--primary), #7c3aed);
    border-radius: 1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
}
.login-logo .icon svg {
    width: 32px;
    height: 32px;
    color: white;
}
.login-logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
    color: var(--text-primary);
}
.login-logo p {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin: 0.25rem 0 0;
}

/* ═══════════════════════════════════════════════════════════
   LAYOUT — Sidebar + Content
   ═══════════════════════════════════════════════════════════ */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ─── Sidebar ─── */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    color: var(--text-sidebar);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: transform 0.3s ease;
    overflow-y: auto;
}

.sidebar-brand {
    padding: 1.5rem 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.sidebar-brand .brand-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary), #7c3aed);
    border-radius: 0.625rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.sidebar-brand .brand-icon svg {
    width: 20px;
    height: 20px;
    color: white;
}
.sidebar-brand .brand-text {
    font-weight: 700;
    font-size: 1rem;
    color: white;
    line-height: 1.2;
}
.sidebar-brand .brand-sub {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.sidebar-nav {
    padding: 1rem 0;
    flex: 1;
}

.sidebar-section {
    padding: 0 0.75rem;
    margin-bottom: 0.5rem;
}
.sidebar-section-title {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    padding: 0.75rem 0.75rem 0.375rem;
    font-weight: 600;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.75rem;
    border-radius: 0.5rem;
    color: var(--text-sidebar);
    font-size: 0.875rem;
    font-weight: 500;
    transition: var(--transition);
    text-decoration: none;
}
.sidebar-link:hover {
    background: var(--bg-sidebar-hover);
    color: white;
}
.sidebar-link.active {
    background: var(--primary);
    color: white;
}
.sidebar-link svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    opacity: 0.7;
}
.sidebar-link.active svg,
.sidebar-link:hover svg {
    opacity: 1;
}

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid rgba(255,255,255,0.08);
}
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}
.sidebar-user-avatar {
    width: 36px;
    height: 36px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: white;
    font-size: 0.875rem;
    flex-shrink: 0;
}
.sidebar-user-info .user-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: white;
}
.sidebar-user-info .user-role {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

/* ─── Main Content ─── */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 0;
    min-height: 100vh;
}

.topbar {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}
.topbar-title {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-primary);
}
.topbar-breadcrumb {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.content-area {
    padding: 1.5rem;
}

/* ─── Mobile Toggle ─── */
.sidebar-toggle {
    display: none;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 0.5rem;
    cursor: pointer;
}

/* ═══════════════════════════════════════════════════════════
   COMPONENTS
   ═══════════════════════════════════════════════════════════ */

/* ─── Cards ─── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}
.card:hover {
    box-shadow: var(--shadow);
}

.stat-card {
    padding: 1.25rem;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
}
.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.stat-card .stat-icon svg {
    width: 24px;
    height: 24px;
}
.stat-card .stat-icon.blue { background: var(--primary-light); color: var(--primary); }
.stat-card .stat-icon.green { background: var(--success-light); color: var(--success); }
.stat-card .stat-icon.amber { background: var(--warning-light); color: var(--warning); }
.stat-card .stat-icon.red { background: var(--danger-light); color: var(--danger); }
.stat-card .stat-icon.cyan { background: var(--info-light); color: var(--info); }

.stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1;
    margin-bottom: 0.25rem;
}
.stat-card .stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* ─── Stats Grid ─── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

/* ─── Tables ─── */
.table-container {
    overflow-x: auto;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    background: var(--bg-card);
}

.table {
    margin-bottom: 0;
    font-size: 0.875rem;
}
.table thead th {
    background: #f8fafc;
    border-bottom: 2px solid var(--border-color);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.75rem 1rem;
    white-space: nowrap;
}
.table tbody td {
    padding: 0.75rem 1rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}
.table tbody tr:hover {
    background: #f8fafc;
}
.table tbody tr:last-child td {
    border-bottom: none;
}

/* ─── Badges ─── */
.badge-status {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.625rem;
    border-radius: 9999px;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}
.badge-active {
    background: var(--success-light);
    color: var(--success);
}
.badge-inactive {
    background: var(--danger-light);
    color: var(--danger);
}
.badge-admin {
    background: #ede9fe;
    color: #7c3aed;
}
.badge-user {
    background: var(--primary-light);
    color: var(--primary);
}

/* ─── Buttons ─── */
.btn {
    font-weight: 600;
    font-size: 0.875rem;
    border-radius: 0.5rem;
    padding: 0.5rem 1rem;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
}
.btn svg {
    width: 16px;
    height: 16px;
}
.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
}
.btn-primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
}

/* ─── Forms ─── */
.form-control, .form-select {
    border-radius: 0.5rem;
    border: 1px solid var(--border-color);
    font-size: 0.875rem;
    padding: 0.5rem 0.75rem;
    transition: var(--transition);
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
}
.form-label {
    font-weight: 600;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-bottom: 0.375rem;
}

/* ─── Filter Bar ─── */
.filter-bar {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
}

/* ─── Upload Zone ─── */
.upload-zone {
    border: 2px dashed var(--border-color);
    border-radius: var(--border-radius);
    padding: 3rem 2rem;
    text-align: center;
    background: #fafbfd;
    transition: var(--transition);
    cursor: pointer;
}
.upload-zone:hover,
.upload-zone.dragover {
    border-color: var(--primary);
    background: var(--primary-light);
}
.upload-zone .upload-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 1rem;
    background: var(--primary-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
}
.upload-zone .upload-icon svg {
    width: 32px;
    height: 32px;
}
.upload-zone h4 {
    font-weight: 700;
    margin-bottom: 0.25rem;
    color: var(--text-primary);
}
.upload-zone p {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin: 0;
}

/* ─── Detail Grid ─── */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 0;
}
.detail-item {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
}
.detail-item:last-child {
    border-bottom: none;
}
.detail-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 0.125rem;
}
.detail-value {
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--text-primary);
    word-break: break-word;
}
.detail-value.empty {
    color: var(--text-muted);
    font-style: italic;
}

/* ─── Section Card ─── */
.section-card {
    margin-bottom: 1.5rem;
}
.section-card .section-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.section-card .section-header h5 {
    margin: 0;
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--text-primary);
}
.section-card .section-header svg {
    width: 18px;
    height: 18px;
    color: var(--primary);
}

/* ─── Pagination ─── */
.pagination {
    margin: 1.5rem 0 0;
    justify-content: center;
}
.page-link {
    border-radius: 0.375rem;
    margin: 0 0.125rem;
    color: var(--text-secondary);
    border-color: var(--border-color);
    font-size: 0.875rem;
    font-weight: 500;
}
.page-link:hover {
    background: var(--primary-light);
    color: var(--primary);
    border-color: var(--primary-light);
}
.page-item.active .page-link {
    background: var(--primary);
    border-color: var(--primary);
}

/* ─── Alerts / Flash Messages ─── */
.alert {
    border-radius: 0.5rem;
    font-size: 0.875rem;
    border: none;
    font-weight: 500;
}

/* ─── Import Result ─── */
.import-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1rem;
}
.import-summary .summary-item {
    text-align: center;
    padding: 1rem;
    border-radius: 0.75rem;
}
.import-summary .summary-item .number {
    font-size: 2rem;
    font-weight: 800;
    line-height: 1;
}
.import-summary .summary-item .label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 0.25rem;
}

/* ─── Dashboard Lists ─── */
.count-list .count-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.625rem 0;
    border-bottom: 1px solid var(--border-color);
}
.count-list .count-item:last-child {
    border-bottom: none;
}
.count-list .count-item .count-name {
    font-size: 0.875rem;
    color: var(--text-primary);
    font-weight: 500;
}
.count-list .count-item .count-value {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--primary);
    background: var(--primary-light);
    padding: 0.125rem 0.625rem;
    border-radius: 9999px;
}

/* ═══════════════════════════════════════════════════════════
   ANIMATIONS
   ═══════════════════════════════════════════════════════════ */
@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.animate-fade {
    animation: fadeIn 0.3s ease-out;
}

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
    }
    .sidebar-toggle {
        display: block;
    }
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .content-area {
        padding: 1rem;
    }
    .detail-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    .login-card {
        padding: 1.5rem;
    }
    .import-summary {
        grid-template-columns: repeat(2, 1fr);
    }
}
