/* =============================================
   Searchoo - AI Tools Directory
   Design System: Product Hunt / App Store inspired
   ============================================= */

/* --- CSS Variables (Light Mode) --- */
:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-light: rgba(99, 102, 241, 0.08);
    --secondary: #8b5cf6;
    --accent: #06b6d4;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;

    --bg: #f8fafc;
    --bg-alt: #f1f5f9;
    --surface: #ffffff;
    --surface-hover: #f8fafc;
    --border: #e2e8f0;

    --text: #1e293b;
    --text-secondary: #475569;
    --text-muted: #94a3b8;

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
    --shadow-lg: 0 12px 40px rgba(0,0,0,0.08);
    --shadow-xl: 0 20px 60px rgba(0,0,0,0.1);

    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    --font: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Dark Mode --- */
[data-theme="dark"], :root.dark-mode {
    --bg: #0f172a;
    --bg-alt: #1e293b;
    --surface: #1e293b;
    --surface-hover: #273548;
    --border: #334155;

    --text: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #64748b;

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.3);
    --shadow-lg: 0 12px 40px rgba(0,0,0,0.4);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #0f172a;
        --bg-alt: #1e293b;
        --surface: #1e293b;
        --surface-hover: #273548;
        --border: #334155;
        --text: #f1f5f9;
        --text-secondary: #cbd5e1;
        --text-muted: #64748b;
        --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
        --shadow-md: 0 4px 12px rgba(0,0,0,0.3);
        --shadow-lg: 0 12px 40px rgba(0,0,0,0.4);
    }
}

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

html { font-size:16px; scroll-behavior:smooth; }
body {
    font-family:var(--font);
    background:var(--bg);
    color:var(--text);
    line-height:1.6;
    min-height:100vh;
    -webkit-font-smoothing:antialiased;
}

a { color:var(--primary); text-decoration:none; transition:color var(--transition); }
a:hover { color:var(--primary-hover); }
img { max-width:100%; height:auto; display:block; }
input, select, textarea, button { font-family:inherit; }

/* --- Container --- */
.container { max-width:1280px; margin:0 auto; padding:0 24px; }

/* --- Typography --- */
h1 { font-size:2.25rem; font-weight:800; letter-spacing:-0.03em; }
h2 { font-size:1.5rem; font-weight:700; letter-spacing:-0.02em; }
h3 { font-size:1.1rem; font-weight:600; }
p { color:var(--text-secondary); }

.gradient-text {
    background:linear-gradient(135deg, var(--primary), var(--secondary), var(--accent));
    -webkit-background-clip:text;
    -webkit-text-fill-color:transparent;
    background-clip:text;
}

/* --- Header --- */
.site-header {
    position:sticky; top:0; z-index:100;
    background:var(--surface);
    border-bottom:1px solid var(--border);
    backdrop-filter:blur(12px);
}
.site-header .container {
    display:flex; align-items:center; justify-content:space-between;
    height:64px;
}
.logo { display:flex; align-items:center; gap:10px; color:var(--text); font-weight:700; font-size:1.25rem; }
.logo-text { font-weight:800; letter-spacing:-0.02em; }
.main-nav { display:flex; align-items:center; gap:8px; }
.main-nav a {
    padding:8px 14px; border-radius:var(--radius);
    color:var(--text-secondary); font-size:0.9rem; font-weight:500;
    transition:all var(--transition);
}
.main-nav a:hover, .main-nav a.active { background:var(--primary-light); color:var(--primary); }
.dropdown { position:relative; }
.dropdown-toggle::after { content:' ▾'; font-size:0.7rem; }
.dropdown-menu {
    display:none; position:absolute; top:100%; left:0;
    background:var(--surface); border:1px solid var(--border);
    border-radius:var(--radius); min-width:220px; padding:8px;
    box-shadow:var(--shadow-lg); z-index:50;
}
.dropdown:hover .dropdown-menu { display:block; }
.dropdown-menu a { display:block; padding:8px 12px; border-radius:var(--radius-sm); font-size:0.85rem; white-space:nowrap; }

.header-actions { display:flex; align-items:center; gap:8px; }
.mobile-only { display:none; }

/* --- Buttons --- */
.btn {
    display:inline-flex; align-items:center; justify-content:center; gap:6px;
    padding:10px 20px; border-radius:var(--radius); border:none;
    font-size:0.9rem; font-weight:600; cursor:pointer;
    transition:all var(--transition); text-decoration:none;
    line-height:1.4;
}
.btn-primary { background:var(--primary); color:white; }
.btn-primary:hover { background:var(--primary-hover); color:white; transform:translateY(-1px); box-shadow:var(--shadow-md); }
.btn-ghost { background:transparent; color:var(--text-secondary); }
.btn-ghost:hover { background:var(--bg-alt); color:var(--text); }
.btn-sm { padding:6px 12px; font-size:0.8rem; }
.btn-lg { padding:14px 28px; font-size:1rem; border-radius:var(--radius-lg); }
.btn-icon {
    display:inline-flex; align-items:center; justify-content:center;
    width:40px; height:40px; border-radius:var(--radius); border:none;
    background:transparent; color:var(--text); cursor:pointer;
    transition:all var(--transition);
}
.btn-icon:hover { background:var(--bg-alt); }

/* Accent button (gold/premium) */
.btn-accent {
    background:linear-gradient(135deg, #f59e0b, #fbbf24);
    color:#0f172a;
    border:none;
    font-weight:700;
    border-radius:50px;
    box-shadow:0 2px 8px rgba(245,158,11,0.2);
}
.btn-accent:hover {
    background:linear-gradient(135deg, #d97706, #f59e0b);
    color:#0f172a;
    transform:translateY(-1px);
    box-shadow:0 4px 16px rgba(245,158,11,0.35);
}

/* --- Badges --- */
.badge {
    display:inline-block; padding:3px 10px; border-radius:20px;
    font-size:0.7rem; font-weight:600; white-space:nowrap;
    letter-spacing:0.01em;
}
.badge-category { background:rgba(99,102,241,0.1); color:var(--primary); }
.badge-country { background:rgba(6,182,212,0.1); color:var(--accent); }
.badge-iran { background:rgba(34,197,94,0.12); color:#16a34a; font-weight:600; }
.badge-free { background:rgba(16,185,129,0.1); color:var(--success); }
.badge-paid { background:rgba(245,158,11,0.1); color:var(--warning); }
.badge-freemium { background:rgba(139,92,246,0.1); color:var(--secondary); }
.badge-oss { background:rgba(239,68,68,0.1); color:var(--danger); }
.badge-api { background:rgba(6,182,212,0.1); color:var(--accent); }
.badge-tag { background:var(--bg-alt); color:var(--text-secondary); }
.badge-success { background:rgba(16,185,129,0.1); color:var(--success); }
.badge-warning { background:rgba(245,158,11,0.1); color:var(--warning); }
.badge-danger { background:rgba(239,68,68,0.1); color:var(--danger); }

/* --- Hero Section --- */
.hero {
    padding:64px 0 48px; text-align:center;
    background:linear-gradient(180deg, var(--surface) 0%, var(--bg) 100%);
}
.hero h1 {
    font-size:3rem; margin-bottom:12px;
    max-width:800px; margin-inline:auto;
}
.hero-subtitle {
    font-size:1.15rem; color:var(--text-muted); margin-bottom:32px;
    max-width:500px; margin-inline:auto;
}

/* --- Search Box --- */
.search-box { max-width:600px; margin:0 auto; padding:0 24px; }
.search-input-wrapper {
    display:flex; align-items:center; gap:0;
    background:var(--surface); border:2px solid var(--border);
    border-radius:50px; overflow:hidden;
    box-shadow:var(--shadow-md); transition:all var(--transition);
}
.search-input-wrapper:focus-within {
    border-color:var(--primary); box-shadow:0 0 0 4px rgba(99,102,241,0.12);
}
.search-icon { margin-left:24px; color:var(--text-muted); flex-shrink:0; }
.search-input {
    flex:1; border:none; padding:16px 14px 16px 14px; font-size:1rem;
    background:transparent; color:var(--text); outline:none; min-width:0;
}
.search-input::placeholder { color:var(--text-muted); }
.search-input-wrapper .btn {
    margin:6px 8px 6px 4px; border-radius:50px; padding:12px 28px; flex-shrink:0;
}

/* --- Filters Bar --- */
.filters-bar { padding:16px 0; border-bottom:1px solid var(--border); background:var(--surface); position:sticky; top:64px; z-index:50; }
.filters-form { display:flex; flex-wrap:wrap; gap:10px; align-items:center; }
.filter-select {
    padding:10px 36px 10px 18px; border:1.5px solid var(--border);
    border-radius:50px; background:var(--surface); color:var(--text);
    font-size:0.85rem; cursor:pointer; outline:none;
    transition:all var(--transition);
    appearance:none; -webkit-appearance:none; -moz-appearance:none;
    background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat:no-repeat;
    background-position:right 14px center;
    box-shadow:var(--shadow-sm);
}
.filter-select:hover { border-color:var(--primary); box-shadow:0 0 0 3px rgba(99,102,241,0.08); }
.filter-select:focus { border-color:var(--primary); box-shadow:0 0 0 3px rgba(99,102,241,0.15); }

[dir="rtl"] .filter-select {
    padding:10px 18px 10px 36px;
    background-position:left 14px center;
}

/* --- Section --- */
.section { padding:48px 0; }
.section-header { display:flex; align-items:center; justify-content:space-between; margin-bottom:28px; flex-wrap:wrap; gap:12px; }
.bg-alt { background:var(--bg-alt); }

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

/* --- Tool Card --- */
.tool-card {
    display:flex; flex-direction:column;
    background:var(--surface); border:1px solid var(--border);
    border-radius:var(--radius-lg); overflow:hidden;
    transition:all var(--transition);
    color:var(--text);
}
.tool-card:hover {
    transform:translateY(-4px);
    box-shadow:var(--shadow-lg); border-color:var(--primary);
}
.tool-card.featured {
    border-color:rgba(99,102,241,0.3);
    background:linear-gradient(135deg, var(--surface) 0%, rgba(99,102,241,0.03) 100%);
}
.tool-card.iranian {
    border-right:3px solid #22c55e;
    background:linear-gradient(135deg, var(--surface) 0%, rgba(34,197,94,0.03) 100%);
}
[dir="rtl"] .tool-card.iranian {
    border-right:none;
    border-left:3px solid #22c55e;
}
.tool-card.iranian:hover {
    border-color:var(--border);
    border-right-color:#22c55e;
    box-shadow:var(--shadow-lg), inset 0 0 0 1px rgba(34,197,94,0.1);
}
[dir="rtl"] .tool-card.iranian:hover {
    border-right-color:var(--border);
    border-left-color:#22c55e;
}
.tool-card-link {
    display:flex; flex-direction:column; flex:1;
    color:inherit; text-decoration:none; cursor:pointer;
}
.tool-card-img {
    height:56px; width:56px; margin:20px 0 0 20px;
    border-radius:var(--radius); overflow:hidden; background:var(--bg-alt);
    display:flex; align-items:center; justify-content:center;
}
.tool-card-img img {
    width:100%; height:100%; object-fit:cover;
}
.tool-card-body { padding:20px 20px; flex:1; }
.tool-card-body h3 { font-size:1.15rem; margin-bottom:6px; font-weight:700; }
.tool-card-external {
    font-size:0.8rem; color:var(--text-muted); margin-left:4px;
    opacity:0; transition:opacity var(--transition);
}
.tool-card:hover .tool-card-external { opacity:1; }
.tool-card-body p {
    font-size:0.85rem; color:var(--text-secondary);
    display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical;
    overflow:hidden; line-height:1.5;
}
.tool-card-meta { display:flex; flex-wrap:wrap; gap:6px; margin-top:12px; }
.tool-card-footer {
    display:flex; align-items:center; justify-content:space-between;
    padding:12px 20px; border-top:1px solid var(--border);
    font-size:0.8rem; color:var(--text-muted);
}
.tool-info-link {
    font-weight:600; color:var(--primary); text-decoration:none; font-size:0.8rem;
}
.tool-info-link:hover { color:var(--primary-hover); }
.tool-card-premium {
    padding:12px 20px 16px;
    background:linear-gradient(180deg, rgba(245,158,11,0.06) 0%, var(--surface) 100%);
    border-top:1px dashed rgba(245,158,11,0.25);
}
.tool-card-premium .btn {
    width:100%; text-align:center; justify-content:center;
    padding:10px 20px;
    font-size:0.85rem;
    font-weight:700;
    border-radius:50px;
    background:linear-gradient(135deg, #f59e0b, #fbbf24);
    color:#0f172a;
    border:none;
    cursor:pointer;
    transition:all 0.2s ease;
    box-shadow:0 2px 8px rgba(245,158,11,0.2);
}
.tool-card-premium .btn:hover {
    background:linear-gradient(135deg, #d97706, #f59e0b);
    transform:translateY(-1px);
    box-shadow:0 4px 16px rgba(245,158,11,0.35);
    color:#0f172a;
}
.tool-card-premium small {
    font-weight:700; opacity:0.9; font-size:0.8em;
}
.tool-stats { display:flex; gap:8px; font-size:0.75rem; }
.tool-stats-sm { font-size:0.75rem; color:var(--text-muted); }

/* --- Tool Detail Page --- */
.tool-detail-page { padding:40px 24px; }
.breadcrumb { font-size:0.85rem; color:var(--text-muted); margin-bottom:24px; }
.breadcrumb a { color:var(--text-muted); }
.breadcrumb a:hover { color:var(--primary); }
.tool-detail-header { display:flex; gap:24px; margin-bottom:32px; }
.tool-detail-logo {
    width:100px; height:100px; border-radius:var(--radius-lg);
    overflow:hidden; flex-shrink:0; background:var(--bg-alt);
    border:1px solid var(--border);
}
.tool-detail-logo img { width:100%; height:100%; object-fit:cover; }
.tool-detail-info { flex:1; }
.tool-detail-info h1 { font-size:2rem; margin-bottom:8px; }
.tool-detail-desc { font-size:1.05rem; margin-bottom:16px; }
.tool-detail-meta { display:flex; flex-wrap:wrap; gap:8px; margin-bottom:12px; }
.tool-detail-stats { display:flex; gap:16px; font-size:0.85rem; color:var(--text-muted); margin-bottom:20px; }
.tool-detail-actions { display:flex; flex-wrap:wrap; gap:12px; margin-bottom:12px; }
.tool-detail-actions .btn { flex:1; min-width:200px; text-align:center; justify-content:center; }
.tool-detail-content { margin:32px 0; }
.tool-detail-content h2 { margin-bottom:12px; }
.content-text { color:var(--text-secondary); line-height:1.8; }
.tool-detail-website { margin:24px 0; }
.info-box { padding:16px; background:var(--bg-alt); border-radius:var(--radius); }
.related-tools { margin-top:48px; padding-top:32px; border-top:1px solid var(--border); }
.related-tools h2 { margin-bottom:20px; }

/* --- Category Header --- */
.category-header { padding:40px 0 20px; }
.category-header h1 { font-size:2rem; }
.category-header p { margin-top:8px; }
.count-badge { display:inline-block; margin-top:8px; padding:4px 14px; background:var(--primary-light); color:var(--primary); border-radius:20px; font-size:0.8rem; font-weight:600; }

/* --- Search Header --- */
.search-header { padding:40px 0 20px; text-align:center; }
.search-header h1 { margin-bottom:24px; }

/* --- Pagination --- */
.pagination { display:flex; align-items:center; justify-content:center; gap:16px; padding:32px 0 48px; }
.pagination-info { font-size:0.9rem; color:var(--text-muted); }

/* --- Empty State --- */
.empty-state { text-align:center; padding:64px 20px; color:var(--text-muted); }
.empty-state svg { margin-bottom:16px; opacity:0.4; }
.empty-state h3 { margin-bottom:8px; color:var(--text); }
.empty-state .btn { margin-top:16px; }

/* --- Footer --- */
.site-footer { background:var(--surface); border-top:1px solid var(--border); padding:48px 0 24px; margin-top:48px; }
.footer-grid { display:grid; grid-template-columns:2fr 1fr 1fr 1fr; gap:32px; margin-bottom:32px; }
.footer-brand .logo { margin-bottom:12px; }
.footer-brand p { font-size:0.9rem; }
.footer-links h4 { font-size:0.85rem; text-transform:uppercase; letter-spacing:0.05em; margin-bottom:12px; color:var(--text); }
.footer-links a { display:block; font-size:0.875rem; color:var(--text-secondary); margin-bottom:8px; }
.footer-links a:hover { color:var(--primary); }
.footer-bottom { padding-top:24px; border-top:1px solid var(--border); text-align:center; font-size:0.8rem; color:var(--text-muted); }

/* --- Dark Mode SVG Icons --- */
.icon-sun { display:block; }
.icon-moon { display:none; }
[data-theme="dark"] .icon-sun { display:none; }
[data-theme="dark"] .icon-moon { display:block; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .icon-sun { display:none; }
    :root:not([data-theme="light"]) .icon-moon { display:block; }
}

/* --- Responsive --- */
@media (max-width:1024px) {
    .footer-grid { grid-template-columns:1fr 1fr; }
}
@media (max-width:768px) {
    h1 { font-size:1.75rem; }
    .hero h1 { font-size:2rem; }
    .main-nav { display:none; }
    .main-nav.open { display:flex; flex-direction:column; position:absolute; top:64px; left:0; right:0; background:var(--surface); border-bottom:1px solid var(--border); padding:16px; z-index:100; }
    .mobile-only { display:flex; }
    .tools-grid { grid-template-columns:1fr; }
    .tool-detail-header { flex-direction:column; }
    .tool-detail-logo { width:80px; height:80px; }
    .footer-grid { grid-template-columns:1fr 1fr; }
    .footer-brand { grid-column:1/-1; }
    .filters-form { gap:8px; }
    .search-input-wrapper .btn { padding:10px 16px; font-size:0.85rem; }
}
@media (max-width:480px) {
    .hero h1 { font-size:1.6rem; }
    .section { padding:32px 0; }
    .tools-grid { grid-template-columns:1fr; }
    .filter-select { font-size:0.8rem; padding:6px 10px; }
    .search-input { padding:12px 8px; font-size:0.9rem; }
    .search-icon { margin-left:12px; }
    .tool-card-body { padding:12px 16px; }
    .tool-card-footer { padding:10px 16px; }
}

/* --- Animations --- */
@keyframes fadeInUp {
    from { opacity:0; transform:translateY(16px); }
    to { opacity:1; transform:translateY(0); }
}
.tool-card { animation:fadeInUp 0.4s ease both; }
.tools-grid .tool-card:nth-child(1) { animation-delay:0.05s; }
.tools-grid .tool-card:nth-child(2) { animation-delay:0.1s; }
.tools-grid .tool-card:nth-child(3) { animation-delay:0.15s; }
.tools-grid .tool-card:nth-child(4) { animation-delay:0.2s; }
.tools-grid .tool-card:nth-child(5) { animation-delay:0.25s; }
.tools-grid .tool-card:nth-child(6) { animation-delay:0.3s; }
.tools-grid .tool-card:nth-child(7) { animation-delay:0.35s; }
.tools-grid .tool-card:nth-child(8) { animation-delay:0.4s; }
.tools-grid .tool-card:nth-child(9) { animation-delay:0.45s; }
.tools-grid .tool-card:nth-child(10) { animation-delay:0.5s; }
.tools-grid .tool-card:nth-child(11) { animation-delay:0.55s; }
.tools-grid .tool-card:nth-child(12) { animation-delay:0.6s; }

/* =============================================
   RTL SUPPORT (Persian / Arabic)
   ============================================= */
[dir="rtl"] {
    direction: rtl;
    text-align: right;
}

[dir="rtl"] .search-icon {
    margin-left: 0;
    margin-right: 24px;
}

[dir="rtl"] .search-input {
    padding: 16px 28px 16px 8px;
}

[dir="rtl"] .search-input-wrapper .btn {
    margin: 6px 0 6px 6px;
}

[dir="rtl"] .tool-card-img {
    margin: 20px 20px 0 0;
}

[dir="rtl"] .tool-card-body {
    text-align: right;
}

[dir="rtl"] .tool-card-meta,
[dir="rtl"] .tool-detail-meta {
    justify-content: flex-start;
}

[dir="rtl"] .badge {
    margin-left: 0;
}

[dir="rtl"] .tool-stats {
    margin-left: 0;
}

[dir="rtl"] .tool-card-footer {
    direction: rtl;
}

[dir="rtl"] .tool-card-external {
    margin-left: 0;
    margin-right: 4px;
}

[dir="rtl"] .tool-detail-header {
    text-align: right;
}

[dir="rtl"] .tool-detail-stats {
    justify-content: flex-start;
}

[dir="rtl"] .tool-detail-info h1 {
    text-align: right;
}

[dir="rtl"] .filters-form {
    direction: rtl;
}

[dir="rtl"] .dropdown-menu {
    left: auto;
    right: 0;
}

[dir="rtl"] .section-header {
    text-align: right;
}

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

[dir="rtl"] .btn {
    flex-direction: row;
}

[dir="rtl"] .logo {
    flex-direction: row;
}

[dir="rtl"] .tool-card-footer {
    flex-direction: row;
}

[dir="rtl"] .header-actions {
    flex-direction: row;
}

[dir="rtl"] .tool-detail-content h2,
[dir="rtl"] .related-tools h2 {
    text-align: right;
}

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

[dir="rtl"] .info-box {
    text-align: right;
}

[dir="rtl"] .tool-detail-actions {
    justify-content: flex-start;
}

[dir="rtl"] .empty-state {
    text-align: center;
}

[dir="rtl"] .pagination {
    direction: ltr; /* keep numbers LTR */
}

[dir="rtl"] .hero {
    text-align: center;
}

[dir="rtl"] .search-header {
    text-align: right;
}

[dir="rtl"] .category-header {
    text-align: right;
}

[dir="rtl"] .footer-grid {
    direction: rtl;
}

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

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

[dir="rtl"] .main-nav {
    direction: rtl;
}

[dir="rtl"] .site-footer {
    direction: rtl;
}

/* LTR numbers in RTL - keep numbers LTR */
[dir="rtl"] .tool-stats span,
[dir="rtl"] .tool-detail-stats span,
[dir="rtl"] .stat-value,
[dir="rtl"] .pagination-info {
    direction: ltr;
    display: inline-block;
    unicode-bidi: embed;
}

@media (max-width: 768px) {
    [dir="rtl"] .main-nav.open {
        text-align: right;
    }

    [dir="rtl"] .tool-detail-header {
        text-align: right;
    }

    [dir="rtl"] .hero-content {
        text-align: center;
        margin: 0 auto;
    }

    [dir="rtl"] .hero-actions {
        justify-content: center;
    }

    [dir="rtl"] .hero-stats {
        justify-content: center;
    }

    [dir="rtl"] .tool-card-img {
        margin: 20px auto 0 auto;
    }
}
