:root {
    /* Light Mode Palette - Vibrant & Premium */
    --bg-color: #f8fafc;
    --surface-color: rgba(255, 255, 255, 0.7);
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --accent-color: #3b82f6;
    --accent-hover: #2563eb;
    --border-color: rgba(148, 163, 184, 0.2);
    --glass-border: rgba(255, 255, 255, 0.5);
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.07);
    --blob-1: rgba(59, 130, 246, 0.4);
    --blob-2: rgba(236, 72, 153, 0.3);
    --blob-blur: 100px;
    --transition-speed: 0.3s;
}

[data-theme="dark"] {
    /* Dark Mode Palette - Deep & Sleek */
    --bg-color: #0f172a;
    --surface-color: rgba(30, 41, 59, 0.7);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent-color: #60a5fa;
    --accent-hover: #93c5fd;
    --border-color: rgba(148, 163, 184, 0.1);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
    --blob-1: rgba(96, 165, 250, 0.2);
    --blob-2: rgba(244, 114, 182, 0.15);
    --blob-blur: 120px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    transition: background-color var(--transition-speed) ease, color var(--transition-speed) ease;
}

/* Dynamic Typography based on Direction */
[dir="rtl"] body {
    font-family: 'Cairo', sans-serif;
}

/* Smart Canvas Background */
.smart-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    pointer-events: none; /* Let clicks pass through to app */
    background: var(--bg-color);
    transition: background-color var(--transition-speed) ease;
}

.container {
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    flex: 1;
}

/* Header */
.app-header {
    background: var(--surface-color);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 10;
    transition: background var(--transition-speed) ease, border-color var(--transition-speed) ease;
}

.header-container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-primary);
    text-decoration: none;
    display: flex;
    align-items: center;
}

.logo .dot {
    color: var(--accent-color);
}

.header-controls {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

button {
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    cursor: pointer;
    padding: 0.5rem 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-speed) ease;
    font-family: inherit;
    font-weight: 600;
}

button:hover {
    background: var(--border-color);
    transform: translateY(-1px);
}

#lang-toggle {
    min-width: 48px;
}

/* Theme Icons Toggle */
[data-theme="light"] .moon-icon { display: none; }
[data-theme="dark"] .sun-icon { display: none; }

/* Grid for Tools */
/* Colors by Category */
[data-cat="math"] { --c-rgb: 59, 130, 246; } /* Blue */
[data-cat="text"] { --c-rgb: 245, 158, 11; } /* Amber */
[data-cat="digital"] { --c-rgb: 139, 92, 246; } /* Violet */
[data-cat="health"] { --c-rgb: 16, 185, 129; } /* Emerald */
[data-cat="dev"] { --c-rgb: 6, 182, 212; } /* Cyan */
[data-cat="productivity"] { --c-rgb: 239, 68, 68; } /* Red */
[data-cat="media"] { --c-rgb: 236, 72, 153; } /* Pink */
[data-cat="pdf"] { --c-rgb: 220, 38, 38; } /* Crimson Red */
[data-cat="all"] { --c-rgb: 59, 130, 246; } /* Default Blue */

.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 1.25rem;
    margin-top: 1.5rem;
}

.tool-card {
    --card-color: rgb(var(--c-rgb, 59, 130, 246));
    --card-color-light: rgba(var(--c-rgb, 59, 130, 246), 0.15);
    background: var(--surface-color);
    border: 1px solid var(--glass-border);
    border-top: 3px solid var(--card-color);
    border-radius: 16px;
    padding: 1.5rem 1rem;
    text-decoration: none;
    color: inherit;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03), inset 0 0 0 1px rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.75rem;
    position: relative;
    overflow: hidden;
}

.tool-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(135deg, rgba(var(--c-rgb, 59,130,246), 0.08) 0%, transparent 100%);
    opacity: 0;
    transition: opacity 0.4s ease;
    z-index: -1;
}

.tool-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 20px 40px -10px rgba(var(--c-rgb, 59, 130, 246), 0.25), inset 0 0 0 1px rgba(255, 255, 255, 0.2);
    border-color: var(--card-color);
}

.tool-card:hover::before {
    opacity: 1;
}

.tool-card:hover .tool-card-icon {
    transform: scale(1.25) translateY(-4px);
    background: var(--card-color);
    color: white;
    box-shadow: 0 8px 16px rgba(var(--c-rgb, 59, 130, 246), 0.3);
}

.tool-card-icon {
    font-size: 1.6rem;
    background: var(--card-color-light);
    width: 54px;
    height: 54px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 16px;
    color: var(--card-color);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    margin-bottom: 0.25rem;
}

.tool-card-title {
    font-size: 1.15rem;
    font-weight: 700;
}

.tool-card-desc {
    color: var(--text-secondary);
    font-size: 0.85rem;
    line-height: 1.4;
}

/* Categories Nav */
.categories-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: center;
    margin-bottom: 2rem;
}

.cat-tab {
    --tab-color: rgb(var(--c-rgb, 59, 130, 246));
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 30px;
    padding: 0.5rem 1.25rem;
    color: var(--text-secondary);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-speed) ease;
    font-size: 0.95rem;
}

.cat-tab:hover {
    background: var(--surface-color);
    border-color: var(--tab-color);
    color: var(--tab-color);
}

.cat-tab.active {
    background: var(--tab-color);
    color: white;
    border-color: var(--tab-color);
    box-shadow: 0 4px 12px rgba(var(--c-rgb, 59, 130, 246), 0.3);
}

/* Tool Inner View */
.tool-view-header {
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}
.back-btn {
    text-decoration: none;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    transition: color 0.2s, transform 0.2s;
}
.back-btn:hover {
    color: var(--accent-color);
    transform: translateX(var(--rtl-back-dir, -4px));
}
[dir="rtl"] .back-btn {
    --rtl-back-dir: 4px;
}
.back-btn svg {
    transform: rotate(var(--rtl-back-rot, 0deg));
}
[dir="rtl"] .back-btn svg {
    --rtl-back-rot: 180deg;
}

.tool-view-title {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 2rem;
}

.glass-panel {
    background: var(--surface-color);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 2rem;
    box-shadow: var(--glass-shadow);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

/* Shared UI Components for Tools */
input, textarea, select {
    width: 100%;
    padding: 0.75rem 1rem;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}
input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}
.primary-btn {
    background: var(--accent-color);
    color: #fff;
    border: none;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    border-radius: 8px;
    font-weight: 600;
}
.primary-btn:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

/* Footer - World Class Design */
.app-footer {
    background: var(--surface-color);
    padding: 4rem 2rem 1.5rem;
    border-top: 1px solid var(--border-color);
    margin-top: auto;
    font-size: 0.95rem;
}
.footer-container {
    max-width: 1000px;
    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 2rem;
    padding-bottom: 2.5rem;
    border-bottom: 1px solid var(--border-color);
}
.footer-brand {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    text-align: right;
}
[dir="ltr"] .footer-brand {
    text-align: left;
}
.footer-logo {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text-primary);
    display: flex;
    align-items: center;
}
.footer-logo .dot {
    color: var(--accent-color);
}
#footer-slogan {
    color: var(--text-secondary);
    margin: 0;
    font-size: 1rem;
}
.footer-links {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
}
.footer-links a {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s ease;
    position: relative;
}
.footer-links a::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--accent-color);
    transition: width 0.3s ease;
}
.footer-links a:hover {
    color: var(--text-primary);
}
.footer-links a:hover::after {
    width: 100%;
}
.footer-bottom {
    text-align: center;
    padding-top: 1.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}
#footer-credit {
    margin: 0;
    font-weight: 500;
}
.heart {
    color: #ef4444;
    display: inline-block;
    animation: heartbeat 1.5s infinite;
}

@keyframes heartbeat {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

@media (max-width: 768px) {
    .footer-container {
        flex-direction: column;
        text-align: center;
        justify-content: center;
    }
    .footer-brand {
        text-align: center;
        align-items: center;
    }
    [dir="ltr"] .footer-brand {
        text-align: center;
    }
    .footer-links {
        justify-content: center;
        gap: 1.5rem;
    }
}

/* Static Pages Styles */
.static-page-content h3 {
    font-size: 1.4rem;
    color: var(--accent-color);
    margin-top: 2.5rem;
    margin-bottom: 1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.static-page-content p {
    font-size: 1.05rem;
    color: var(--text-secondary);
    line-height: 1.8;
    margin-bottom: 1.5rem;
}
.static-page-content ul {
    margin-bottom: 1.5rem;
    padding-inline-start: 1.5rem;
    color: var(--text-secondary);
    line-height: 1.8;
    font-size: 1.05rem;
}
.static-page-content li {
    margin-bottom: 0.75rem;
}
.static-page-content strong {
    color: var(--text-primary);
}

/* Animations */
.fade-in {
    animation: fadeIn 0.4s ease forwards;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Search Bar */
.search-container {
    max-width: 500px;
    margin: 0 auto 2rem auto;
    position: relative;
    display: flex;
    align-items: center;
}
.search-container svg {
    position: absolute;
    color: var(--text-secondary);
    left: 1rem;
}
[dir="rtl"] .search-container svg {
    left: auto;
    right: 1rem;
}
.search-input {
    width: 100%;
    padding: 1rem 3rem;
    border-radius: 50px;
    border: 1px solid var(--border-color);
    background: var(--surface-color);
    color: var(--text-primary);
    font-size: 1.1rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
}
.search-input:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.2);
    outline: none;
}

/* Back to Top Button */
.back-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--accent-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
    z-index: 1000;
}
[dir="rtl"] .back-to-top {
    right: auto;
    left: 2rem;
}
.back-to-top.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}
.back-to-top:hover {
    background: var(--accent-hover);
    transform: translateY(-5px);
    box-shadow: 0 8px 16px rgba(59, 130, 246, 0.6);
}

/* Extra Sections (FAQ & Reviews) */
.extra-section {
    margin-top: 6rem;
    padding-top: 3rem;
    border-top: 1px solid var(--border-color);
}
.section-title {
    text-align: center;
    font-size: 2.2rem;
    font-weight: 800;
    margin-bottom: 3rem;
    color: var(--text-primary);
}

.faq-grid {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-width: 800px;
    margin: 0 auto;
}
.faq-card {
    background: var(--surface-color);
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    overflow: hidden;
    transition: all 0.3s ease;
}
.faq-q {
    font-weight: 700;
    font-size: 1.1rem;
    padding: 1.25rem 1.5rem;
    margin: 0;
    color: var(--text-primary);
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
    transition: background 0.2s;
}
.faq-q:hover {
    background: rgba(59, 130, 246, 0.05);
}
.faq-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    background: rgba(59, 130, 246, 0.1);
    color: var(--accent-color);
    border-radius: 50%;
    font-size: 0.9rem;
    flex-shrink: 0;
}
.faq-chevron {
    transition: transform 0.3s ease;
    color: var(--text-secondary);
}
.faq-card.active .faq-chevron {
    transform: rotate(180deg);
    color: var(--accent-color);
}
.faq-card.active .faq-q {
    border-bottom: 1px solid var(--border-color);
}
.faq-a-wrapper {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.3s ease;
}
.faq-card.active .faq-a-wrapper {
    grid-template-rows: 1fr;
}
.faq-a {
    overflow: hidden;
    color: var(--text-secondary);
    line-height: 1.6;
    font-size: 0.95rem;
    margin: 0;
    padding: 0 1.5rem;
}
.faq-card.active .faq-a {
    padding: 1.25rem 1.5rem;
}

.reviews-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}
.review-card {
    background: var(--surface-color);
    padding: 2rem;
    border-radius: 16px;
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: transform 0.3s ease;
}
.review-card:hover {
    transform: translateY(-5px);
}
.review-text {
    font-size: 1.05rem;
    color: var(--text-primary);
    font-style: italic;
    line-height: 1.6;
    margin-bottom: 1.5rem;
}
.review-author {
    display: flex;
    align-items: center;
    gap: 1rem;
    border-top: 1px solid var(--border-color);
    padding-top: 1rem;
}
.review-avatar {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--accent-color), #8b5cf6);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.2rem;
}
.review-name {
    font-weight: 700;
    color: var(--text-primary);
}
.review-role {
    font-size: 0.85rem;
    color: var(--text-secondary);
}
