/* --- 1. Color and Style Variables --- */
:root {
    --bg-color: #101015;
    --box-bg: #1a1a1f;
    --card-bg: #1f1f23;
    --primary-glow: rgba(20, 210, 184, 0.5);
    --primary-color: #14D2B8;
    --border-color: rgba(255, 255, 255, 0.1);
    --text-color: #e5e7eb;
    --text-muted: #9ca3af;
    --shadow-color: rgba(0,0,0,0.2);
    --chart-grid-color: rgba(255, 255, 255, 0.1);
    --danger-bg: rgba(239, 68, 68, 0.05);
    --danger-border: rgba(239, 68, 68, 0.2);
    --danger-text-header: #f87171;
    --danger-text-body: #fca5a5;
}

.light-theme {
    --bg-color: #F8F7F4;
    --box-bg: #FFFFFF;
    --card-bg: #FFFFFF;
    --primary-glow: rgba(13, 148, 136, 0.3);
    --primary-color: #0D9488;
    --border-color: rgba(0, 0, 0, 0.08);
    --text-color: #3D405B;
    --text-muted: #6b7280;
    --shadow-color: rgba(61, 64, 91, 0.1);
    --chart-grid-color: rgba(0, 0, 0, 0.08);
    --danger-bg: #FEF2F2;
    --danger-border: #FEE2E2;
    --danger-text-header: #B91C1C;
    --danger-text-body: #7F1D1D;
}

/* --- 2. General Body and Layout Styles --- */
html { 
    scroll-behavior: smooth; 
}

body {
    font-family: 'Vazirmatn', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    transition: background-color 0.3s ease, color 0.3s ease;
}

.main-container {
     max-width: 1200px;
     margin: 0 auto;
     padding: 20px 1rem;
}
@media (min-width: 768px) {
    .main-container { padding: 50px 1rem; }
}

/* --- 3. Shared Component Styles --- */

.static-header {
    position: sticky; top: 0; z-index: 1000;
    background-color: var(--box-bg); 
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    display: flex; align-items: center; justify-content: space-between; 
    padding: 0 1rem; 
    height: 60px; 
    transition: box-shadow 0.3s ease, background-color 0.3s ease;
}
@media (min-width: 768px) {
    .static-header {
        padding: 0 2rem;
        height: 80px;
    }
}
.static-header.scrolled {
    box-shadow: 0 4px 12px var(--shadow-color);
}

.site-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-color);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
    flex-grow: 1;
    padding: 0 0.5rem;
}
@media (min-width: 640px) {
    .site-title { font-size: 1.25rem; }
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
@media (min-width: 640px) {
    .header-actions { gap: 0.75rem; }
}

footer {
    background-color: var(--box-bg);
    border-top: 1px solid var(--border-color);
}

.header-button {
    background: none; border: 1px solid var(--text-muted); color: var(--text-muted);
    width: 36px; height: 36px; 
    border-radius: 50%; cursor: pointer;
    display: flex; justify-content: center; align-items: center;
    transition: all 0.4s ease;
    text-decoration: none;
}
@media (min-width: 640px) {
    .header-button { width: 40px; height: 40px; }
}
.header-button:hover { color: var(--primary-color); border-color: var(--primary-color); transform: scale(1.1); }
.header-button svg { width: 18px; height: 18px; }
@media (min-width: 640px) {
    .header-button svg { width: 20px; height: 20px; }
}

.content-box {
    background-color: var(--box-bg);
    border-radius: 1.5rem; 
    padding: 1.5rem;
    margin-bottom: 2rem;
    border: 1px solid var(--border-color);
    box-shadow: 0 10px 30px -10px var(--shadow-color);
}
@media (min-width: 768px) {
    .content-box {
        border-radius: 24px;
        padding: 3rem;
        margin-bottom: 3rem;
    }
}

/* --- 4. Typography & Content Styles --- */

.section-title {
    font-size: 1.75rem; 
    font-weight: 800;
    text-align: center;
    margin-bottom: 3rem;
    position: relative;
    color: var(--text-color);
}
@media (min-width: 768px) {
    .section-title { font-size: 2.5rem; margin-bottom: 4rem; }
}
.section-title::after {
    content: '';
    position: absolute;
    bottom: -15px;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 4px;
    background: var(--primary-color);
    border-radius: 2px;
}

.prose { color: var(--text-muted); line-height: 1.6; }
.prose h1, .prose h2, .prose h3 { font-weight: bold; margin-top: 1em; margin-bottom: 0.5em; color: var(--text-color); }
.prose h4 { font-weight: 700; font-size: 1.1rem; margin-bottom: 1rem; color: var(--text-color); }
@media (min-width: 768px) {
    .prose { line-height: 1.7; }
    .prose h4 { font-size: 1.25rem; }
}
.prose p { margin-bottom: 1rem; }
.prose strong { font-weight: 700; color: var(--text-color); }
.prose blockquote {
    border-right: 4px solid var(--border-color);
    padding-right: 1rem; margin-right: 0; font-style: italic;
}
.prose ul, .prose ol { padding-right: 1.5rem; }
.prose ul { list-style-type: disc; }
.prose li { margin-bottom: 0.5rem; }
.prose a { color: var(--primary-color); text-decoration: none; transition: color 0.2s; }
.prose a:hover { text-decoration: underline; color: var(--primary-glow); }

.prose .danger-header { color: var(--danger-text-header); }
.prose .danger-text { color: var(--danger-text-body); }

/* --- 5. Page-Specific Styles --- */

.page-card { 
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 12px var(--shadow-color);
    border-radius: 1.5rem;
    padding: 1.25rem; 
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    height: 100%;
}
@media (min-width: 768px) {
    .page-card { padding: 1.5rem; }
}
.page-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 15px -3px var(--shadow-color);
}

.tab-btn { color: var(--text-muted); white-space: nowrap; }
.tab-btn.active { background-color: var(--primary-color); color: var(--bg-color); }

.amcc-chart-container { 
    position: relative;
    width: 100%;
    margin-left: auto;
    margin-right: auto;
    height: 250px; 
}
@media (min-width: 768px) {
    .amcc-chart-container { 
        max-width: 600px;
        height: 350px;
        max-height: 400px;
    }
}

.tool-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
}
.tool-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 15px -3px var(--shadow-color);
}
.tool-card.active {
    transform: translateY(-5px);
    box-shadow: 0 0 25px var(--primary-glow);
    border-color: var(--primary-color);
}

.danger-box {
    background-color: var(--danger-bg);
    border: 1px solid var(--danger-border);
}
.danger-box .prose blockquote { 
    border-right-color: var(--danger-border); 
}

/* --- 6. Responsive Table (Mobile Cards Pattern) --- */
.table-wrapper {
    width: 100%;
    overflow: hidden;
}

.responsive-table {
    width: 100%;
    border-collapse: collapse;
}
.responsive-table th,
.responsive-table td {
    border: 1px solid var(--border-color);
    padding: 0.75rem;
    text-align: right;
    color: var(--text-muted);
}
.responsive-table th {
    background-color: rgba(128, 128, 128, 0.1);
    font-weight: bold;
    color: var(--text-color);
}

@media (max-width: 767px) {
    /* Hide table header on mobile */
    .responsive-table thead {
        display: none;
    }

    /* Turn rows into cards */
    .responsive-table,
    .responsive-table tbody,
    .responsive-table tr,
    .responsive-table td {
        display: block;
        width: 100%;
        border: none;
    }

    .responsive-table tr {
        margin-bottom: 1.5rem;
        border: 1px solid var(--border-color);
        border-radius: 1rem;
        background: var(--card-bg);
        padding: 1rem;
        box-shadow: 0 4px 12px var(--shadow-color);
    }

    .responsive-table td {
        display: flex;
        flex-direction: column;
        padding: 0.6rem 0;
        border-bottom: 1px solid var(--border-color);
    }

    .responsive-table td:last-child {
        border-bottom: none;
    }

    /* Add labels using data-label attribute */
    .responsive-table td::before {
        content: attr(data-label);
        font-weight: bold;
        color: var(--primary-color);
        margin-bottom: 0.25rem;
        font-size: 0.9rem;
    }
}
