/**
 * PrestyBI - Design System
 * Estilo Premium para BI Financeiro
 */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
    --primary: #6366f1;
    --primary-light: #818cf8;
    --primary-dark: #4f46e5;
    --secondary: #06b6d4;
    --accent: #f59e0b;
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #eab308;
    
    --font-primary: 'DM Sans', -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --radius: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.1);
}

[data-theme="dark"] {
    --bg-primary: #0c0a1d;
    --bg-secondary: #13112b;
    --bg-card: linear-gradient(145deg, #1a1735 0%, #13112b 100%);
    --bg-card-solid: #1a1735;
    --bg-hover: rgba(99, 102, 241, 0.08);
    --bg-input: #0c0a1d;
    --text-primary: #f1f5f9;
    --text-secondary: #a5b4fc;
    --text-muted: #6366f1;
    --border: rgba(99, 102, 241, 0.15);
    --border-hover: rgba(99, 102, 241, 0.3);
    --glow: 0 0 40px rgba(99, 102, 241, 0.15);
}

[data-theme="light"] {
    --bg-primary: #f1f5f9;
    --bg-secondary: #ffffff;
    --bg-card: linear-gradient(145deg, #ffffff 0%, #f8fafc 100%);
    --bg-card-solid: #ffffff;
    --bg-hover: rgba(99, 102, 241, 0.08);
    --bg-input: #ffffff;
    --text-primary: #1e1b4b;
    --text-secondary: #4338ca;
    --text-muted: #6366f1;
    --border: rgba(99, 102, 241, 0.15);
    --border-hover: rgba(99, 102, 241, 0.3);
    --glow: 0 0 40px rgba(99, 102, 241, 0.1);
}

/* Light theme specific overrides */
[data-theme="light"] .card {
    box-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
}

[data-theme="light"] .card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

[data-theme="light"] .kpi-card {
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

[data-theme="light"] .kpi-value {
    background: linear-gradient(135deg, #1e1b4b 0%, #4338ca 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

[data-theme="light"] .filters-bar {
    background: #ffffff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

[data-theme="light"] .badge-primary {
    background: rgba(99, 102, 241, 0.12);
    color: #4338ca;
}

[data-theme="light"] .table th {
    background: rgba(99, 102, 241, 0.06);
    color: #4338ca;
}

[data-theme="light"] .table td {
    color: #334155;
}

[data-theme="light"] .table tbody tr:hover {
    background: rgba(99, 102, 241, 0.04);
}

[data-theme="light"] .search-bar {
    background: #f8fafc;
    border-color: rgba(99, 102, 241, 0.15);
}

[data-theme="light"] .form-input,
[data-theme="light"] .form-select {
    background: #f8fafc;
    border-color: rgba(99, 102, 241, 0.15);
}

[data-theme="light"] .form-input:focus,
[data-theme="light"] .form-select:focus {
    background: #ffffff;
}

[data-theme="light"] .card-title {
    color: #1e1b4b;
}

[data-theme="light"] .card-title i {
    color: #6366f1;
}

[data-theme="light"] .text-muted {
    color: #64748b !important;
}

[data-theme="light"] .kpi-card.danger::before {
    background: linear-gradient(90deg, #ef4444 0%, #dc2626 100%);
}

[data-theme="light"] .kpi-label {
    color: #475569;
}

[data-theme="light"] .modal {
    background: #ffffff;
    box-shadow: 0 25px 50px rgba(0,0,0,0.15);
}

[data-theme="light"] .modal-header {
    border-color: rgba(99, 102, 241, 0.1);
}

[data-theme="light"] .modal-footer {
    border-color: rgba(99, 102, 241, 0.1);
    background: rgba(248, 250, 252, 0.5);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-primary);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Background Pattern */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background: 
        radial-gradient(circle at 20% 20%, rgba(99, 102, 241, 0.08) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(6, 182, 212, 0.06) 0%, transparent 50%),
        radial-gradient(circle at 50% 50%, rgba(245, 158, 11, 0.04) 0%, transparent 50%);
    pointer-events: none;
    z-index: -1;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-family: var(--font-primary);
    font-size: 0.875rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.1) 0%, transparent 50%);
    opacity: 0;
    transition: opacity var(--transition);
}

.btn:hover::before {
    opacity: 1;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5);
}

.btn-secondary {
    background: var(--bg-card-solid);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    border-color: var(--border-hover);
    background: var(--bg-hover);
}

.btn-success {
    background: linear-gradient(135deg, var(--success) 0%, #16a34a 100%);
    color: white;
    box-shadow: 0 4px 14px rgba(34, 197, 94, 0.3);
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger) 0%, #dc2626 100%);
    color: white;
    box-shadow: 0 4px 14px rgba(239, 68, 68, 0.3);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid transparent;
}

.btn-ghost:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
}

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 10px;
}

.btn-icon.btn-sm {
    width: 32px;
    height: 32px;
}

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow);
    backdrop-filter: blur(10px);
    transition: all var(--transition);
}

.card:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-lg), var(--glow);
}

.card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(99, 102, 241, 0.03);
}

.card-title {
    font-size: 0.95rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.625rem;
    color: var(--text-primary);
}

.card-title i {
    color: var(--primary);
    width: 18px;
    height: 18px;
}

.card-body {
    padding: 1.5rem;
}

/* Tables */
.table-container {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 1rem 1.25rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.table th {
    background: rgba(99, 102, 241, 0.05);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

.table tbody tr {
    transition: background var(--transition);
}

.table tbody tr:hover {
    background: var(--bg-hover);
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.375rem 0.875rem;
    font-size: 0.7rem;
    font-weight: 600;
    border-radius: 9999px;
    letter-spacing: 0.02em;
}

.badge-primary {
    background: rgba(99, 102, 241, 0.15);
    color: var(--primary-light);
}

.badge-success {
    background: rgba(34, 197, 94, 0.15);
    color: var(--success);
}

.badge-warning {
    background: rgba(234, 179, 8, 0.15);
    color: var(--warning);
}

.badge-danger {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
}

/* Light theme badges */
[data-theme="light"] .badge-danger {
    background: rgba(239, 68, 68, 0.12);
    color: #dc2626;
}

[data-theme="light"] .badge-success {
    background: rgba(34, 197, 94, 0.12);
    color: #16a34a;
}

[data-theme="light"] .badge-warning {
    background: rgba(234, 179, 8, 0.12);
    color: #ca8a04;
}

/* KPI Cards */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    position: relative;
    overflow: hidden;
    transition: all var(--transition);
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary) 0%, var(--secondary) 100%);
}

.kpi-card.success::before { 
    background: linear-gradient(90deg, var(--success) 0%, #16a34a 100%); 
}
.kpi-card.warning::before { 
    background: linear-gradient(90deg, var(--warning) 0%, #d97706 100%); 
}
.kpi-card.danger::before { 
    background: linear-gradient(90deg, var(--danger) 0%, #dc2626 100%); 
}

.kpi-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl), var(--glow);
    border-color: var(--border-hover);
}

.kpi-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
    position: relative;
}

.kpi-icon::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: currentColor;
    opacity: 0.12;
}

.kpi-icon.primary { color: var(--primary); }
.kpi-icon.success { color: var(--success); }
.kpi-icon.warning { color: var(--warning); }
.kpi-icon.danger { color: var(--danger); }

.kpi-icon i {
    width: 24px;
    height: 24px;
    position: relative;
    z-index: 1;
}

.kpi-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 0.375rem;
    background: linear-gradient(135deg, var(--text-primary) 0%, var(--text-secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.kpi-label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Forms */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.form-input,
.form-select {
    width: 100%;
    padding: 0.875rem 1rem;
    font-family: var(--font-primary);
    font-size: 0.9rem;
    color: var(--text-primary);
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: all var(--transition);
}

.form-input:focus,
.form-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236366f1' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    padding-right: 3rem;
}

/* Search Bar */
.search-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: all var(--transition);
}

.search-bar:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.search-bar i {
    color: var(--text-muted);
    width: 18px;
    height: 18px;
}

.search-bar input {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-family: var(--font-primary);
    font-size: 0.9rem;
    outline: none;
}

.search-bar input::placeholder {
    color: var(--text-muted);
    opacity: 0.6;
}

/* Filters Bar */
.filters-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding: 1.25rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 0.625rem;
}

.filter-group label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.filter-group select,
.filter-group input {
    padding: 0.625rem 0.875rem;
    font-size: 0.85rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-family: var(--font-primary);
}

/* Ranking List */
.ranking-list {
    list-style: none;
}

.ranking-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 0;
    border-bottom: 1px solid var(--border);
    transition: all var(--transition);
}

.ranking-item:last-child {
    border-bottom: none;
}

.ranking-item:hover {
    padding-left: 0.5rem;
}

.ranking-position {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    background: var(--bg-hover);
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.ranking-position.gold {
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
    color: #1e1b4b;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

.ranking-position.silver {
    background: linear-gradient(135deg, #94a3b8 0%, #64748b 100%);
    color: white;
}

.ranking-position.bronze {
    background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
    color: white;
}

.ranking-info {
    flex: 1;
    min-width: 0;
}

.ranking-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-decoration: none;
    display: block;
    transition: color var(--transition);
}

.ranking-name:hover {
    color: var(--primary);
}

.ranking-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.125rem;
}

.ranking-value {
    font-size: 0.95rem;
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--success);
}

/* Progress */
.progress {
    height: 6px;
    background: var(--bg-hover);
    border-radius: 9999px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary) 0%, var(--secondary) 100%);
    border-radius: 9999px;
    transition: width 0.5s ease;
}

/* Spinner */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Toast */
.toast-container {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.toast {
    background: var(--bg-card-solid);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    min-width: 300px;
    display: flex;
    align-items: center;
    gap: 0.875rem;
    animation: slideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-xl);
    backdrop-filter: blur(10px);
}

.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--danger); }
.toast.warning { border-left: 4px solid var(--warning); }

@keyframes slideIn {
    from { transform: translateX(120%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(12, 10, 29, 0.8);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-card-solid);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    width: 90%;
    max-width: 480px;
    max-height: 90vh;
    overflow: hidden;
    transform: scale(0.9) translateY(20px);
    transition: transform var(--transition);
    box-shadow: var(--shadow-xl), var(--glow);
}

.modal-overlay.active .modal {
    transform: scale(1) translateY(0);
}

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    background: rgba(99, 102, 241, 0.03);
}

/* Dropzone */
.dropzone {
    border: 2px dashed var(--border);
    border-radius: var(--radius-xl);
    padding: 4rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    background: rgba(99, 102, 241, 0.02);
}

.dropzone:hover,
.dropzone.dragover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.06);
    transform: scale(1.01);
}

.dropzone-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 1.5rem;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.15) 0%, rgba(6, 182, 212, 0.1) 100%);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
}

.dropzone-icon i {
    width: 36px;
    height: 36px;
}

.dropzone h3 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

/* Charts */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.25rem;
    margin-top: 1.5rem;
}

.chart-container {
    height: 300px;
}

/* Utilities */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }

.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

/* Responsive */
@media (max-width: 992px) {
    .charts-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .filters-bar {
        flex-direction: column;
    }
    
    .filter-group {
        width: 100%;
    }
    
    .filter-group select,
    .filter-group input {
        flex: 1;
    }
}
