/* ═══════════════════════════════════════════════════════════
   GeoChemPlot Pro 3.4 — Academic Research Edition
   Custom Stylesheet  ·  Mohammad Fadaeian © 2026
   ═══════════════════════════════════════════════════════════ */

/* ─── CSS Variables ────────────────────────────────────── */
:root {
    --accent:        #2563eb;
    --accent-hover:  #1d4ed8;
    --accent-soft:   rgba(37, 99, 235, 0.10);
    --bg-body:       #f0f4f8;
    --bg-card:       rgba(255,255,255,0.72);
    --bg-card-solid: #ffffff;
    --bg-nav:        rgba(255,255,255,0.78);
    --text-primary:  #1e293b;
    --text-muted:    #64748b;
    --border:        rgba(0,0,0,0.06);
    --shadow-sm:     0 1px 3px rgba(0,0,0,0.05);
    --shadow-md:     0 4px 20px rgba(0,0,0,0.06);
    --shadow-lg:     0 10px 40px rgba(0,0,0,0.08);
    --radius:        12px;
    --radius-lg:     16px;
    --font-main:     'Inter', system-ui, -apple-system, sans-serif;
    --font-mono:     'JetBrains Mono', ui-monospace, monospace;
    --font-fa:       'Vazirmatn', 'Inter', system-ui, sans-serif;
    --hero-gradient: linear-gradient(135deg, #e0e7ff 0%, #f0f4f8 40%, #ecfdf5 100%);
}

[data-bs-theme="dark"] {
    --accent:        #3b82f6;
    --accent-hover:  #60a5fa;
    --accent-soft:   rgba(59, 130, 246, 0.15);
    --bg-body:       #0f172a;
    --bg-card:       rgba(30, 41, 59, 0.72);
    --bg-card-solid: #1e293b;
    --bg-nav:        rgba(15, 23, 42, 0.85);
    --text-primary:  #e2e8f0;
    --text-muted:    #94a3b8;
    --border:        rgba(255,255,255,0.06);
    --shadow-sm:     0 1px 3px rgba(0,0,0,0.2);
    --shadow-md:     0 4px 20px rgba(0,0,0,0.3);
    --shadow-lg:     0 10px 40px rgba(0,0,0,0.4);
    --hero-gradient: linear-gradient(135deg, #1e1b4b 0%, #0f172a 40%, #042f2e 100%);
}

/* ─── Base ─────────────────────────────────────────────── */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    scroll-padding-top: 80px;
}

body {
    font-family: var(--font-main);
    background: var(--bg-body);
    color: var(--text-primary);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ─── RTL / Persian Mode ───────────────────────────────── */
body.rtl-mode {
    font-family: var(--font-fa);
}

body.rtl-mode .brand-title,
body.rtl-mode .brand-version {
    font-family: var(--font-main);
}

body.rtl-mode .me-1 { margin-right: 0 !important; margin-left: 0.25rem !important; }
body.rtl-mode .me-2 { margin-right: 0 !important; margin-left: 0.5rem !important; }
body.rtl-mode .ms-2 { margin-left: 0 !important; margin-right: 0.5rem !important; }
body.rtl-mode .ms-lg-2 { margin-left: 0 !important; margin-right: 0.5rem !important; }

body.rtl-mode #dataTable tbody td {
    font-family: var(--font-mono);
    direction: ltr;
    text-align: center;
}

body.rtl-mode #dataTable thead th {
    direction: ltr;
    text-align: center;
}

body.rtl-mode .cipw-mineral {
    direction: ltr;
}

body.rtl-mode .index-stat {
    direction: ltr;
}

body.rtl-mode .mineral-name,
body.rtl-mode .mineral-value {
    font-family: var(--font-mono);
}

/* ─── Glass Nav ────────────────────────────────────────── */
.glass-nav {
    background: var(--bg-nav);
    backdrop-filter: blur(20px) saturate(1.5);
    -webkit-backdrop-filter: blur(20px) saturate(1.5);
    border-bottom: 1px solid var(--border);
    z-index: 1030;
    transition: background 0.3s;
}

.brand-icon {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, var(--accent), #7c3aed);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.1rem;
}

.brand-title {
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: -0.3px;
}

.brand-version {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--accent);
    background: var(--accent-soft);
    padding: 1px 6px;
    border-radius: 6px;
    margin-left: 4px;
    vertical-align: super;
}

.navbar-nav .nav-link {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
    transition: color 0.2s;
    border-radius: 8px;
    padding: 6px 12px !important;
}

.navbar-nav .nav-link:hover {
    color: var(--accent);
    background: var(--accent-soft);
}

/* ─── Hero ─────────────────────────────────────────────── */
.hero-section {
    background: var(--hero-gradient);
    padding: 4rem 1rem 3rem;
    position: relative;
    overflow: hidden;
}

.hero-section::before {
    content: "";
    position: absolute;
    top: -50%;
    right: -20%;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, var(--accent-soft) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
}

.hero-badge {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--accent);
    background: var(--accent-soft);
    padding: 4px 16px;
    border-radius: 100px;
}

body.rtl-mode .hero-badge {
    letter-spacing: 0;
}

.hero-title {
    font-size: clamp(2rem, 5vw, 3.2rem);
    font-weight: 800;
    letter-spacing: -1px;
    line-height: 1.15;
    margin-bottom: .5rem;
    font-family: var(--font-main);
}

.text-accent { color: var(--accent); }

.hero-subtitle {
    max-width: 560px;
    color: var(--text-muted);
    font-size: 1.05rem;
    line-height: 1.6;
}

body.rtl-mode .hero-subtitle {
    line-height: 2;
}

/* ─── Upload Zone ──────────────────────────────────────── */
.upload-zone {
    max-width: 520px;
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 2.5rem 2rem;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.upload-zone:hover,
.upload-zone.drag-over {
    border-color: var(--accent);
    background: var(--accent-soft);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.upload-icon-wrapper {
    width: 64px;
    height: 64px;
    background: var(--accent-soft);
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.upload-icon-wrapper i {
    font-size: 1.5rem;
    color: var(--accent);
}

.upload-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2rem;
}

.file-info-card {
    max-width: 600px;
}

/* ─── Glass Card ───────────────────────────────────────── */
.glass-card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 1rem;
    transition: box-shadow 0.3s;
}

.glass-card:hover {
    box-shadow: var(--shadow-md);
}

/* ─── Section Header ───────────────────────────────────── */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

.section-header h2 {
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: -0.3px;
    margin: 0;
}

/* ─── Buttons ──────────────────────────────────────────── */
.btn-accent {
    background: var(--accent);
    color: #fff;
    border: none;
    font-weight: 600;
    transition: all 0.2s;
}

.btn-accent:hover {
    background: var(--accent-hover);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.btn-diagram {
    background: var(--bg-card-solid);
    border: 1px solid var(--border);
    color: var(--text-primary);
    font-weight: 500;
    font-size: 0.85rem;
    padding: 6px 16px;
    border-radius: 100px;
    transition: all 0.2s;
}

.btn-diagram:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-soft);
}

.btn-diagram.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

/* ─── Diagram Category Tabs ────────────────────────────── */
.diagram-tabs .nav-link {
    font-size: 0.82rem;
    font-weight: 600;
    padding: 6px 14px;
    border-radius: 100px;
    color: var(--text-secondary);
    background: var(--bg-card-solid);
    border: 1px solid var(--border);
    transition: all 0.2s;
}
.diagram-tabs .nav-link:hover {
    border-color: var(--accent);
    color: var(--accent);
}
.diagram-tabs .nav-link.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.2);
}

/* ─── Data Table ───────────────────────────────────────── */
#dataTable {
    font-size: 0.8rem;
}

#dataTable thead th {
    background: var(--accent);
    color: #fff;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: sticky;
    top: 0;
    z-index: 10;
    white-space: nowrap;
    padding: 10px 12px;
}

#dataTable tbody td {
    padding: 8px 12px;
    white-space: nowrap;
    font-family: var(--font-mono);
    font-size: 0.78rem;
}

#dataTable tbody tr:hover {
    background: var(--accent-soft) !important;
}

.table-responsive {
    max-height: 450px;
    overflow: auto;
    border-radius: var(--radius);
}

/* ─── Plot Container ───────────────────────────────────── */
.plot-container {
    min-height: 300px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
}

.plot-placeholder {
    text-align: center;
    padding: 3rem;
}

.plot-image {
    max-width: 100%;
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
}

.plot-loading {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    border-radius: var(--radius);
    z-index: 5;
}

.plot-actions {
    text-align: center;
}

/* ─── Indices Cards ────────────────────────────────────── */
.index-card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    text-align: center;
    transition: all 0.3s;
}

.index-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    border-color: var(--accent);
}

.index-card .index-name {
    font-weight: 700;
    font-size: 1rem;
    color: var(--accent);
    margin-bottom: .5rem;
    font-family: var(--font-mono);
}

.index-card .index-stat {
    font-family: var(--font-mono);
    font-size: 0.82rem;
}

.index-card .index-stat span {
    display: block;
    line-height: 1.6;
}

.index-card .index-stat .label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    font-family: var(--font-main);
    font-weight: 600;
}

body.rtl-mode .index-card .index-stat .label {
    font-family: var(--font-fa);
}

/* ─── CIPW ─────────────────────────────────────────────── */
#cipwInputs .form-control {
    font-family: var(--font-mono);
    font-size: 0.85rem;
}

#cipwInputs label {
    font-family: var(--font-mono);
}

.cipw-mineral {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

.cipw-mineral:last-child {
    border-bottom: none;
}

.cipw-mineral .mineral-name {
    font-weight: 600;
    color: var(--accent);
    font-family: var(--font-mono);
}

.cipw-mineral .mineral-value {
    font-family: var(--font-mono);
    font-size: 0.9rem;
}

/* ─── Footer ───────────────────────────────────────────── */
.app-footer {
    background: var(--bg-card-solid);
    border-top: 1px solid var(--border);
    font-size: 0.9rem;
}

.footer-cv-link {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.88rem;
    padding: 4px 14px;
    border: 1px solid var(--accent-soft);
    border-radius: 100px;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.footer-cv-link:hover {
    background: var(--accent-soft);
    color: var(--accent-hover);
    border-color: var(--accent);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.15);
}

/* ─── Toast custom ─────────────────────────────────────── */
.toast {
    border: none;
    border-radius: var(--radius);
    backdrop-filter: blur(12px);
    box-shadow: var(--shadow-lg);
}

/* ─── Scrollbar ────────────────────────────────────────── */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(100, 116, 139, 0.3);
    border-radius: 100px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(100, 116, 139, 0.5);
}

/* ─── Responsive ───────────────────────────────────────── */
@media (max-width: 992px) {
    .hero-section {
        padding: 3rem 1rem 2rem;
    }
    .hero-title {
        font-size: 2rem;
    }
    .section-header {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (max-width: 576px) {
    .hero-section {
        padding: 2.5rem 0.5rem 1.5rem;
    }
    .upload-zone {
        padding: 1.5rem 1rem;
    }
    .btn-diagram {
        font-size: 0.78rem;
        padding: 5px 12px;
    }
    .glass-card {
        padding: 0.75rem;
    }
    .table-responsive {
        max-height: 350px;
    }
    #dataTable {
        font-size: 0.72rem;
    }
    .plot-container {
        min-height: 220px;
    }
    .footer-cv-link {
        font-size: 0.8rem;
    }
}

/* ─── Animations ───────────────────────────────────────── */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}

.fade-in-up {
    animation: fadeInUp 0.5s ease both;
}

.fade-in-up-delay-1 { animation-delay: 0.1s; }
.fade-in-up-delay-2 { animation-delay: 0.2s; }
.fade-in-up-delay-3 { animation-delay: 0.3s; }
