/**
 * ==========================================
 * SISTEMA DE DESIGN - CREDINOWE
 * Temas: Light / Dark
 * ==========================================
 */

/* ========== CSS RESET & BASE ========== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ========== VARIAVEIS DO TEMA ========== */
:root {
    /* Cores Primarias */
    --primary-50: #eff6ff;
    --primary-100: #dbeafe;
    --primary-200: #bfdbfe;
    --primary-300: #93c5fd;
    --primary-400: #60a5fa;
    --primary-500: #3b82f6;
    --primary-600: #2563eb;
    --primary-700: #1d4ed8;
    --primary-800: #1e40af;
    --primary-900: #1e3a8a;
    
    /* Cores de Status */
    --success-50: #f0fdf4;
    --success-500: #22c55e;
    --success-600: #16a34a;
    --danger-50: #fef2f2;
    --danger-500: #ef4444;
    --danger-600: #dc2626;
    --warning-50: #fffbeb;
    --warning-500: #f59e0b;
    --warning-600: #d97706;
    --info-50: #eff6ff;
    --info-500: #3b82f6;
    --info-600: #2563eb;
    
    /* Gradientes */
    --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-dark: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    --gradient-success: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    --gradient-danger: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    
    /* Sombras */
    --shadow-xs: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    
    /* Tipografia */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
    
    /* Espacamentos */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;
    --radius-full: 9999px;
    
    /* Transicoes */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
    --transition-slow: 0.4s ease;
}

/* ========== TEMA LIGHT (Padrao) ========== */
[data-theme="light"], :root {
    --bg-body: #f8fafc;
    --bg-surface: #ffffff;
    --bg-surface-hover: #f1f5f9;
    --bg-elevated: #ffffff;
    --bg-muted: #f1f5f9;
    --bg-subtle: #e2e8f0;
    
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-tertiary: #64748b;
    --text-muted: #94a3b8;
    --text-inverse: #ffffff;
    
    --border-default: #e2e8f0;
    --border-subtle: #f1f5f9;
    --border-strong: #cbd5e1;
    
    --navbar-bg: linear-gradient(135deg, #1e3a5f 0%, #2c5282 100%);
    --navbar-text: #ffffff;
    
    --input-bg: #ffffff;
    --input-border: #e2e8f0;
    --input-focus-ring: rgba(59, 130, 246, 0.25);
    
    --code-bg: #f1f5f9;
    --overlay-bg: rgba(0, 0, 0, 0.5);
}

/* ========== TEMA DARK ========== */
[data-theme="dark"] {
    --bg-body: #0f172a;
    --bg-surface: #1e293b;
    --bg-surface-hover: #334155;
    --bg-elevated: #1e293b;
    --bg-muted: #1e293b;
    --bg-subtle: #334155;
    
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-tertiary: #94a3b8;
    --text-muted: #64748b;
    --text-inverse: #0f172a;
    
    --border-default: #334155;
    --border-subtle: #1e293b;
    --border-strong: #475569;
    
    --navbar-bg: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    --navbar-text: #f8fafc;
    
    --input-bg: #1e293b;
    --input-border: #334155;
    --input-focus-ring: rgba(96, 165, 250, 0.3);
    
    --code-bg: #1e293b;
    --overlay-bg: rgba(0, 0, 0, 0.7);
    
    --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.3);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.4);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.4);
}

/* ========== ESTILOS BASE ========== */
html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    transition: background-color var(--transition-normal), color var(--transition-normal);
}

/* ========== NAVBAR MODERNA ========== */
.navbar-sistema {
    background: var(--navbar-bg);
    padding: 0.75rem 1rem;
    box-shadow: var(--shadow-lg);
    position: sticky;
    top: 0;
    z-index: 1000;
    backdrop-filter: blur(10px);
}

.navbar-sistema .navbar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--navbar-text);
    font-weight: 700;
    font-size: 1.1rem;
    text-decoration: none;
}

.navbar-sistema .brand-icon {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.navbar-sistema .nav-link {
    color: rgba(255, 255, 255, 0.85);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all var(--transition-fast);
}

.navbar-sistema .nav-link:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

.navbar-sistema .nav-link.active {
    color: #fff;
    background: rgba(255, 255, 255, 0.2);
}

/* ========== BOTAO DE TEMA ========== */
.theme-toggle {
    width: 42px;
    height: 42px;
    border-radius: var(--radius-full);
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: var(--navbar-text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: all var(--transition-fast);
}

.theme-toggle:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(15deg);
}

[data-theme="light"] .theme-toggle .icon-dark { display: none; }
[data-theme="light"] .theme-toggle .icon-light { display: block; }
[data-theme="dark"] .theme-toggle .icon-dark { display: block; }
[data-theme="dark"] .theme-toggle .icon-light { display: none; }

/* ========== SIDEBAR (Opcional) ========== */
.sidebar {
    width: 260px;
    background: var(--bg-surface);
    border-right: 1px solid var(--border-default);
    height: calc(100vh - 60px);
    position: fixed;
    left: 0;
    top: 60px;
    overflow-y: auto;
    padding: 1.5rem 1rem;
    transition: transform var(--transition-normal);
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    transition: all var(--transition-fast);
    margin-bottom: 0.25rem;
}

.sidebar-link:hover {
    color: var(--text-primary);
    background: var(--bg-surface-hover);
}

.sidebar-link.active {
    color: var(--primary-600);
    background: var(--primary-50);
}

[data-theme="dark"] .sidebar-link.active {
    color: var(--primary-400);
    background: rgba(59, 130, 246, 0.15);
}

/* ========== CARDS ========== */
.card-sistema {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-default);
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-normal);
}

.card-sistema:hover {
    box-shadow: var(--shadow-md);
}

.card-sistema .card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-default);
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-sistema .card-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-sistema .card-body {
    padding: 1.5rem;
}

/* Card de Estatistica */
.stat-card {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-default);
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: all var(--transition-normal);
}

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

.stat-card .stat-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.stat-card .stat-icon.primary { background: var(--primary-100); color: var(--primary-600); }
.stat-card .stat-icon.success { background: var(--success-50); color: var(--success-600); }
.stat-card .stat-icon.danger { background: var(--danger-50); color: var(--danger-600); }
.stat-card .stat-icon.warning { background: var(--warning-50); color: var(--warning-600); }

[data-theme="dark"] .stat-card .stat-icon.primary { background: rgba(59, 130, 246, 0.2); }
[data-theme="dark"] .stat-card .stat-icon.success { background: rgba(34, 197, 94, 0.2); }
[data-theme="dark"] .stat-card .stat-icon.danger { background: rgba(239, 68, 68, 0.2); }
[data-theme="dark"] .stat-card .stat-icon.warning { background: rgba(245, 158, 11, 0.2); }

.stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
}

.stat-card .stat-label {
    font-size: 0.875rem;
    color: var(--text-tertiary);
    margin-top: 0.25rem;
}

/* ========== BOTOES ========== */
.btn-sistema {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
}

.btn-sistema:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px -5px rgba(102, 126, 234, 0.5);
    color: white;
}

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

.btn-success:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px -5px rgba(34, 197, 94, 0.5);
    color: white;
}

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

.btn-danger:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px -5px rgba(239, 68, 68, 0.5);
    color: white;
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--border-default);
    color: var(--text-primary);
}

.btn-outline:hover:not(:disabled) {
    background: var(--bg-surface-hover);
    border-color: var(--border-strong);
    color: var(--text-primary);
}

.btn-ghost {
    background: transparent;
    border: none;
    color: var(--text-secondary);
}

.btn-ghost:hover:not(:disabled) {
    background: var(--bg-surface-hover);
    color: var(--text-primary);
}

/* ========== INPUTS ========== */
.input-sistema {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    background: var(--input-bg);
    border: 2px solid var(--input-border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    transition: all var(--transition-fast);
}

.input-sistema:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 4px var(--input-focus-ring);
}

.input-sistema::placeholder {
    color: var(--text-muted);
}

.input-group-sistema {
    position: relative;
}

.input-group-sistema .input-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

.input-group-sistema .input-sistema {
    padding-left: 3rem;
}

.form-label-sistema {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

/* ========== TABELAS ========== */
.table-sistema {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.table-sistema thead th {
    background: var(--bg-muted);
    padding: 0.875rem 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-tertiary);
    text-align: left;
    border-bottom: 1px solid var(--border-default);
}

.table-sistema thead th:first-child {
    border-radius: var(--radius-md) 0 0 0;
}

.table-sistema thead th:last-child {
    border-radius: 0 var(--radius-md) 0 0;
}

.table-sistema tbody td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-default);
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.table-sistema tbody tr {
    transition: background var(--transition-fast);
}

.table-sistema tbody tr:hover {
    background: var(--bg-surface-hover);
}

/* ========== BADGES ========== */
.badge-sistema {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: var(--radius-full);
}

.badge-success {
    background: var(--success-50);
    color: var(--success-600);
}

.badge-danger {
    background: var(--danger-50);
    color: var(--danger-600);
}

.badge-warning {
    background: var(--warning-50);
    color: var(--warning-600);
}

.badge-info {
    background: var(--info-50);
    color: var(--info-600);
}

.badge-neutral {
    background: var(--bg-muted);
    color: var(--text-tertiary);
}

[data-theme="dark"] .badge-success { background: rgba(34, 197, 94, 0.2); }
[data-theme="dark"] .badge-danger { background: rgba(239, 68, 68, 0.2); }
[data-theme="dark"] .badge-warning { background: rgba(245, 158, 11, 0.2); }
[data-theme="dark"] .badge-info { background: rgba(59, 130, 246, 0.2); }

/* ========== ALERTAS ========== */
.alert-sistema {
    padding: 1rem 1.25rem;
    border-radius: var(--radius-md);
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.alert-sistema .alert-icon {
    flex-shrink: 0;
    font-size: 1.25rem;
}

.alert-success {
    background: var(--success-50);
    color: var(--success-600);
    border: 1px solid rgba(34, 197, 94, 0.2);
}

.alert-danger {
    background: var(--danger-50);
    color: var(--danger-600);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.alert-warning {
    background: var(--warning-50);
    color: var(--warning-600);
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.alert-info {
    background: var(--info-50);
    color: var(--info-600);
    border: 1px solid rgba(59, 130, 246, 0.2);
}

/* ========== MODAIS ========== */
.modal-sistema .modal-content {
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
}

.modal-sistema .modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-default);
}

.modal-sistema .modal-title {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-primary);
}

.modal-sistema .modal-body {
    padding: 1.5rem;
}

.modal-sistema .modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-default);
    background: var(--bg-muted);
    border-radius: 0 0 var(--radius-xl) var(--radius-xl);
}

/* ========== LOGS ========== */
.log-item {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1rem;
    border-bottom: 1px solid var(--border-default);
    transition: background var(--transition-fast);
}

.log-item:hover {
    background: var(--bg-surface-hover);
}

.log-item:last-child {
    border-bottom: none;
}

.log-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.875rem;
}

.log-icon.login { background: var(--success-50); color: var(--success-600); }
.log-icon.logout { background: var(--warning-50); color: var(--warning-600); }
.log-icon.error { background: var(--danger-50); color: var(--danger-600); }
.log-icon.action { background: var(--info-50); color: var(--info-600); }
.log-icon.system { background: var(--bg-muted); color: var(--text-tertiary); }

[data-theme="dark"] .log-icon.login { background: rgba(34, 197, 94, 0.2); }
[data-theme="dark"] .log-icon.logout { background: rgba(245, 158, 11, 0.2); }
[data-theme="dark"] .log-icon.error { background: rgba(239, 68, 68, 0.2); }
[data-theme="dark"] .log-icon.action { background: rgba(59, 130, 246, 0.2); }

.log-content {
    flex: 1;
}

.log-title {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.875rem;
}

.log-description {
    color: var(--text-tertiary);
    font-size: 0.8125rem;
    margin-top: 0.125rem;
}

.log-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.log-meta span {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

/* ========== PROGRESS ========== */
.progress-sistema {
    height: 8px;
    background: var(--bg-muted);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-bar-sistema {
    height: 100%;
    background: var(--gradient-primary);
    border-radius: var(--radius-full);
    transition: width var(--transition-normal);
}

/* ========== AVATAR ========== */
.avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    font-weight: 600;
    color: white;
    background: var(--gradient-primary);
}

.avatar.sm { width: 32px; height: 32px; font-size: 0.75rem; }
.avatar.lg { width: 56px; height: 56px; font-size: 1.125rem; }

/* ========== DROPDOWN ========== */
.dropdown-menu-sistema {
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 0.5rem;
    min-width: 200px;
}

.dropdown-menu-sistema .dropdown-item {
    padding: 0.625rem 1rem;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: all var(--transition-fast);
}

.dropdown-menu-sistema .dropdown-item:hover {
    background: var(--bg-surface-hover);
    color: var(--text-primary);
}

.dropdown-menu-sistema .dropdown-divider {
    border-color: var(--border-default);
    margin: 0.5rem 0;
}

/* ========== SPINNER ========== */
.spinner-sistema {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-default);
    border-top-color: var(--primary-500);
    border-radius: var(--radius-full);
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ========== TOAST ========== */
.toast-sistema {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    padding: 1rem 1.25rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    z-index: 9999;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ========== UTILITARIOS ========== */
.text-primary { color: var(--primary-600) !important; }
.text-success { color: var(--success-600) !important; }
.text-danger { color: var(--danger-600) !important; }
.text-warning { color: var(--warning-600) !important; }
.text-muted { color: var(--text-muted) !important; }

.bg-primary { background: var(--primary-500) !important; }
.bg-success { background: var(--success-500) !important; }
.bg-danger { background: var(--danger-500) !important; }
.bg-warning { background: var(--warning-500) !important; }

.rounded-lg { border-radius: var(--radius-lg) !important; }
.rounded-xl { border-radius: var(--radius-xl) !important; }
.rounded-full { border-radius: var(--radius-full) !important; }

.shadow-sm { box-shadow: var(--shadow-sm) !important; }
.shadow-md { box-shadow: var(--shadow-md) !important; }
.shadow-lg { box-shadow: var(--shadow-lg) !important; }

/* ========== ANIMACOES ========== */
.fade-in {
    animation: fadeIn 0.3s ease;
}

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

.pulse {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ========== RESPONSIVIDADE ========== */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        z-index: 1001;
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    .stat-card {
        padding: 1rem;
    }
    
    .stat-card .stat-value {
        font-size: 1.5rem;
    }
}
