@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;600&display=swap');

:root {
    --bg-main: #f8fafc;
    --bg-sidebar: #0f172a;
    --bg-card: #ffffff;
    
    --primary: #3b82f6;
    --primary-glow: rgba(59, 130, 246, 0.35);
    --primary-hover: #2563eb;
    
    --success: #10b981;
    --success-glow: rgba(16, 185, 129, 0.3);
    
    --warning: #f59e0b;
    --warning-glow: rgba(245, 158, 11, 0.3);
    
    --purple: #8b5cf6;
    --purple-glow: rgba(139, 92, 246, 0.3);
    
    --danger: #ef4444;
    --danger-glow: rgba(239, 68, 68, 0.3);
    
    --text-main: #0f172a;
    --text-muted: #64748b;
    --text-light: #94a3b8;
    
    --border: #e2e8f0;
    --border-dark: #1e293b;
    
    --shadow-sm: 0 2px 4px rgba(15, 23, 42, 0.04);
    --shadow-md: 0 10px 25px -5px rgba(15, 23, 42, 0.08), 0 8px 10px -6px rgba(15, 23, 42, 0.04);
    --shadow-lg: 0 20px 30px -10px rgba(15, 23, 42, 0.12);
    --radius: 16px;
    --radius-sm: 10px;
}

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

html, body {
    height: 100%;
    font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    -webkit-font-smoothing: antialiased;
}

a {
    text-decoration: none;
    color: inherit;
}

code, pre, .json-box {
    font-family: 'JetBrains Mono', monospace;
}

/* --- TELA DE LOGIN FUTURISTA --- */
body.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at top right, #1e1b4b, #0f172a);
    position: relative;
    overflow: hidden;
}

body.login-page::before {
    content: '';
    position: absolute;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, var(--primary-glow) 0%, transparent 70%);
    top: -200px;
    right: -200px;
    z-index: 0;
    pointer-events: none;
}

.login-box {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    padding: 48px 40px;
    border-radius: 24px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    width: 100%;
    max-width: 420px;
    z-index: 1;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.login-header {
    text-align: center;
    margin-bottom: 36px;
}

.login-header .logo-icon {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--primary), var(--purple));
    border-radius: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    color: white;
    box-shadow: 0 10px 25px -5px var(--primary-glow);
    margin-bottom: 16px;
}

.login-header h2 {
    font-size: 1.8rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    color: var(--text-main);
}

/* --- ESTRUTURA DO DASHBOARD (SIDEBAR + CONTEÚDO) --- */
.layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background-color: var(--bg-sidebar);
    color: white;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    z-index: 50;
    border-right: 1px solid var(--border-dark);
    transition: width 0.3s ease;
}

.sidebar-header {
    padding: 24px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border-dark);
}

.sidebar-logo-icon {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, var(--primary), var(--purple));
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: white;
    box-shadow: 0 4px 12px var(--primary-glow);
}

.sidebar-header h1 {
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: linear-gradient(to right, #fff, #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar-nav {
    padding: 20px 14px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
}

.nav-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-light);
    margin: 16px 8px 8px 8px;
    font-weight: 700;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    border-radius: 12px;
    color: #cbd5e1;
    font-weight: 500;
    font-size: 0.95rem;
    transition: all 0.2s ease;
}

.nav-item i {
    font-size: 1.1rem;
    width: 24px;
    text-align: center;
    transition: transform 0.2s;
}

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

.nav-item.active {
    background: linear-gradient(90deg, rgba(59, 130, 246, 0.2), transparent);
    border-left: 3px solid var(--primary);
}

.nav-item:hover i {
    transform: scale(1.15);
    color: var(--primary);
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border-dark);
    background: rgba(0, 0, 0, 0.2);
}

.user-profile {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    overflow: hidden;
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: #334155;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: white;
    font-size: 0.9rem;
}

.user-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: white;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: 0.7rem;
    color: var(--text-light);
}

/* --- CONTEÚDO PRINCIPAL --- */
.main-wrapper {
    flex: 1;
    margin-left: 260px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.top-navbar {
    height: 70px;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 40px;
    position: sticky;
    top: 0;
    z-index: 40;
}

.page-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
}

.top-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.main-content {
    padding: 40px;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    flex: 1;
}

/* --- CARDS E DASHBOARD GRID --- */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
    margin-top: 24px;
}

.system-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 32px 24px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    overflow: hidden;
}

.system-card::top-border {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--primary);
    opacity: 0;
    transition: opacity 0.3s;
}

.system-card:hover {
    transform: translateY(-6px);
    box-shadow: var(--shadow-lg);
    border-color: #cbd5e1;
}

.system-card:hover::top-border {
    opacity: 1;
}

.card-icon-wrapper {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    margin-bottom: 24px;
    transition: transform 0.3s;
}

.system-card:hover .card-icon-wrapper {
    transform: scale(1.1) rotate(5deg);
}

.system-card h3 {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-main);
}

.system-card p {
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.5;
    margin-bottom: 28px;
}

/* Cores específicas dos Cards */
.card-blue .card-icon-wrapper { background: rgba(59, 130, 246, 0.1); color: var(--primary); }
.card-blue .btn-card { background: var(--primary); box-shadow: 0 4px 12px var(--primary-glow); }

.card-green .card-icon-wrapper { background: rgba(16, 185, 129, 0.1); color: var(--success); }
.card-green .btn-card { background: var(--success); box-shadow: 0 4px 12px var(--success-glow); }

.card-purple .card-icon-wrapper { background: rgba(139, 92, 246, 0.1); color: var(--purple); }
.card-purple .btn-card { background: var(--purple); box-shadow: 0 4px 12px var(--purple-glow); }

.card-amber .card-icon-wrapper { background: rgba(245, 158, 11, 0.1); color: var(--warning); }
.card-amber .btn-card { background: var(--warning); box-shadow: 0 4px 12px var(--warning-glow); }

/* --- BOTÕES --- */
.btn-primary, .btn-card {
    background-color: var(--primary);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
}

.btn-primary:hover, .btn-card:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

.btn-secondary {
    background: #f1f5f9;
    color: var(--text-main);
    border: 1px solid var(--border);
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: #e2e8f0;
    border-color: #cbd5e1;
}

/* --- COMPONENTES DA UI --- */
.upload-section {
    background: var(--bg-card);
    padding: 48px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    text-align: center;
    margin-bottom: 32px;
    border: 2px dashed #cbd5e1;
    transition: border-color 0.3s;
}

.upload-section:hover {
    border-color: var(--primary);
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.table-container {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    overflow: hidden;
}

.data-table, .log-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
}

.data-table th, .log-table th {
    background-color: #f8fafc;
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 16px 24px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.data-table td, .log-table td {
    padding: 16px 24px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
    color: var(--text-main);
}

.data-table tr:last-child td, .log-table tr:last-child td {
    border-bottom: none;
}

.data-table tr:hover, .log-table tr:hover {
    background-color: #f8fafc;
}

/* Form Groups */
.form-group {
    margin-bottom: 20px;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-main);
}

.form-group input, .form-group select {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-family: inherit;
    transition: all 0.2s;
    background: #f8fafc;
}

.form-group input:focus, .form-group select:focus {
    outline: none;
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 4px var(--primary-glow);
}

.password-wrapper {
    position: relative;
}

.password-toggle {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    color: var(--text-muted);
}

/* --- MODAIS COM BLUR --- */
.modal {
    display: none; 
    position: fixed; 
    z-index: 1000; 
    left: 0; 
    top: 0;
    width: 100%; 
    height: 100%; 
    background-color: rgba(15, 23, 42, 0.6); 
    backdrop-filter: blur(8px);
    align-items: center; 
    justify-content: center;
    padding: 20px;
}

.modal-content { 
    background-color: white; 
    padding: 32px; 
    border-radius: 20px;
    width: 100%; 
    max-width: 500px; 
    box-shadow: var(--shadow-lg);
    position: relative; 
    max-height: 90vh; 
    overflow-y: auto; 
    border: 1px solid var(--border);
    animation: modalScale 0.2s ease-out;
}

@keyframes modalScale {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.modal-content.lg {
    max-width: 950px;
}

.close {
    position: absolute;
    right: 24px;
    top: 24px;
    font-size: 20px;
    cursor: pointer;
    color: var(--text-light);
    transition: color 0.2s;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f1f5f9;
}

.close:hover {
    color: var(--danger);
    background: #fee2e2;
}

/* --- LOADING & PROGRESS --- */
#progress-container {
    margin-top: 24px;
    text-align: center;
    display: none;
    width: 100%;
}

progress {
    width: 100%;
    height: 12px;
    border-radius: 6px;
    overflow: hidden;
    appearance: none;
}

progress::-webkit-progress-bar { background-color: #e2e8f0; }
progress::-webkit-progress-value { background-color: var(--primary); transition: width 0.3s ease; }

.progress-text {
    font-weight: 700;
    color: var(--primary);
    margin-top: 8px;
    display: block;
    font-size: 0.9rem;
}

.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 32px;
    color: var(--text-muted);
}

/* --- RESPONSIVIDADE --- */
@media (max-width: 1024px) {
    .sidebar { width: 80px; }
    .sidebar-header h1, .nav-item span, .user-name, .user-role, .nav-label { display: none; }
    .sidebar-header { justify-content: center; padding: 20px 0; }
    .nav-item { justify-content: center; padding: 16px 0; }
    .main-wrapper { margin-left: 80px; }
    .user-profile { justify-content: center; }
}

@media (max-width: 768px) {
    .sidebar { display: none; }
    .main-wrapper { margin-left: 0; }
    .top-navbar { padding: 0 20px; }
    .main-content { padding: 20px; }
}