:root {
    --bg-color: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.7);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border-color: rgba(255, 255, 255, 0.1);
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Cairo', sans-serif; }
html { scroll-behavior: smooth; }

body {
    background-color: var(--bg-color);
    background-image: 
        linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px),
        radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(16, 185, 129, 0.15) 0px, transparent 50%),
        radial-gradient(at 50% 50%, rgba(244, 63, 94, 0.05) 0px, transparent 50%);
    background-size: 50px 50px, 50px 50px, 100% 100%, 100% 100%, 100% 100%;
    background-attachment: fixed;
    color: var(--text-main);
    min-height: 100vh;
    animation: bgPulse 15s ease-in-out infinite alternate;
    transition: background-color 0.5s, color 0.5s;
}

/* Light Mode Theme */
body.light-mode {
    --bg-color: #f1f5f9;
    --card-bg: rgba(255, 255, 255, 0.85);
    --text-main: #0f172a;
    --text-muted: #475569;
    --border-color: rgba(0, 0, 0, 0.1);
}

body.light-mode .main-header {
    background: rgba(255, 255, 255, 0.7);
    box-shadow: 0 10px 30px -10px rgba(0,0,0,0.1);
}
body.light-mode .logo { color: #0f172a; text-shadow: none; }
body.light-mode nav a { color: #475569; }
body.light-mode nav a:hover { color: #6366f1; }
body.light-mode .hero-text h1 { background: linear-gradient(135deg, #0f172a 0%, #475569 100%); -webkit-background-clip: text; }
body.light-mode .search-input { background: rgba(255, 255, 255, 0.9); color: #0f172a; box-shadow: 0 10px 25px rgba(0,0,0,0.05); }
body.light-mode .chip { background: rgba(255, 255, 255, 0.8); color: #475569; }
body.light-mode .chip.active { color: #fff; }
body.light-mode .section-title { color: #0f172a; }
body.light-mode .stat-box { background: rgba(255,255,255,0.8); }
body.light-mode .faq-item { background: rgba(255,255,255,0.8); }
body.light-mode .faq-question { color: #0f172a; }
body.light-mode .main-footer { background: rgba(255, 255, 255, 0.7); color: #475569; }
body.light-mode .footer-col h4 { color: #0f172a; }

@keyframes bgPulse {
    0% { background-position: 0% 0%; }
    100% { background-position: 100% 100%; }
}

/* Header */
.main-header {
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 20px;
    position: sticky;
    top: 20px;
    z-index: 100;
    max-width: 1160px;
    margin: 20px auto 0;
    box-shadow: 0 10px 30px -10px rgba(0,0,0,0.5);
}

.header-content {
    padding: 15px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.6rem;
    font-weight: 900;
    color: #fff;
    text-shadow: 0 0 20px rgba(99, 102, 241, 0.5);
}

.logo ion-icon { color: #6366f1; animation: float 3s ease-in-out infinite; }

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
}

nav a {
    color: var(--text-muted);
    text-decoration: none;
    margin-right: 20px;
    font-weight: 600;
    transition: color 0.3s;
}

nav a:hover { color: #fff; }

.theme-toggle {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    margin-right: 20px;
    outline: none;
}
.theme-toggle:hover { color: #6366f1; transform: rotate(15deg) scale(1.1); }

/* Hero */
.hero {
    padding: 100px 20px 80px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.hero::before {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 600px; height: 600px;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.2) 0%, transparent 60%);
    z-index: -1;
    border-radius: 50%;
    animation: pulseBlob 8s infinite alternate;
}

@keyframes pulseBlob {
    0% { transform: translate(-50%, -50%) scale(1); }
    100% { transform: translate(-50%, -50%) scale(1.2); }
}

.hero-text h1 {
    font-size: 3.5rem;
    font-weight: 900;
    margin-bottom: 20px;
    line-height: 1.3;
    background: linear-gradient(135deg, #fff 0%, #94a3b8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero-text p {
    font-size: 1.2rem;
    color: var(--text-muted);
    max-width: 600px;
    margin: 0 auto 30px;
}

/* Search Bar */
.search-container {
    max-width: 500px;
    margin: 0 auto;
    position: relative;
}

.search-input {
    width: 100%;
    padding: 18px 50px 18px 50px;
    border-radius: 30px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    font-size: 1.1rem;
    outline: none;
    backdrop-filter: blur(10px);
    transition: all 0.3s;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
}

.search-input:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.3), 0 10px 25px rgba(0,0,0,0.3);
}

.search-icon {
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 1.3rem;
}

/* Filter Chips */
.filter-chips {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    margin-top: 30px;
}

.chip {
    background: rgba(30, 41, 59, 0.6);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 10px 20px;
    border-radius: 30px;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
    backdrop-filter: blur(5px);
}

.chip:hover {
    background: rgba(99, 102, 241, 0.1);
    color: #fff;
    border-color: rgba(99, 102, 241, 0.4);
}

.chip.active {
    background: linear-gradient(135deg, #6366f1, #a855f7);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 5px 15px rgba(99, 102, 241, 0.4);
}

/* Main Grid */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px 80px;
}

.section-title {
    font-size: 1.5rem;
    margin-bottom: 25px;
    margin-top: 50px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
}

.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    grid-auto-rows: 1fr;
    gap: 30px;
}

@media (min-width: 768px) {
    .bento-large {
        grid-column: span 2;
    }
}

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

/* Scroll Reveal Base Classes */
.reveal {
    opacity: 0;
    transform: translateY(40px);
    transition: all 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.reveal.active {
    opacity: 1;
    transform: translateY(0);
}

.tool-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 30px;
    text-decoration: none;
    color: var(--text-main);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

.tool-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; height: 3px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.5), transparent);
    transform: translateX(-100%);
    transition: transform 0.5s;
}

.tool-card:hover {
    transform: translateY(-8px) scale(1.02);
    background: rgba(30, 41, 59, 0.95);
    border-color: rgba(255, 255, 255, 0.3);
    box-shadow: 0 20px 40px -10px rgba(0,0,0,0.6), 0 0 20px rgba(99, 102, 241, 0.2);
}

.tool-card:hover::before {
    transform: translateX(100%);
}

.tool-card::after {
    content: '\f111'; /* Ionicons arrow-forward (approximate) */
    font-family: 'Ionicons';
    position: absolute;
    bottom: 25px;
    left: 25px;
    font-size: 1.2rem;
    color: #6366f1;
    opacity: 0;
    transform: translateX(10px);
    transition: all 0.3s ease;
}

.tool-card:hover::after {
    opacity: 1;
    transform: translateX(0);
}

/* Badges */
.badge {
    position: absolute;
    top: 15px;
    left: 15px;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.badge.new { background: rgba(16, 185, 129, 0.2); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.3); }
.badge.hot { background: rgba(244, 63, 94, 0.2); color: #fb7185; border: 1px solid rgba(244, 63, 94, 0.3); }

.icon-box {
    width: 60px;
    height: 60px;
    border-radius: 16px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 20px;
    transition: all 0.4s ease;
}

.tool-card:hover .icon-box {
    transform: scale(1.15) rotate(5deg);
    box-shadow: 0 10px 20px rgba(0,0,0,0.3);
}

.icon-box ion-icon {
    font-size: 30px;
    color: #fff;
}

.tool-card h3 {
    font-size: 1.3rem;
    font-weight: 800;
    margin-bottom: 10px;
}

.tool-card p {
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.6;
}

/* Stats Section */
.stats-container {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin: 80px auto;
    flex-wrap: wrap;
    padding: 0 20px;
}
.stat-box {
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.1);
    padding: 30px;
    border-radius: 20px;
    text-align: center;
    min-width: 220px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    transition: transform 0.3s;
}
.stat-box:hover { transform: translateY(-5px); border-color: rgba(99, 102, 241, 0.4); }
.stat-box h3 {
    font-size: 3rem;
    font-weight: 900;
    background: linear-gradient(135deg, #38bdf8, #818cf8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 5px;
}
.stat-box p { color: var(--text-muted); font-weight: 700; font-size: 1.1rem; }

/* FAQ Section */
.faq-section {
    max-width: 800px;
    margin: 80px auto;
    padding: 0 20px;
}
.faq-item {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    margin-bottom: 15px;
    overflow: hidden;
    transition: all 0.3s;
}
.faq-question {
    padding: 20px 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    font-weight: 800;
    font-size: 1.1rem;
    color: #fff;
    transition: background 0.3s;
}
.faq-question:hover { background: rgba(255,255,255,0.02); }
.faq-question ion-icon {
    color: #6366f1;
    transition: transform 0.3s;
    font-size: 1.4rem;
}
.faq-answer {
    padding: 0 25px;
    max-height: 0;
    overflow: hidden;
    color: var(--text-muted);
    line-height: 1.8;
    transition: all 0.3s ease-out;
}
.faq-item.active-faq {
    border-color: #6366f1;
    box-shadow: 0 5px 20px rgba(99, 102, 241, 0.2);
}
.faq-item.active-faq .faq-question ion-icon { transform: rotate(180deg); }
.faq-item.active-faq .faq-answer { padding: 0 25px 20px; max-height: 500px; }

/* Advanced Footer */
.main-footer {
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding: 60px 20px 30px;
    margin-top: 50px;
}

.footer-grid {
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 40px;
    margin-bottom: 40px;
}

.footer-col h4 {
    color: #fff;
    font-size: 1.3rem;
    margin-bottom: 20px;
    font-weight: 800;
}

.footer-col p {
    color: var(--text-muted);
    line-height: 1.8;
}

.footer-col a {
    display: block;
    color: var(--text-muted);
    text-decoration: none;
    margin-bottom: 12px;
    transition: all 0.3s;
}

.footer-col a:hover {
    color: #6366f1;
    transform: translateX(-5px);
}

.footer-bottom {
    text-align: center;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    font-size: 0.9rem;
}

@media (max-width: 768px) {
    .hero-text h1 { font-size: 2rem; }
    .hero { padding: 60px 20px 50px; }
    nav a:not(.blog-btn) { display: none !important; }
    .header-content { padding: 15px; }
    .logo span { display: none; }
    .stats-container { gap: 20px; }
    .stat-box { min-width: 140px; padding: 20px; }
    .stat-box h3 { font-size: 2rem; }
    .tools-grid { grid-template-columns: 1fr; gap: 20px; }
    .bento-large { grid-column: span 1; }
    .footer-grid { gap: 25px; }
    .section-title { font-size: 1.2rem; }
    .filter-chips { gap: 8px; }
    .chip { padding: 8px 15px; font-size: 0.85rem; }
}

/* Reading Progress Bar */
#reading-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 3px;
    background: linear-gradient(90deg, #6366f1, #a855f7, #38bdf8);
    z-index: 9999;
    transition: width 0.1s linear;
    box-shadow: 0 0 8px rgba(99, 102, 241, 0.6);
}

/* No Results Message */
.no-results-msg {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
    display: none;
    grid-column: 1 / -1;
    animation: fadeUp 0.4s ease both;
}
.no-results-msg ion-icon {
    font-size: 3rem;
    display: block;
    margin: 0 auto 15px;
    color: #6366f1;
    opacity: 0.5;
}
.no-results-msg p { font-size: 1.1rem; font-weight: 700; }

/* Enhanced Light Mode Cards */
body.light-mode .tool-card {
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 4px 20px rgba(0,0,0,0.06);
}
body.light-mode .tool-card:hover {
    background: #fff;
    box-shadow: 0 20px 40px -10px rgba(0,0,0,0.15), 0 0 20px rgba(99, 102, 241, 0.15);
}

/* Badge pulse animation */
.badge.hot {
    animation: badgePulse 2s ease-in-out infinite;
}
@keyframes badgePulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(244, 63, 94, 0.4); }
    50% { box-shadow: 0 0 0 6px rgba(244, 63, 94, 0); }
}

/* Gradient text utility */
.gradient-text {
    background: linear-gradient(135deg, #6366f1, #a855f7, #38bdf8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Search input clear button */
.search-clear {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}
.search-clear:hover { color: #f43f5e; }
.search-clear.visible { display: flex; }

/* Custom Premium Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: rgba(15, 23, 42, 0.8);
}
::-webkit-scrollbar-thumb {
    background: rgba(99, 102, 241, 0.5);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(99, 102, 241, 0.8);
}
body.light-mode ::-webkit-scrollbar-track {
    background: rgba(241, 245, 249, 0.8);
}
body.light-mode ::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.5);
}
body.light-mode ::-webkit-scrollbar-thumb:hover {
    background: rgba(99, 102, 241, 0.8);
}
