/* ============================================================
   Hamva.ir - Main Stylesheet
   ============================================================ */

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

:root {
    --primary: #2563eb;
    --primary-dark: #1e40af;
    --primary-light: #dbeafe;
    --text: #1f2937;
    --text-muted: #6b7280;
    --text-soft: #9ca3af;
    --bg: #f1f5f9;
    --bg-card: #ffffff;
    --border: #e5e7eb;
    --border-soft: #f3f4f6;
    --danger: #ef4444;
    --success: #10b981;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .04);
    --shadow: 0 2px 8px rgba(0, 0, 0, .06);
    --shadow-md: 0 6px 20px rgba(0, 0, 0, .08);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, .12);
    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --transition: .2s ease;

    /* Footer dark theme */
    --footer-bg: #1f2937;
    --footer-text: #9ca3af;
    --footer-title: #ffffff;
    --footer-link: #60a5fa;
    --footer-link-hover: #93c5fd;
    --footer-border: rgba(255, 255, 255, .1);
    --footer-pill: rgba(255, 255, 255, .08);
    --footer-pill-hover: rgba(96, 165, 250, .2);
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Vazirmatn', -apple-system, BlinkMacSystemFont, 'Segoe UI', Tahoma, sans-serif;
    font-size: 15px;
    line-height: 1.7;
    color: var(--text);
    background: var(--bg);
    direction: rtl;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

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

img {
    max-width: 100%;
    height: auto;
    display: block;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
}

input,
textarea,
select {
    font-family: inherit;
    font-size: inherit;
}

/* ============ Container ============ */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ============ Header ============ */
.site-header-main {
    background: #fff;
    border-bottom: 1px solid var(--border);
    padding: 16px 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.site-header-main .logo {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 18px;
    font-weight: 800;
    color: var(--text);
    text-decoration: none;
}

.site-header-main .logo-icon {
    font-size: 24px;
    line-height: 1;
}

.site-header-main .logo-text {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* ============ Main ============ */
.main {
    flex: 1;
    padding: 40px 0 60px;
}

/* ============ Hero ============ */
.hero {
    text-align: center;
    padding: 20px 0 32px;
}

.hero-badge {
    display: inline-block;
    padding: 6px 14px;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 16px;
}

.hero-title {
    font-size: 32px;
    font-weight: 800;
    line-height: 1.4;
    margin-bottom: 12px;
    color: var(--text);
}

.hero-title-highlight {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero-desc {
    font-size: 15px;
    color: var(--text-muted);
    max-width: 680px;
    margin: 0 auto;
    line-height: 1.9;
}

/* ============ Search Form ============ */
.search-form {
    position: relative;
    max-width: 640px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    background: #fff;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    padding: 6px;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.search-form:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, .1);
}

.search-form .search-icon {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-soft);
    display: flex;
    pointer-events: none;
}

.search-form input[type="text"] {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    padding: 12px 48px 12px 16px;
    font-size: 15px;
    color: var(--text);
}

.search-form input[type="text"]::placeholder {
    color: var(--text-soft);
}

.search-form button[type="submit"] {
    padding: 10px 22px;
    background: var(--primary);
    color: #fff;
    border-radius: 8px;
    font-weight: 700;
    font-size: 14px;
    transition: background var(--transition);
}

.search-form button[type="submit"]:hover {
    background: var(--primary-dark);
}

/* ============ Section Header ============ */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    gap: 12px;
}

.section-title {
    font-size: 20px;
    font-weight: 800;
    color: var(--text);
    margin: 0;
    position: relative;
    padding-right: 14px;
}

.section-title::before {
    content: '';
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 20px;
    background: var(--primary);
    border-radius: 4px;
}

.section-count {
    font-size: 13px;
    color: var(--text-muted);
    background: var(--bg-card);
    padding: 4px 12px;
    border-radius: 999px;
    border: 1px solid var(--border);
}

/* ============ Result Info ============ */
.result-info {
    text-align: center;
    padding: 14px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 24px;
}

.result-count {
    display: inline-block;
    background: var(--primary);
    color: #fff;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 700;
    margin-left: 6px;
}

/* ============ File Grid ============ */
.file-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
}

/* ============ File Card ============ */
.file-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
    color: inherit;
    text-decoration: none;
}

.file-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary);
    color: inherit;
}

.file-card-top {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.file-card-icon {
    position: relative;
    width: 52px;
    height: 60px;
    flex-shrink: 0;
    background: linear-gradient(135deg, #eff6ff, #dbeafe);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.file-card-icon-emoji {
    font-size: 26px;
    line-height: 1;
}

.file-card-icon-ext {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--primary);
    color: #fff;
    font-size: 9px;
    font-weight: 800;
    text-align: center;
    padding: 2px 0;
    letter-spacing: .5px;
}

.file-card-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}

.file-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 9px;
    border-radius: 999px;
    background: var(--border-soft);
    color: var(--text-muted);
    white-space: nowrap;
}

.file-pill.primary {
    background: var(--primary-light);
    color: var(--primary);
}

.file-card-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.6;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.file-card-meta {
    display: flex;
    align-items: center;
    gap: 16px;
    padding-top: 12px;
    border-top: 1px dashed var(--border);
    font-size: 12px;
    color: var(--text-muted);
}

.file-card-meta-item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.file-card-meta-emoji {
    font-size: 13px;
}

/* ============ Empty State ============ */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    background: var(--bg-card);
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
}

.empty-icon {
    font-size: 56px;
    line-height: 1;
    margin-bottom: 16px;
}

.empty-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 8px;
}

.empty-desc {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 20px;
}

/* ============ Buttons ============ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 22px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 700;
    transition: all var(--transition);
    cursor: pointer;
    border: 1px solid transparent;
}

.btn-ghost {
    background: transparent;
    color: var(--text);
    border-color: var(--border);
}

.btn-ghost:hover {
    background: var(--bg-card);
    border-color: var(--primary);
    color: var(--primary);
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    color: #fff;
    transform: translateY(-2px);
}

/* ============ File Detail ============ */
.file-detail-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 32px;
    text-align: center;
    margin-bottom: 40px;
    box-shadow: var(--shadow-sm);
}

.file-detail-icon-wrap {
    position: relative;
    width: 80px;
    height: 92px;
    margin: 0 auto 20px;
    background: linear-gradient(135deg, #eff6ff, #dbeafe);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.file-detail-icon {
    font-size: 40px;
    line-height: 1;
}

.file-detail-ext {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--primary);
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    text-align: center;
    padding: 3px 0;
    letter-spacing: 1px;
}

.file-detail-title {
    font-size: 22px;
    font-weight: 800;
    color: var(--text);
    line-height: 1.6;
    margin-bottom: 24px;
}

.file-detail-meta {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    margin-bottom: 28px;
}

.meta-box {
    background: var(--border-soft);
    border-radius: var(--radius);
    padding: 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    text-align: right;
}

.meta-box-icon {
    font-size: 22px;
    line-height: 1;
    flex-shrink: 0;
}

.meta-box-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.meta-box-label {
    font-size: 11.5px;
    color: var(--text-muted);
}

.meta-box-value {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
}

/* ============ Download Button ============ */
.download-section {
    margin-top: 8px;
}

.btn-download-big {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px 40px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    border-radius: var(--radius);
    font-size: 16px;
    font-weight: 800;
    box-shadow: 0 8px 24px rgba(37, 99, 235, .3);
    transition: transform var(--transition), box-shadow var(--transition);
    text-decoration: none;
}

.btn-download-big:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 32px rgba(37, 99, 235, .4);
    color: #fff;
}

.btn-download-big:active {
    transform: translateY(0);
}

/* ============ Breadcrumb ============ */
.breadcrumb {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 24px;
}

.breadcrumb a {
    color: var(--text-muted);
}

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

.breadcrumb-sep {
    color: var(--text-soft);
}

.breadcrumb-current {
    color: var(--text);
    font-weight: 600;
}

/* ============ Related Section ============ */
.related-section {
    margin-bottom: 40px;
}

/* ============ Back Section ============ */
.back-section {
    text-align: center;
    padding: 20px 0 40px;
}

/* ============ 404 Page ============ */
.error-404 {
    text-align: center;
    padding: 60px 20px 40px;
    max-width: 640px;
    margin: 0 auto;
}

.error-404-icon {
    font-size: 88px;
    line-height: 1;
    margin-bottom: 24px;
    animation: floatIcon 3s ease-in-out infinite;
}

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

.error-404-title {
    font-size: 28px;
    font-weight: 800;
    color: var(--text);
    margin: 0 0 16px;
    line-height: 1.4;
}

.error-404-desc {
    font-size: 15px;
    color: var(--text-muted);
    line-height: 1.9;
    margin: 0;
}

.error-404-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 32px;
    flex-wrap: wrap;
}

/* ============ Footer (Dark Theme) ============ */
.site-footer-main {
    background: var(--footer-bg);
    color: var(--footer-text);
    border-top: none;
    padding: 48px 0 24px;
    margin-top: auto;
}

.footer-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 28px;
    align-items: start;
    margin-bottom: 32px;
}

.footer-col-1 { grid-column: span 1; }
.footer-col-2 { grid-column: span 2; }
.footer-col-3 { grid-column: span 3; }

.footer-title {
    font-size: 15px;
    font-weight: 800;
    color: var(--footer-title);
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.footer-title span {
    font-size: 18px;
    line-height: 1;
}

.footer-text {
    font-size: 13.5px;
    color: var(--footer-text);
    line-height: 1.9;
}

.footer-text-justify {
    text-align: justify;
    text-justify: inter-word;
    line-height: 1.95;
}

.footer-link {
    color: var(--footer-link);
    text-decoration: none;
    font-weight: 700;
}

.footer-link:hover {
    text-decoration: underline;
    color: var(--footer-link-hover);
}

/* ============ Keywords Cloud ============ */
.keywords-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.keyword-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    background: var(--footer-pill);
    color: #e5e7eb;
    border-radius: 999px;
    font-size: 12.5px;
    font-weight: 600;
    transition: background var(--transition), color var(--transition);
    text-decoration: none;
}

.keyword-tag:hover {
    background: var(--footer-pill-hover);
    color: var(--footer-link-hover);
}

.keyword-count {
    font-size: 10.5px;
    background: rgba(96, 165, 250, .2);
    color: var(--footer-link-hover);
    padding: 1px 6px;
    border-radius: 999px;
    font-weight: 700;
}

/* ============ Footer Stats ============ */
.footer-stats {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 4px;
}

.footer-stat {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 14px;
    background: rgba(255, 255, 255, .06);
    border-radius: 10px;
    font-size: 13px;
}

.footer-stat-label {
    color: var(--footer-text);
    font-size: 12.5px;
}

.footer-stat-value {
    color: var(--footer-link);
    font-weight: 800;
    font-size: 15px;
}

/* ============ Footer Bottom ============ */
.footer-bottom {
    border-top: 1px solid var(--footer-border);
    padding-top: 20px;
    text-align: center;
    font-size: 13px;
    color: var(--footer-text);
}

.footer-bottom strong {
    color: var(--footer-title);
}

/* ============ Back to Top (Glass) ============ */
.back-to-top {
    position: fixed;
    bottom: 24px;
    left: 24px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 1px solid rgba(37, 99, 235, .25);
    background: rgba(255, 255, 255, .55);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow:
        0 6px 20px rgba(0, 0, 0, .12),
        inset 0 1px 0 rgba(255, 255, 255, .7);
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: opacity .3s, transform .3s, visibility .3s, background .2s;
    z-index: 999;
    cursor: pointer;
}

/* ✅ فلش به سمت بالا — چرخش SVG */
.back-to-top svg {
    transform: rotate(180deg);
    transition: transform .2s;
}

.back-to-top:hover svg {
    transform: rotate(180deg) translateY(-2px);
}

.back-to-top.is-visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.back-to-top:hover {
    background: rgba(255, 255, 255, .8);
    transform: translateY(-3px);
}

.back-to-top:active {
    transform: translateY(-1px) scale(.95);
}

/* اگه backdrop-filter پشتیبانی نشد */
@supports not (backdrop-filter: blur(10px)) {
    .back-to-top {
        background: var(--primary);
        color: #fff;
        border-color: transparent;
    }
}

/* ============ Responsive ============ */

/* تبلت */
@media (max-width: 900px) {
    .footer-grid {
        grid-template-columns: 1fr;
        gap: 28px;
    }
    .footer-col-1,
    .footer-col-2,
    .footer-col-3 {
        grid-column: span 1;
    }

    .file-detail-card {
        padding: 24px 20px;
    }

    .file-detail-title {
        font-size: 19px;
    }

    .hero-title {
        font-size: 26px;
    }
}

/* موبایل */
@media (max-width: 600px) {
    body {
        font-size: 14px;
    }

    .container {
        padding: 0 16px;
    }

    .main {
        padding: 24px 0 40px;
    }

    .hero {
        padding: 10px 0 24px;
    }

    .hero-title {
        font-size: 22px;
    }

    .hero-desc {
        font-size: 13.5px;
    }

    .search-form {
        padding: 4px;
    }

    .search-form input[type="text"] {
        padding: 10px 44px 10px 12px;
        font-size: 14px;
    }

    .search-form button[type="submit"] {
        padding: 9px 16px;
        font-size: 13px;
    }

    .search-form .search-icon {
        right: 16px;
    }

    .section-title {
        font-size: 17px;
    }

    .file-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .file-detail-card {
        padding: 20px 16px;
        border-radius: var(--radius);
    }

    .file-detail-icon-wrap {
        width: 66px;
        height: 76px;
    }

    .file-detail-icon {
        font-size: 32px;
    }

    .file-detail-title {
        font-size: 16px;
    }

    .file-detail-meta {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .meta-box {
        padding: 10px;
        gap: 8px;
    }

    .meta-box-icon {
        font-size: 18px;
    }

    .meta-box-label {
        font-size: 10.5px;
    }

    .meta-box-value {
        font-size: 12.5px;
    }

    .btn-download-big {
        width: 100%;
        padding: 14px 24px;
        font-size: 15px;
    }

    .error-404 {
        padding: 40px 16px 30px;
    }

    .error-404-icon {
        font-size: 64px;
    }

    .error-404-title {
        font-size: 22px;
    }

    .error-404-desc {
        font-size: 13.5px;
    }

    .site-footer-main {
        padding: 32px 0 20px;
    }

    .back-to-top {
        width: 42px;
        height: 42px;
        bottom: 16px;
        left: 16px;
    }
}

/* موبایل خیلی کوچک */
@media (max-width: 380px) {
    .file-detail-meta {
        grid-template-columns: 1fr;
    }
}

/* ============ Utility ============ */
.text-center { text-align: center; }
.text-muted  { color: var(--text-muted); }
.mb-0        { margin-bottom: 0; }
.mt-20       { margin-top: 20px; }
.mt-40       { margin-top: 40px; }

/* ============ Header Logo ============ */
.site-header-main .logo {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}

.logo-img {
    height: 42px;
    width: auto;
    display: block;
    transition: opacity var(--transition);
}

.logo:hover .logo-img {
    opacity: .85;
}

/* موبایل */
@media (max-width: 600px) {
    .logo-img {
        height: 34px;
    }
}

/* ============ Header Logo ============ */
.site-header-main .logo {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}

.logo-img {
    height: 42px;
    width: auto;
    display: block;
    transition: opacity var(--transition);
}

.logo-text {
    font-size: 22px;
    font-weight: 800;
    color: var(--text);
    line-height: 1;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    transition: opacity var(--transition);
}

.logo:hover .logo-img,
.logo:hover .logo-text {
    opacity: .85;
}

/* موبایل */
@media (max-width: 600px) {
    .logo-img {
        height: 34px;
    }
    .logo-text {
        font-size: 18px;
    }
}

/* ============ Hero ============ */
.hero {
    text-align: center;
    padding: 20px 0 32px;
}

.hero-title {
    font-size: 48px;
    font-weight: 900;
    line-height: 1.3;
    margin-bottom: 12px;
    color: var(--text);
}

.hero-title-highlight {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero-desc {
    font-size: 18px;
    color: var(--text-muted);
    max-width: 680px;
    margin: 0 auto;
    line-height: 1.8;
    font-weight: 500;
}

/* موبایل */
@media (max-width: 900px) {
    .hero-title {
        font-size: 38px;
    }
    .hero-desc {
        font-size: 16px;
    }
}

@media (max-width: 600px) {
    .hero {
        padding: 10px 0 24px;
    }
    .hero-title {
        font-size: 32px;
    }
    .hero-desc {
        font-size: 14.5px;
    }
}