:root {
    --dg-primary: #2c3e50;
    --dg-secondary: #e67e22;
    --dg-white: #ffffff;
    --dg-dark: #1a1a2e;

    --viewport-mobile: 480px;
    --viewport-tablet: 768px;
    --viewport-laptop: 1024px;
    --viewport-desktop: 1440px;
    --viewport-tv: 2560px;

    --spacing-unit: 1rem;
    --container-width: 1200px;

    --font-fa: 'Vazir', 'Vazirmatn', sans-serif;
    --font-en: 'Nunito', sans-serif;
    --app-bg: #ffffff;
    --app-text: #2c3e50;
}

*, *::before, *::after {
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    margin: 0;
    padding: 0;
    font-family: var(--font-fa);
    background-color: var(--dg-white);
    color: var(--dg-dark);
    line-height: 1.6;
    overflow-x: hidden;
}

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

/* Featured Image */
.post-thumbnail {
    margin-bottom: 1.5rem;
}

.post-thumbnail img {
    width: 100%;
    height: auto;
    border-radius: 4px;
}

/* Mobile */
@media screen and (max-width: 480px) {
    body { font-size: 14px; }
    .site-content { padding: 10px; }
}

/* Tablet */
@media screen and (min-width: 481px) and (max-width: 1024px) {
    body { font-size: 16px; }
    a, button, input { min-height: 44px; min-width: 44px; }
}

/* Desktop */
@media screen and (min-width: 1025px) {
    .container { max-width: var(--container-width); margin: 0 auto; }
}

/* 4K */
@media screen and (min-width: 1921px) {
    :root { --spacing-unit: 2rem; }
    body { font-size: 24px; max-width: 2000px; margin: 0 auto; }
}

@media print {
    body { background: white; color: black; }
    .site-header, .site-footer { display: none; }
}

/* Elementor Compatibility */
.elementor-section { position: relative; }
.site-main { min-height: 60vh; }

/* Loader */
#shahin-app-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--app-bg);
    z-index: 999999;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.6s ease-out, visibility 0.6s;
}

#shahin-app-loader.loaded {
    opacity: 0;
    visibility: hidden;
}

.loader-content {
    text-align: center;
    animation: fadeInUp 0.8s ease-out;
}

.loader-brand {
    font-size: 2rem;
    font-weight: 900;
    color: var(--app-text);
    margin-top: 20px;
    letter-spacing: -0.5px;
}

.loader-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(44, 62, 80, 0.1);
    border-left-color: #e67e22;
    border-radius: 50%;
    margin: 0 auto;
    animation: spin 1s linear infinite;
}

@keyframes spin { 100% { transform: rotate(360deg); } }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

@media screen and (max-width: 480px) {
    .loader-brand { font-size: 1.8rem; }
}

/* ------------------------------------------------------------------
 * دکمه بازگشت به بالا (Back to Top)
 * --------------------------------------------------------------- */

.shahin-back-to-top {
    --shahin-btt-bg: var(--dg-secondary, #e67e22);
    position: fixed;
    bottom: 24px;
    left: 24px;
    z-index: 9999;
    width: 48px;
    height: 48px;
    padding: 0;
    margin: 0;
    border: 0;
    border-radius: 50%;
    background: var(--shahin-btt-bg);
    background: linear-gradient(
        135deg,
        var(--shahin-btt-bg),
        color-mix(in srgb, var(--shahin-btt-bg) 62%, #000)
    );
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.28);
    opacity: 0;
    visibility: hidden;
    transform: translateY(18px) scale(0.9);
    transition:
        opacity 0.3s ease,
        transform 0.3s ease,
        visibility 0.3s ease,
        box-shadow 0.3s ease;
    -webkit-tap-highlight-color: transparent;
}

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

.shahin-back-to-top:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 26px rgba(15, 23, 42, 0.34);
}

.shahin-back-to-top:active {
    transform: translateY(0) scale(0.94);
}

.shahin-back-to-top:focus-visible {
    outline: 3px solid rgba(230, 126, 34, 0.45);
    outline-offset: 3px;
}

.shahin-btt--right {
    left: auto;
    right: 24px;
}

.shahin-btt__progress {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
    pointer-events: none;
}

.shahin-btt__progress circle {
    fill: none;
    stroke-width: 3;
}

.shahin-btt__progress-bg {
    stroke: rgba(255, 255, 255, 0.28);
}

.shahin-btt__progress-bar {
    stroke: #ffffff;
    stroke-linecap: round;
    transition: stroke-dashoffset 0.08s linear;
}

.shahin-btt__icon {
    position: relative;
    z-index: 1;
    width: 20px;
    height: 20px;
}

/* روی موبایل/تبلت بالاتر از منوی پایین صفحه شناور می‌ماند تا روی محتوا نیفتد */
@media screen and (max-width: 768px) {
    .shahin-back-to-top {
        width: 44px;
        height: 44px;
        bottom: calc(88px + env(safe-area-inset-bottom, 0px));
        left: 16px;
    }

    .shahin-btt--right {
        left: auto;
        right: 16px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .shahin-back-to-top {
        transition: opacity 0.2s ease, visibility 0.2s ease;
    }

    .shahin-btt__progress-bar {
        transition: none;
    }
}

/* ------------------------------------------------------------------
 * جلوگیری از سرریز افقی در موبایل (رفع حالت نصفه/دسکتاپی صفحه)
 * --------------------------------------------------------------- */

html {
    overflow-x: hidden;
}

img, video, iframe {
    max-width: 100%;
}

.entry-content,
.comment-content,
.widget {
    overflow-wrap: break-word;
    word-wrap: break-word;
}

@media screen and (max-width: 768px) {
    #page,
    .site,
    .site-main,
    .entry-content,
    .elementor,
    .elementor-section,
    .e-con,
    .elementor-widget-wrap {
        max-width: 100vw;
    }

    .site-main,
    .entry-content {
        overflow-x: clip;
    }

    /* جدول‌های محتوا اگر پهن بودند، اسکرول داخلی بگیرند نه کل صفحه */
    .entry-content table,
    .woocommerce-page table {
        display: block;
        overflow-x: auto;
        max-width: 100%;
        -webkit-overflow-scrolling: touch;
    }
}
