/* ============================================================
   Cienciometria — Visual Theme
   ============================================================ */

/* --- Design Tokens --- */
:root {
    --c-primary: #1e3a5f;
    --c-primary-light: #2a5298;
    --c-primary-dark: #0f1f33;
    --c-accent: #00b4d8;
    --c-accent-light: #48cae4;
    --c-success: #06d6a0;
    --c-warning: #ffd166;
    --c-danger: #ef476f;
    --c-bg: #f0f2f5;
    --c-surface: #ffffff;
    --c-text: #1a1a2e;
    --c-text-muted: #6c757d;
    --c-border: #e2e8f0;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.1);
    --radius: 10px;
    --radius-lg: 16px;
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Global --- */
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--c-bg);
    color: var(--c-text);
    -webkit-font-smoothing: antialiased;
}

/* --- Navbar --- */
.navbar {
    background: linear-gradient(135deg, var(--c-primary-dark) 0%, var(--c-primary) 50%, var(--c-primary-light) 100%) !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    padding: 0.6rem 0;
    border: none;
}

.navbar-brand {
    letter-spacing: -0.5px;
    font-weight: 700 !important;
}

/* --- Sidebar --- */
.sidebar-wrapper {
    background: var(--c-surface);
    border-right: 1px solid var(--c-border);
}

.nav-pills .nav-link {
    color: var(--c-text-muted);
    border-radius: 0;
    transition: all var(--transition);
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.6rem 1rem;
    border-left: 3px solid transparent;
    margin: 1px 0;
}

.nav-pills .nav-link i {
    width: 20px;
    text-align: center;
    transition: color var(--transition);
}

.nav-pills .nav-link:hover {
    background: linear-gradient(90deg, #eef2ff 0%, transparent 100%);
    color: var(--c-primary);
    border-left-color: var(--c-accent);
}

.nav-pills .nav-link.active {
    background: linear-gradient(90deg, #dbeafe 0%, #eff6ff 100%);
    color: var(--c-primary);
    font-weight: 600;
    border-left-color: var(--c-primary);
    border-radius: 0;
}

/* --- Cards --- */
.card {
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    transition: transform var(--transition), box-shadow var(--transition);
    background: var(--c-surface);
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md) !important;
}

.card-header {
    background: linear-gradient(180deg, #fafbfc 0%, #f4f6f8 100%);
    border-bottom: 1px solid var(--c-border);
    font-weight: 600;
}

/* --- Metric Cards --- */
.metric-card {
    border: none !important;
    border-radius: var(--radius-lg) !important;
    overflow: hidden;
    position: relative;
}

.metric-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
}

.metric-card .card-body {
    padding: 1.25rem;
    position: relative;
}

.metric-card .metric-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.metric-card .metric-value {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    line-height: 1.2;
}

.metric-card .metric-label {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--c-text-muted);
}

/* Metric card color variants */
.metric-card-primary::before { background: linear-gradient(90deg, var(--c-primary), var(--c-primary-light)); }
.metric-card-primary .metric-icon { background: #dbeafe; color: var(--c-primary); }

.metric-card-info::before { background: linear-gradient(90deg, var(--c-accent), var(--c-accent-light)); }
.metric-card-info .metric-icon { background: #e0f7fa; color: #0277bd; }

.metric-card-success::before { background: linear-gradient(90deg, #06d6a0, #2ecc71); }
.metric-card-success .metric-icon { background: #d4edda; color: #155724; }

.metric-card-warning::before { background: linear-gradient(90deg, #ffd166, #f0932b); }
.metric-card-warning .metric-icon { background: #fff3cd; color: #856404; }

.metric-card-danger::before { background: linear-gradient(90deg, var(--c-danger), #e17055); }
.metric-card-danger .metric-icon { background: #f8d7da; color: #721c24; }

/* --- Hero Section (Home) --- */
.hero-section {
    background: linear-gradient(135deg, var(--c-primary-dark) 0%, var(--c-primary) 40%, var(--c-primary-light) 100%);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    color: white;
    position: relative;
    overflow: hidden;
    margin-bottom: 2rem;
}

.hero-section::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.08) 0%, transparent 70%);
    border-radius: 50%;
}

.hero-section::after {
    content: '';
    position: absolute;
    bottom: -30%;
    left: 10%;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(0, 180, 216, 0.15) 0%, transparent 70%);
    border-radius: 50%;
}

.hero-title {
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    position: relative;
    z-index: 1;
}

.hero-subtitle {
    font-size: 0.95rem;
    opacity: 0.85;
    position: relative;
    z-index: 1;
}

.hero-badge {
    display: inline-block;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 500;
    margin-right: 0.5rem;
    margin-bottom: 0.5rem;
}

/* --- Feature Cards (Home) --- */
.feature-card {
    border: 1px solid var(--c-border) !important;
    border-radius: var(--radius-lg) !important;
    transition: all var(--transition);
    overflow: hidden;
}

.feature-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg) !important;
    border-color: var(--c-accent) !important;
}

.feature-card .feature-icon-box {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    margin-bottom: 1rem;
}

.feature-icon-upload { background: linear-gradient(135deg, #dbeafe, #bfdbfe); color: var(--c-primary); }
.feature-icon-api { background: linear-gradient(135deg, #d1fae5, #a7f3d0); color: #065f46; }
.feature-icon-analysis { background: linear-gradient(135deg, #fef3c7, #fde68a); color: #92400e; }
.feature-icon-ai { background: linear-gradient(135deg, #ede9fe, #ddd6fe); color: #5b21b6; }

/* --- Source Badges --- */
.source-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: 8px;
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
    font-weight: 500;
    transition: all var(--transition);
}

.source-badge:hover {
    border-color: var(--c-accent);
    box-shadow: 0 2px 8px rgba(0, 180, 216, 0.15);
}

.source-badge .source-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.source-dot-open { background: var(--c-success); }
.source-dot-key { background: var(--c-warning); }
.source-dot-enrich { background: var(--c-accent); }

/* --- Data Entry --- */
.dcc-upload {
    transition: all 0.3s ease;
    border-radius: var(--radius) !important;
}

.dcc-upload:hover {
    border-color: var(--c-accent) !important;
    background-color: #f0f9ff;
}

/* --- Buttons --- */
.btn {
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.875rem;
    padding: 0.5rem 1.25rem;
    transition: all var(--transition);
}

.btn-primary {
    background: linear-gradient(135deg, var(--c-primary) 0%, var(--c-primary-light) 100%);
    border: none;
    box-shadow: 0 2px 8px rgba(30, 58, 95, 0.3);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--c-primary-dark) 0%, var(--c-primary) 100%);
    box-shadow: 0 4px 12px rgba(30, 58, 95, 0.4);
    transform: translateY(-1px);
}

.btn-outline-primary {
    border-color: var(--c-primary);
    color: var(--c-primary);
}

.btn-outline-primary:hover {
    background: var(--c-primary);
    border-color: var(--c-primary);
}

/* --- DataTable --- */
.dash-table-container {
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--c-border);
}

.dash-header {
    font-weight: 600 !important;
    font-size: 0.825rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* --- Tabs --- */
.nav-tabs {
    border-bottom: 2px solid var(--c-border);
}

.nav-tabs .nav-link {
    border: none;
    border-bottom: 3px solid transparent;
    font-weight: 500;
    color: var(--c-text-muted);
    transition: all var(--transition);
    padding: 0.75rem 1.25rem;
}

.nav-tabs .nav-link:hover {
    color: var(--c-primary);
    border-bottom-color: var(--c-accent-light);
}

.nav-tabs .nav-link.active {
    font-weight: 700;
    color: var(--c-primary);
    border-bottom: 3px solid var(--c-primary);
    background: transparent;
}

/* --- Alerts --- */
.alert {
    border-radius: var(--radius);
    border: none;
    font-size: 0.9rem;
    border-left: 4px solid;
}

.alert-success { border-left-color: var(--c-success); }
.alert-info { border-left-color: var(--c-accent); }
.alert-warning { border-left-color: var(--c-warning); }
.alert-danger { border-left-color: var(--c-danger); }

/* --- Plotly Charts --- */
.js-plotly-plot {
    border-radius: var(--radius);
    overflow: hidden;
}

/* --- AI Report --- */
.ai-report {
    line-height: 1.8;
    font-size: 0.95rem;
}

.ai-report h1, .ai-report h2, .ai-report h3 {
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--c-primary);
    font-weight: 700;
}

.ai-report ul, .ai-report ol {
    padding-left: 1.5rem;
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 6px;
}

::-webkit-scrollbar-thumb {
    background: #94a3b8;
    border-radius: 6px;
    border: 2px solid #f1f5f9;
}

::-webkit-scrollbar-thumb:hover {
    background: #64748b;
}

/* Firefox scrollbar */
* {
    scrollbar-width: auto;
    scrollbar-color: #94a3b8 #f1f5f9;
}

/* --- Section titles --- */
.section-title {
    font-weight: 700;
    color: var(--c-primary);
    position: relative;
    padding-bottom: 0.5rem;
}

.section-title::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 40px;
    height: 3px;
    background: linear-gradient(90deg, var(--c-accent), var(--c-accent-light));
    border-radius: 2px;
}

/* --- Page header --- */
.page-header {
    margin-bottom: 1.5rem;
}

.page-header h3 {
    font-weight: 700;
    color: var(--c-primary);
    margin-bottom: 0;
}

/* --- Filter section --- */
.filter-panel {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
}

/* --- Spinner --- */
.dash-spinner {
    margin: 2rem auto;
}

/* --- Badge --- */
.badge {
    font-weight: 600;
    letter-spacing: 0.3px;
}

/* --- Tooltip/Slider --- */
.rc-slider-handle {
    border-color: var(--c-primary) !important;
}

.rc-slider-track {
    background-color: var(--c-primary) !important;
}

/* --- Status indicator --- */
.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.status-dot-active {
    background: var(--c-success);
    box-shadow: 0 0 6px rgba(6, 214, 160, 0.5);
}

.status-dot-inactive {
    background: #adb5bd;
}

/* --- Search Interface --- */
.search-hero {
    background: linear-gradient(135deg, var(--c-primary-dark) 0%, var(--c-primary) 50%, var(--c-primary-light) 100%);
    border-radius: var(--radius-lg);
    padding: 2rem 2.5rem;
    color: white;
    margin-bottom: 1.5rem;
    position: relative;
    overflow: hidden;
}

.search-hero::before {
    content: '';
    position: absolute;
    top: -40%;
    right: -10%;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(255,255,255,0.06) 0%, transparent 70%);
    border-radius: 50%;
}

.search-input-wrapper .form-control {
    border-radius: 12px;
    padding: 0.85rem 1.25rem;
    font-size: 1rem;
    border: 2px solid rgba(255,255,255,0.3);
    background: rgba(255,255,255,0.15);
    color: white;
    backdrop-filter: blur(8px);
    transition: all var(--transition);
}

.search-input-wrapper .form-control::placeholder {
    color: rgba(255,255,255,0.6);
}

.search-input-wrapper .form-control:focus {
    background: rgba(255,255,255,0.25);
    border-color: rgba(255,255,255,0.6);
    color: white;
    box-shadow: 0 0 0 3px rgba(255,255,255,0.15);
}

.source-select-card {
    border: 2px solid var(--c-border);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: all var(--transition);
    background: var(--c-surface);
    user-select: none;
}

.source-select-card:hover {
    border-color: var(--c-accent);
    box-shadow: 0 2px 8px rgba(0,180,216,0.12);
}

.source-select-card.source-selected {
    border-color: var(--c-primary);
    background: #eef2ff;
    box-shadow: 0 2px 8px rgba(30,58,95,0.12);
}

.source-select-card .source-name {
    font-weight: 600;
    font-size: 0.9rem;
}

.source-select-card .source-desc {
    font-size: 0.75rem;
    color: var(--c-text-muted);
}

.search-options-panel {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
}

/* --- Settings Page --- */
.settings-card {
    border: 1px solid var(--c-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.settings-card .card-header {
    font-weight: 600;
    font-size: 0.9rem;
    padding: 0.85rem 1.25rem;
}

.settings-card .form-label {
    font-weight: 500;
    font-size: 0.85rem;
    color: var(--c-text-muted);
}

.api-status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.api-status-configured { background: var(--c-success); }
.api-status-missing { background: #adb5bd; }

/* --- Responsive --- */
@media (max-width: 768px) {
    .sidebar {
        display: none;
    }
    .hero-section {
        padding: 1.5rem;
    }
    .hero-title {
        font-size: 1.3rem;
    }
}

/* --- Animations --- */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in-up {
    animation: fadeInUp 0.5s ease-out;
}

@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 0 4px rgba(6, 214, 160, 0.4); }
    50% { box-shadow: 0 0 10px rgba(6, 214, 160, 0.7); }
}

.pulse-glow {
    animation: pulse-glow 2s ease-in-out infinite;
}

/* --- Login Page --- */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--c-primary-dark) 0%, var(--c-primary) 40%, var(--c-primary-light) 100%);
}

.login-container {
    width: 100%;
    max-width: 420px;
    text-align: center;
    color: white;
}

.login-logo {
    width: 72px;
    height: 72px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.login-card {
    border: none;
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.login-card .form-control:focus {
    border-color: var(--c-primary);
    box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.15);
}

/* --- Sidebar Project Items --- */
.sidebar-project-item {
    border-left: 2px solid transparent !important;
    transition: all var(--transition);
}

.sidebar-project-item:hover {
    background: #f8fafc;
    border-left-color: var(--c-accent) !important;
}

.sidebar-project-item.active {
    background: #eef2ff;
    border-left-color: var(--c-primary) !important;
}
