/* ===== Theme Enhancements ===== */

/* ===== Global Improvements ===== */
* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Vazir', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-secondary);
    overflow-x: hidden;
}

/* ===== Professional Polish (Global Palette & Density) ===== */
:root {
    /* Calmer newsroom palette */
    --primary: #1e3a8a;        /* Royal Blue */
    --primary-dark: #1e2a5e;   /* Darker Royal Blue */
    --primary-light: #2563eb;  /* Lighter Royal Blue */
    --accent: #e11d48;         /* Rose-600 */
    --accent-dark: #be123c;    /* Rose-700 */

    /* Softer shadows site-wide */
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 3px 8px rgba(0,0,0,0.08);
    --shadow-lg: 0 12px 24px rgba(0,0,0,0.10);
}

/* Density and subtlety for a newsroom feel */
.container { padding: 0 var(--spacing-sm); }

/* Tighter global spacing for desktop */
:root {
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
}

/* Headings a bit smaller and calmer */
h1 { font-size: 2.1rem !important; }
h2 { font-size: 1.75rem !important; }
h3 { font-size: 1.35rem !important; }
h4 { font-size: 1.1rem !important; }

/* ===== Header Polish ===== */
.header-top {
    background: var(--bg-secondary) !important;
    color: var(--text-secondary) !important;
    padding: 6px 0 !important;
}
.header-top .header-social a,
.header-top .header-social button { background: transparent !important; border: 1px solid var(--border-light) !important; color: var(--text-secondary) !important; width: 28px !important; height: 28px !important; font-size: 0.9rem !important; }

.header-main { padding: var(--spacing-sm) 0 !important; border-bottom: 1px solid var(--border-light) !important; }
.site-logo { font-size: 1.5rem !important; }
.site-logo i { background: none !important; color: var(--primary); -webkit-text-fill-color: initial; }

.header-search .search-input { border-width: 1px !important; border-radius: var(--radius-md) !important; font-size: 0.9rem !important; }
.header-search .search-btn { width: 36px !important; height: 36px !important; border-radius: var(--radius-sm) !important; }

.header-nav { border-bottom: 1px solid var(--border-light) !important; }
.primary-menu li a {
    padding: var(--spacing-xs) var(--spacing-sm) !important;
    border-radius: var(--radius-sm) !important;
}
.primary-menu li a:hover,
.primary-menu li.current-menu-item a {
    background: transparent !important;
    color: var(--primary) !important;
}
.primary-menu li a::after { height: 1px !important; background: var(--primary) !important; opacity: .8; }

/* ===== Breaking News: calmer treatment ===== */
.breaking-news-ticker {
    background: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
    padding: 4px 0 !important; /* slimmer height */
    border-top: 1px solid var(--border-light) !important;
    border-bottom: 1px solid var(--border-light) !important;
}
.breaking-news-wrapper { gap: var(--spacing-xs) !important; align-items: center !important; }
.breaking-news-label {
    background: transparent !important;
    color: var(--text-secondary) !important; /* calmer label */
    padding: 0 !important;
    font-weight: 600 !important;
    display: inline-flex !important; align-items: center !important; gap: 6px !important;
}
.breaking-news-label i { color: var(--accent) !important; font-size: 0.85rem !important; animation: none !important; opacity: 0.9; }
.breaking-news-content { height: 18px !important; }
.breaking-news-content .news-item { line-height: 18px !important; }
.breaking-news-content .news-item a { font-size: 0.9rem !important; color: var(--text-primary) !important; }

/* ===== Cards & Lists Polish ===== */
.card,
.post-card,
.widget,
.side-news-item {
    border-radius: var(--radius-md) !important;
    box-shadow: var(--shadow-sm) !important;
}
.card:hover,
.post-card:hover { transform: none !important; box-shadow: var(--shadow-sm) !important; }

.post-title { font-size: 1.05rem; }
.post-excerpt { font-size: 0.85rem; }

/* Tighter gaps */
.content-header { margin-bottom: var(--spacing-md) !important; padding-bottom: var(--spacing-sm) !important; }
.posts-grid { gap: var(--spacing-sm) !important; }
.categories-grid { gap: var(--spacing-md) !important; }

/* Sidebar widgets full-width and tidy */
.sidebar .widget { width: 100% !important; padding: var(--spacing-sm) !important; }
.widget-title { font-size: 0.95rem !important; padding-bottom: var(--spacing-xs) !important; border-bottom: 1px solid var(--border-light) !important; }

/* ===== Footer refinement ===== */
.footer { background: var(--bg-secondary) !important; }
.footer-widget-title { border-bottom-width: 1px !important; font-size: 1rem !important; }

/* ===== Hero subtle adjustments (applies across demos) ===== */
.hero-section.modern-hero { background: linear-gradient(135deg, var(--bg-secondary), rgba(30,58,138,0.04)) !important; margin: var(--spacing-lg) 0 !important; }
.hero-title { letter-spacing: -0.2px; font-size: 1.6rem !important; }
.hero-image { height: 220px !important; }
.hero-excerpt { font-size: 0.95rem !important; }

/* Badges quieter */
.post-badge {
    background: var(--bg-secondary) !important;
    color: var(--text-secondary) !important;
    border: 1px solid var(--border-light) !important;
}


/* ===== Selection Styles ===== */
::selection {
    background: var(--primary);
    color: var(--text-white);
}

::-moz-selection {
    background: var(--primary);
    color: var(--text-white);
}

/* ===== Scrollbar Styles ===== */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-dark);
}

/* ===== Focus Styles ===== */
*:focus {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

button:focus,
input:focus,
textarea:focus,
select:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* ===== Loading States ===== */
.loading {
    position: relative;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid var(--border-light);
    border-top: 2px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ===== Skeleton Loading ===== */
.skeleton {
    background: linear-gradient(90deg, var(--bg-secondary) 25%, var(--border-light) 50%, var(--bg-secondary) 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ===== Hover Effects ===== */
.hover-lift {
    transition: transform var(--transition-fast);
}

.hover-lift:hover {
    transform: translateY(-5px);
}

.hover-scale {
    transition: transform var(--transition-fast);
}

.hover-scale:hover {
    transform: scale(1.05);
}

.hover-glow {
    transition: box-shadow var(--transition-fast);
}

.hover-glow:hover {
    box-shadow: 0 0 20px rgba(37, 99, 235, 0.3);
}

/* ===== Text Effects ===== */
.text-gradient {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.text-shadow {
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.text-glow {
    text-shadow: 0 0 10px rgba(37, 99, 235, 0.5);
}

/* ===== Border Effects ===== */
.border-gradient {
    border: 2px solid transparent;
    background: linear-gradient(var(--bg-primary), var(--bg-primary)) padding-box,
                linear-gradient(135deg, var(--primary), var(--accent)) border-box;
}

.border-dashed {
    border: 2px dashed var(--border-light);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    text-align: center;
    color: var(--text-muted);
}

/* ===== Shadow Effects ===== */
.shadow-sm { box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05); }
.shadow { box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06); }
.shadow-md { box-shadow: 0 4px 6px rgba(0, 0, 0, 0.07), 0 2px 4px rgba(0, 0, 0, 0.06); }
.shadow-lg { box-shadow: 0 10px 15px rgba(0, 0, 0, 0.1), 0 4px 6px rgba(0, 0, 0, 0.05); }
.shadow-xl { box-shadow: 0 20px 25px rgba(0, 0, 0, 0.1), 0 10px 10px rgba(0, 0, 0, 0.04); }
.shadow-2xl { box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25); }

/* ===== Spacing Utilities ===== */
.m-0 { margin: 0; }
.m-1 { margin: var(--spacing-xs); }
.m-2 { margin: var(--spacing-sm); }
.m-3 { margin: var(--spacing-md); }
.m-4 { margin: var(--spacing-lg); }
.m-5 { margin: var(--spacing-xl); }

.p-0 { padding: 0; }
.p-1 { padding: var(--spacing-xs); }
.p-2 { padding: var(--spacing-sm); }
.p-3 { padding: var(--spacing-md); }
.p-4 { padding: var(--spacing-lg); }
.p-5 { padding: var(--spacing-xl); }

/* ===== Display Utilities ===== */
.d-none { display: none; }
.d-block { display: block; }
.d-inline { display: inline; }
.d-inline-block { display: inline-block; }
.d-flex { display: flex; }
.d-grid { display: grid; }

/* ===== Flexbox Utilities ===== */
.flex-row { flex-direction: row; }
.flex-column { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.flex-nowrap { flex-wrap: nowrap; }
.justify-start { justify-content: flex-start; }
.justify-center { justify-content: center; }
.justify-end { justify-content: flex-end; }
.justify-between { justify-content: space-between; }
.justify-around { justify-content: space-around; }
.align-start { align-items: flex-start; }
.align-center { align-items: center; }
.align-end { align-items: flex-end; }
.align-stretch { align-items: stretch; }

/* ===== Text Utilities ===== */
.text-left { text-align: left; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-justify { text-align: justify; }

.font-light { font-weight: 300; }
.font-normal { font-weight: 400; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.font-extrabold { font-weight: 800; }

.text-xs { font-size: 0.75rem; }
.text-sm { font-size: 0.875rem; }
.text-base { font-size: 1rem; }
.text-lg { font-size: 1.125rem; }
.text-xl { font-size: 1.25rem; }
.text-2xl { font-size: 1.5rem; }
.text-3xl { font-size: 1.875rem; }
.text-4xl { font-size: 2.25rem; }

/* ===== Color Utilities ===== */
.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.text-white { color: var(--text-white); }
.text-primary-color { color: var(--primary); }
.text-accent { color: var(--accent); }

.bg-primary { background-color: var(--bg-primary); }
.bg-secondary { background-color: var(--bg-secondary); }
.bg-primary-color { background-color: var(--primary); }
.bg-accent { background-color: var(--accent); }

/* ===== Border Utilities ===== */
.border { border: 1px solid var(--border-light); }
.border-t { border-top: 1px solid var(--border-light); }
.border-r { border-right: 1px solid var(--border-light); }
.border-b { border-bottom: 1px solid var(--border-light); }
.border-l { border-left: 1px solid var(--border-light); }

.border-primary { border-color: var(--primary); }
.border-accent { border-color: var(--accent); }

.rounded { border-radius: var(--radius-md); }
.rounded-sm { border-radius: var(--radius-sm); }
.rounded-lg { border-radius: var(--radius-lg); }
.rounded-xl { border-radius: var(--radius-xl); }
.rounded-full { border-radius: 50%; }

/* ===== Position Utilities ===== */
.relative { position: relative; }
.absolute { position: absolute; }
.fixed { position: fixed; }
.sticky { position: sticky; }

.top-0 { top: 0; }
.right-0 { right: 0; }
.bottom-0 { bottom: 0; }
.left-0 { left: 0; }

/* ===== Overflow Utilities ===== */
.overflow-hidden { overflow: hidden; }
.overflow-auto { overflow: auto; }
.overflow-scroll { overflow: scroll; }

/* ===== Z-Index Utilities ===== */
.z-0 { z-index: 0; }
.z-10 { z-index: 10; }
.z-20 { z-index: 20; }
.z-30 { z-index: 30; }
.z-40 { z-index: 40; }
.z-50 { z-index: 50; }

/* ===== Width Utilities ===== */
.w-full { width: 100%; }
.w-auto { width: auto; }
.w-1/2 { width: 50%; }
.w-1/3 { width: 33.333333%; }
.w-2/3 { width: 66.666667%; }
.w-1/4 { width: 25%; }
.w-3/4 { width: 75%; }

/* ===== Height Utilities ===== */
.h-full { height: 100%; }
.h-auto { height: auto; }
.h-screen { height: 100vh; }

/* ===== Animation Utilities ===== */
.animate-pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.animate-bounce {
    animation: bounce 1s infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(-25%); animation-timing-function: cubic-bezier(0.8, 0, 1, 1); }
    50% { transform: translateY(0); animation-timing-function: cubic-bezier(0, 0, 0.2, 1); }
}

.animate-spin {
    animation: spin 1s linear infinite;
}

.animate-ping {
    animation: ping 1s cubic-bezier(0, 0, 0.2, 1) infinite;
}

@keyframes ping {
    75%, 100% { transform: scale(2); opacity: 0; }
}

/* ===== Transition Utilities ===== */
.transition { transition: all var(--transition-fast); }
.transition-fast { transition: all var(--transition-fast); }
.transition-normal { transition: all var(--transition-normal); }
.transition-slow { transition: all var(--transition-slow); }

/* ===== Transform Utilities ===== */
.transform { transform: translateZ(0); }
.scale-0 { transform: scale(0); }
.scale-50 { transform: scale(0.5); }
.scale-75 { transform: scale(0.75); }
.scale-90 { transform: scale(0.9); }
.scale-95 { transform: scale(0.95); }
.scale-100 { transform: scale(1); }
.scale-105 { transform: scale(1.05); }
.scale-110 { transform: scale(1.1); }
.scale-125 { transform: scale(1.25); }
.scale-150 { transform: scale(1.5); }

.rotate-0 { transform: rotate(0deg); }
.rotate-1 { transform: rotate(1deg); }
.rotate-2 { transform: rotate(2deg); }
.rotate-3 { transform: rotate(3deg); }
.rotate-6 { transform: rotate(6deg); }
.rotate-12 { transform: rotate(12deg); }
.rotate-45 { transform: rotate(45deg); }
.rotate-90 { transform: rotate(90deg); }
.rotate-180 { transform: rotate(180deg); }

/* ===== Opacity Utilities ===== */
.opacity-0 { opacity: 0; }
.opacity-25 { opacity: 0.25; }
.opacity-50 { opacity: 0.5; }
.opacity-75 { opacity: 0.75; }
.opacity-100 { opacity: 1; }

/* ===== Cursor Utilities ===== */
.cursor-auto { cursor: auto; }
.cursor-default { cursor: default; }
.cursor-pointer { cursor: pointer; }
.cursor-wait { cursor: wait; }
.cursor-text { cursor: text; }
.cursor-move { cursor: move; }
.cursor-help { cursor: help; }
.cursor-not-allowed { cursor: not-allowed; }

/* ===== User Select Utilities ===== */
.select-none { user-select: none; }
.select-text { user-select: text; }
.select-all { user-select: all; }
.select-auto { user-select: auto; }

/* ===== Pointer Events Utilities ===== */
.pointer-events-none { pointer-events: none; }
.pointer-events-auto { pointer-events: auto; }

/* ===== Visibility Utilities ===== */
.visible { visibility: visible; }
.invisible { visibility: hidden; }

/* ===== Print Utilities ===== */
@media print {
    .print-hidden { display: none !important; }
    .print-visible { display: block !important; }
}

/* ===== Dark Mode Utilities ===== */
.khb-dark .text-primary { color: var(--text-primary); }
.khb-dark .text-secondary { color: var(--text-secondary); }
.khb-dark .text-muted { color: var(--text-muted); }
.khb-dark .text-white { color: var(--text-white); }

.khb-dark .bg-primary { background-color: var(--bg-primary); }
.khb-dark .bg-secondary { background-color: var(--bg-secondary); }

.khb-dark .border { border-color: var(--border-light); }
.khb-dark .border-t { border-top-color: var(--border-light); }
.khb-dark .border-r { border-right-color: var(--border-light); }
.khb-dark .border-b { border-bottom-color: var(--border-light); }
.khb-dark .border-l { border-left-color: var(--border-light); }

/* ===== Responsive Utilities ===== */
@media (max-width: 640px) {
    .sm\:hidden { display: none; }
    .sm\:block { display: block; }
    .sm\:flex { display: flex; }
    .sm\:grid { display: grid; }
    
    .sm\:text-xs { font-size: 0.75rem; }
    .sm\:text-sm { font-size: 0.875rem; }
    .sm\:text-base { font-size: 1rem; }
    .sm\:text-lg { font-size: 1.125rem; }
    .sm\:text-xl { font-size: 1.25rem; }
    
    .sm\:p-0 { padding: 0; }
    .sm\:p-1 { padding: var(--spacing-xs); }
    .sm\:p-2 { padding: var(--spacing-sm); }
    .sm\:p-3 { padding: var(--spacing-md); }
    .sm\:p-4 { padding: var(--spacing-lg); }
    
    .sm\:m-0 { margin: 0; }
    .sm\:m-1 { margin: var(--spacing-xs); }
    .sm\:m-2 { margin: var(--spacing-sm); }
    .sm\:m-3 { margin: var(--spacing-md); }
    .sm\:m-4 { margin: var(--spacing-lg); }
}

@media (max-width: 768px) {
    .md\:hidden { display: none; }
    .md\:block { display: block; }
    .md\:flex { display: flex; }
    .md\:grid { display: grid; }
    
    .md\:text-xs { font-size: 0.75rem; }
    .md\:text-sm { font-size: 0.875rem; }
    .md\:text-base { font-size: 1rem; }
    .md\:text-lg { font-size: 1.125rem; }
    .md\:text-xl { font-size: 1.25rem; }
    .md\:text-2xl { font-size: 1.5rem; }
    
    .md\:p-0 { padding: 0; }
    .md\:p-1 { padding: var(--spacing-xs); }
    .md\:p-2 { padding: var(--spacing-sm); }
    .md\:p-3 { padding: var(--spacing-md); }
    .md\:p-4 { padding: var(--spacing-lg); }
    .md\:p-5 { padding: var(--spacing-xl); }
    
    .md\:m-0 { margin: 0; }
    .md\:m-1 { margin: var(--spacing-xs); }
    .md\:m-2 { margin: var(--spacing-sm); }
    .md\:m-3 { margin: var(--spacing-md); }
    .md\:m-4 { margin: var(--spacing-lg); }
    .md\:m-5 { margin: var(--spacing-xl); }
}

@media (max-width: 1024px) {
    .lg\:hidden { display: none; }
    .lg\:block { display: block; }
    .lg\:flex { display: flex; }
    .lg\:grid { display: grid; }
    
    .lg\:text-xs { font-size: 0.75rem; }
    .lg\:text-sm { font-size: 0.875rem; }
    .lg\:text-base { font-size: 1rem; }
    .lg\:text-lg { font-size: 1.125rem; }
    .lg\:text-xl { font-size: 1.25rem; }
    .lg\:text-2xl { font-size: 1.5rem; }
    .lg\:text-3xl { font-size: 1.875rem; }
    
    .lg\:p-0 { padding: 0; }
    .lg\:p-1 { padding: var(--spacing-xs); }
    .lg\:p-2 { padding: var(--spacing-sm); }
    .lg\:p-3 { padding: var(--spacing-md); }
    .lg\:p-4 { padding: var(--spacing-lg); }
    .lg\:p-5 { padding: var(--spacing-xl); }
    
    .lg\:m-0 { margin: 0; }
    .lg\:m-1 { margin: var(--spacing-xs); }
    .lg\:m-2 { margin: var(--spacing-sm); }
    .lg\:m-3 { margin: var(--spacing-md); }
    .lg\:m-4 { margin: var(--spacing-lg); }
    .lg\:m-5 { margin: var(--spacing-xl); }
}

/* ===== Accessibility Improvements ===== */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.sr-only-focusable:focus {
    position: static;
    width: auto;
    height: auto;
    padding: inherit;
    margin: inherit;
    overflow: visible;
    clip: auto;
    white-space: normal;
}

/* ===== High Contrast Mode ===== */
@media (prefers-contrast: high) {
    :root {
        --text-primary: #000000;
        --text-secondary: #333333;
        --text-muted: #666666;
        --bg-primary: #ffffff;
        --bg-secondary: #f5f5f5;
        --border-light: #cccccc;
        --primary: #0000ff;
        --accent: #ff0000;
    }
}

/* ===== Reduced Motion ===== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ===== Print Styles ===== */
@media print {
    * {
        background: transparent !important;
        color: black !important;
        box-shadow: none !important;
        text-shadow: none !important;
    }
    
    a,
    a:visited {
        text-decoration: underline;
    }
    
    a[href]:after {
        content: " (" attr(href) ")";
    }
    
    abbr[title]:after {
        content: " (" attr(title) ")";
    }
    
    .no-print {
        display: none !important;
    }
    
    .print-only {
        display: block !important;
    }
    
    h1, h2, h3, h4, h5, h6 {
        page-break-after: avoid;
    }
    
    p, h2, h3 {
        orphans: 3;
        widows: 3;
    }
    
    h2, h3 {
        page-break-after: avoid;
    }
}
