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

:root {
    --primary: #0D9488;
    --primary-dark: #0F766E;
    --secondary: #7C3AED;
    --accent: #F59E0B;
    --dark: #1E293B;
    --light-bg: #F0FDFA;
    --text: #334155;
    --text-light: #64748B;
    --white: #FFFFFF;
    --border: #E2E8F0;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --radius: 12px;
    --radius-sm: 8px;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Tajawal', sans-serif;
    font-weight: 400;
    line-height: 1.7;
    color: var(--text);
    background-color: var(--white);
    min-height: 100vh;
}

html[dir="rtl"] body {
    text-align: right;
}

/* ===== Typography ===== */
h1, h2, h3, h4, h5, h6 {
    font-family: 'Tajawal', sans-serif;
    font-weight: 700;
    color: var(--dark);
    line-height: 1.3;
}

h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }

p { margin-bottom: 1rem; }

a {
    color: var(--primary);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: var(--primary-dark);
}

/* ===== Container ===== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* ===== Navigation ===== */
.navbar {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: var(--white);
    border-bottom: 1px solid var(--border);
    padding: 1rem 0;
}

.navbar .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: var(--primary);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-size: 1.25rem;
}

.nav-links {
    display: flex;
    list-style: none;
    gap: 2rem;
    align-items: center;
}

.nav-links a {
    color: var(--text);
    font-weight: 500;
    padding: 0.5rem 0;
    position: relative;
}

.nav-links a::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 0;
    height: 2px;
    background: var(--primary);
    transition: width 0.3s;
}

.nav-links a:hover::after,
.nav-links a.active::after {
    width: 100%;
}

.nav-links a:hover,
.nav-links a.active {
    color: var(--primary);
}

.mobile-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
}

.mobile-toggle span {
    display: block;
    width: 25px;
    height: 3px;
    background: var(--dark);
    margin: 5px 0;
    border-radius: 2px;
    transition: all 0.3s;
}

/* ===== Hero Section ===== */
.hero {
    background: linear-gradient(135deg, var(--light-bg) 0%, var(--white) 100%);
    padding: 4rem 0;
    text-align: center;
}

.hero h1 {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.hero .tagline {
    font-size: 1.25rem;
    color: var(--text-light);
    margin-bottom: 2rem;
}

.hero-stats {
    display: flex;
    justify-content: center;
    gap: 3rem;
    margin-top: 3rem;
    flex-wrap: wrap;
}

.stat-item {
    text-align: center;
}

.stat-number {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    color: var(--text-light);
    font-size: 0.95rem;
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 1.75rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s;
    border: none;
    font-family: inherit;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    color: var(--white);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

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

.btn-secondary:hover {
    background: #6D28D9;
    color: var(--white);
}

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

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

/* ===== Cards ===== */
.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    transition: all 0.3s;
}

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

.card-icon {
    width: 60px;
    height: 60px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    margin-bottom: 1rem;
}

.card-icon.health { background: #CCFBF1; color: var(--primary); }
.card-icon.finance { background: #EDE9FE; color: var(--secondary); }
.card-icon.home { background: #FEF3C7; color: var(--accent); }
.card-icon.time { background: #DBEAFE; color: #3B82F6; }
.card-icon.convert { background: #FCE7F3; color: #EC4899; }

.card h3 {
    font-size: 1.25rem;
    margin-bottom: 0.75rem;
}

.card p {
    color: var(--text-light);
    font-size: 0.95rem;
    margin-bottom: 1rem;
}

.card-link {
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

/* ===== Section Styles ===== */
.section {
    padding: 4rem 0;
}

.section-header {
    text-align: center;
    margin-bottom: 3rem;
}

.section-header h2 {
    margin-bottom: 0.75rem;
}

.section-header p {
    color: var(--text-light);
    max-width: 600px;
    margin: 0 auto;
}

/* ===== Tools Grid ===== */
.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.tool-card {
    padding: 1.5rem;
}

.tool-card .card-icon {
    width: 50px;
    height: 50px;
    font-size: 1.5rem;
}

/* ===== Articles ===== */
.articles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 2rem;
}

.article-card {
    overflow: hidden;
    padding: 0;
}

.article-card .article-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
}

.article-card .card-content {
    padding: 1.5rem;
}

.article-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.875rem;
    color: var(--text-light);
    margin-bottom: 0.75rem;
}

.article-category {
    background: var(--light-bg);
    color: var(--primary);
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
}

.read-time {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

/* ===== Filter ===== */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: center;
    margin-bottom: 2rem;
}

.filter-btn {
    padding: 0.5rem 1.25rem;
    border-radius: 25px;
    border: 1px solid var(--border);
    background: var(--white);
    color: var(--text);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    font-size: 0.95rem;
}

.filter-btn:hover,
.filter-btn.active {
    background: var(--primary);
    color: var(--white);
    border-color: var(--primary);
}

/* ===== Tool Page ===== */
.tool-page {
    padding-top: 2rem;
    padding-bottom: 4rem;
}

.tool-header {
    text-align: center;
    margin-bottom: 2rem;
}

.tool-container {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 2rem;
    align-items: start;
}

.tool-main {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2rem;
}

.tool-sidebar {
    position: sticky;
    top: 100px;
}

.related-tools h3 {
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.related-tool-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem;
    border-radius: var(--radius-sm);
    background: var(--light-bg);
    margin-bottom: 0.75rem;
    transition: all 0.2s;
}

.related-tool-item:hover {
    background: var(--primary);
    color: var(--white);
}

.related-tool-item .icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.related-tool-item:hover .icon {
    background: rgba(255,255,255,0.2);
}

.related-tool-item span {
    font-weight: 500;
    font-size: 0.95rem;
}

/* ===== Form Elements ===== */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--dark);
}

.form-control {
    width: 100%;
    padding: 0.875rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.1);
}

select.form-control {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%23334155' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left 1rem center;
    padding-left: 2.5rem;
}

html[dir="rtl"] select.form-control {
    background-position: right 1rem center;
    padding-left: 1rem;
    padding-right: 2.5rem;
}

.input-group {
    display: flex;
    gap: 0.5rem;
}

.input-group .form-control {
    flex: 1;
}

.input-suffix {
    display: flex;
    align-items: center;
    padding: 0 1rem;
    background: var(--light-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-light);
    font-weight: 500;
}

.radio-group, .checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.radio-item, .checkbox-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.radio-item input, .checkbox-item input {
    width: 20px;
    height: 20px;
    accent-color: var(--primary);
    cursor: pointer;
}

/* ===== Result Display ===== */
.result-box {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--white);
    border-radius: var(--radius);
    padding: 1.5rem;
    text-align: center;
    margin-top: 1.5rem;
}

.result-box.large {
    padding: 2rem;
}

.result-label {
    font-size: 0.95rem;
    opacity: 0.9;
    margin-bottom: 0.5rem;
}

.result-value {
    font-size: 2.5rem;
    font-weight: 700;
    line-height: 1.2;
}

.result-value.small {
    font-size: 1.75rem;
}

.result-unit {
    font-size: 1rem;
    opacity: 0.9;
    margin-top: 0.25rem;
}

.result-details {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255,255,255,0.2);
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1rem;
}

.result-detail-item {
    text-align: center;
}

.result-detail-label {
    font-size: 0.8rem;
    opacity: 0.8;
}

.result-detail-value {
    font-size: 1.25rem;
    font-weight: 600;
}

/* ===== Article Page ===== */
.article-page {
    padding-top: 2rem;
    padding-bottom: 4rem;
}

.article-hero {
    position: relative;
    height: 400px;
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 2rem;
}

.article-hero img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.article-hero-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 2rem;
    background: linear-gradient(transparent, rgba(0,0,0,0.7));
    color: var(--white);
}

.article-hero-overlay h1 {
    color: var(--white);
    font-size: 2rem;
    margin-bottom: 0.75rem;
}

.article-content-wrapper {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 2rem;
    align-items: start;
}

.article-content {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2rem;
}

.article-content h2 {
    font-size: 1.5rem;
    margin-top: 2rem;
    margin-bottom: 1rem;
}

.article-content h3 {
    font-size: 1.25rem;
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
}

.article-content p {
    margin-bottom: 1.25rem;
    line-height: 1.9;
}

.article-content ul, .article-content ol {
    margin-bottom: 1.25rem;
    padding-right: 1.5rem;
}

html[dir="rtl"] .article-content ul, 
html[dir="rtl"] .article-content ol {
    padding-right: 1.5rem;
    padding-left: 0;
}

.article-content li {
    margin-bottom: 0.5rem;
}

.article-sidebar {
    position: sticky;
    top: 100px;
}

.toc {
    background: var(--light-bg);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.toc h3 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.toc ul {
    list-style: none;
}

.toc li {
    margin-bottom: 0.5rem;
}

.toc a {
    color: var(--text);
    font-size: 0.95rem;
    transition: color 0.2s;
}

.toc a:hover {
    color: var(--primary);
}

.article-author {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    text-align: center;
}

.author-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    margin: 0 auto 1rem;
    object-fit: cover;
}

.author-name {
    font-weight: 600;
    font-size: 1.1rem;
    margin-bottom: 0.25rem;
}

.author-title {
    color: var(--text-light);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
}

.tag {
    background: var(--light-bg);
    color: var(--primary);
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
}

/* ===== About Page ===== */
.about-hero {
    background: linear-gradient(135deg, var(--light-bg) 0%, var(--white) 100%);
    padding: 4rem 0;
    text-align: center;
}

.about-content {
    padding: 4rem 0;
}

.about-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3rem;
    align-items: center;
}

.about-text h2 {
    margin-bottom: 1.5rem;
}

.about-text p {
    color: var(--text-light);
    font-size: 1.1rem;
    line-height: 1.8;
}

.about-values {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
    margin-top: 2rem;
}

.value-item {
    background: var(--light-bg);
    padding: 1.5rem;
    border-radius: var(--radius);
}

.value-item h4 {
    color: var(--primary);
    margin-bottom: 0.5rem;
}

/* ===== Contact Page ===== */
.contact-section {
    padding: 4rem 0;
}

.contact-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3rem;
}

.contact-form {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2rem;
}

.contact-form h2 {
    margin-bottom: 1.5rem;
}

.contact-info {
    background: var(--primary);
    color: var(--white);
    border-radius: var(--radius);
    padding: 2rem;
}

.contact-info h3 {
    color: var(--white);
    margin-bottom: 1.5rem;
}

.contact-item {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.contact-item .icon {
    width: 40px;
    height: 40px;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.contact-item p {
    margin: 0;
    opacity: 0.9;
}

.faq-section {
    margin-top: 4rem;
}

.faq-item {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 1rem;
    overflow: hidden;
}

.faq-question {
    padding: 1.25rem 1.5rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.faq-question:hover {
    background: var(--light-bg);
}

.faq-answer {
    padding: 0 1.5rem 1.25rem;
    color: var(--text-light);
    display: none;
}

.faq-item.active .faq-answer {
    display: block;
}

.faq-item.active .faq-question .icon {
    transform: rotate(180deg);
}

/* ===== Legal Pages ===== */
.legal-page {
    padding: 3rem 0;
}

.legal-content {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 3rem;
    max-width: 800px;
    margin: 0 auto;
}

.legal-content h1 {
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border);
}

.legal-content h2 {
    font-size: 1.3rem;
    margin-top: 2rem;
    margin-bottom: 1rem;
}

.legal-content p {
    margin-bottom: 1rem;
    line-height: 1.8;
}

/* ===== 404 Page ===== */
.error-page {
    min-height: 60vh;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 4rem 1.5rem;
}

.error-content h1 {
    font-size: 8rem;
    color: var(--primary);
    line-height: 1;
    margin-bottom: 1rem;
}

.error-content h2 {
    margin-bottom: 1rem;
}

.error-content p {
    color: var(--text-light);
    margin-bottom: 2rem;
}

/* ===== Footer ===== */
.footer {
    background: var(--dark);
    color: var(--white);
    padding: 3rem 0 1.5rem;
}

html[dir="rtl"] .footer {
    text-align: right;
}

.footer-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    gap: 2rem;
    margin-bottom: 2rem;
}

.footer-brand .logo {
    color: var(--white);
    margin-bottom: 1rem;
}

.footer-brand p {
    color: rgba(255,255,255,0.7);
    font-size: 0.95rem;
}

.footer h4 {
    color: var(--white);
    font-size: 1.1rem;
    margin-bottom: 1.25rem;
}

.footer-links {
    list-style: none;
}

.footer-links li {
    margin-bottom: 0.75rem;
}

.footer-links a {
    color: rgba(255,255,255,0.7);
    transition: color 0.2s;
}

.footer-links a:hover {
    color: var(--white);
}

.footer-bottom {
    border-top: 1px solid rgba(255,255,255,0.1);
    padding-top: 1.5rem;
    text-align: center;
    color: rgba(255,255,255,0.6);
    font-size: 0.9rem;
}

/* ===== Utilities ===== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

/* ===== Responsive ===== */
@media (max-width: 1024px) {
    .tool-container,
    .article-content-wrapper {
        grid-template-columns: 1fr;
    }
    
    .tool-sidebar,
    .article-sidebar {
        position: static;
    }
    
    .about-grid,
    .contact-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    h1 { font-size: 2rem; }
    h2 { font-size: 1.75rem; }
    
    .hero h1 { font-size: 2.25rem; }
    .hero-stats { gap: 1.5rem; }
    .stat-number { font-size: 2rem; }
    
    .nav-links {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--white);
        flex-direction: column;
        padding: 1rem;
        gap: 0;
        border-bottom: 1px solid var(--border);
        box-shadow: var(--shadow);
    }
    
    html[dir="rtl"] .nav-links {
        left: auto;
        right: 0;
    }
    
    .nav-links.active {
        display: flex;
    }
    
    .nav-links li {
        width: 100%;
    }
    
    .nav-links a {
        display: block;
        padding: 0.875rem 0;
        border-bottom: 1px solid var(--border);
    }
    
    .mobile-toggle {
        display: block;
    }
    
    .section { padding: 3rem 0; }
    
    .tools-grid,
    .articles-grid {
        grid-template-columns: 1fr;
    }
    
    .footer-grid {
        grid-template-columns: 1fr 1fr;
    }
    
    .about-values {
        grid-template-columns: 1fr;
    }
    
    .article-hero { height: 250px; }
    .article-hero-overlay h1 { font-size: 1.5rem; }
}

@media (max-width: 480px) {
    .container { padding: 0 1rem; }
    
    .hero-stats { flex-direction: column; gap: 1rem; }
    
    .footer-grid {
        grid-template-columns: 1fr;
    }
    
    .result-details {
        grid-template-columns: 1fr 1fr;
    }
}

/* ===== Animations ===== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeIn 0.5s ease-out forwards;
}

.animate-delay-1 { animation-delay: 0.1s; }
.animate-delay-2 { animation-delay: 0.2s; }
.animate-delay-3 { animation-delay: 0.3s; }
.animate-delay-4 { animation-delay: 0.4s; }
.animate-delay-5 { animation-delay: 0.5s; }
.animate-delay-6 { animation-delay: 0.6s; }

/* ===== Print ===== */
@media print {
    .navbar, .footer, .tool-sidebar, .article-sidebar {
        display: none;
    }
    
    .tool-container,
    .article-content-wrapper {
        grid-template-columns: 1fr;
    }
}
