/* ============================================================
   UI FEATURES CSS
   Cookie Banner · Back to Top · Preloader · Dark Mode · RTL
   ============================================================ */

/* ── SKIP LINK (accessibility) ────────────────────────────── */
.skip-link {
    position: absolute;
    top: -100%;
    left: var(--spacing-sm);
    z-index: 99999;
    background: var(--color-primary);
    color: #fff;
    padding: 10px 20px;
    border-radius: 0 0 var(--radius) var(--radius);
    font-weight: 600;
    font-size: var(--font-sm);
    transition: top 0.2s;
}
.skip-link:focus { top: 0; color: #fff; }

/* ── PRELOADER ────────────────────────────────────────────── */
.preloader {
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: var(--color-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}
.preloader--done {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}
.preloader__inner { display: flex; flex-direction: column; align-items: center; gap: 20px; }

/* Spinner style */
.preloader__spinner {
    width: 44px;
    height: 44px;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Dots style */
.preloader__dots { display: flex; gap: 10px; }
.preloader__dots span {
    width: 12px; height: 12px;
    background: var(--color-primary);
    border-radius: 50%;
    animation: bounce 0.8s ease-in-out infinite;
}
.preloader__dots span:nth-child(1) { animation-delay: 0s; }
.preloader__dots span:nth-child(2) { animation-delay: 0.15s; }
.preloader__dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
    40%           { transform: scale(1);   opacity: 1;   }
}

/* Bar style */
.preloader__bar {
    width: 200px; height: 3px;
    background: var(--color-border);
    border-radius: 2px;
    overflow: hidden;
}
.preloader__bar-fill {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, var(--color-primary), #00b4d8);
    border-radius: 2px;
    animation: bar-load 2s ease forwards;
}
@keyframes bar-load { 0% { width: 0; } 60% { width: 85%; } 100% { width: 100%; } }
.preloader__site-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--color-text);
    letter-spacing: 2px;
    text-transform: uppercase;
}

/* ── BACK TO TOP ──────────────────────────────────────────── */
.back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 900;
    width: 46px;
    height: 46px;
    background: var(--color-primary);
    color: #fff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(0,115,170,0.35);
    opacity: 0;
    transform: translateY(16px);
    transition: opacity 0.3s ease, transform 0.3s ease, background 0.2s ease;
    pointer-events: none;
}
.back-to-top--visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}
.back-to-top:hover { background: var(--color-secondary); transform: translateY(-3px); }

/* ── COOKIE BANNER ────────────────────────────────────────── */
.cookie-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    background: #1a1a2e;
    color: #e2e8f0;
    padding: var(--spacing-sm) var(--spacing-sm);
    box-shadow: 0 -4px 20px rgba(0,0,0,0.2);
    border-top: 1px solid rgba(255,255,255,0.08);
    transform: translateY(0);
    transition: transform 0.4s ease, opacity 0.4s ease;
}
.cookie-banner--hiding {
    transform: translateY(100%);
    opacity: 0;
}
.cookie-banner__inner {
    max-width: var(--max-width);
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    flex-wrap: wrap;
}
.cookie-banner__icon { font-size: 1.6rem; flex-shrink: 0; }
.cookie-banner__text {
    flex: 1;
    font-size: var(--font-sm);
    line-height: 1.6;
    color: rgba(255,255,255,0.8);
    min-width: 200px;
}
.cookie-banner__policy {
    color: #60c2f5;
    margin-left: 4px;
    text-decoration: underline;
}
.cookie-banner__actions { display: flex; gap: 10px; flex-shrink: 0; }
.cookie-btn {
    padding: 9px 22px;
    border-radius: 6px;
    font-size: var(--font-sm);
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
    white-space: nowrap;
}
.cookie-btn--accept  { background: var(--color-primary); color: #fff; }
.cookie-btn--accept:hover  { background: #0096dd; }
.cookie-btn--decline { background: rgba(255,255,255,0.08); color: rgba(255,255,255,0.7); border: 1px solid rgba(255,255,255,0.15); }
.cookie-btn--decline:hover { background: rgba(255,255,255,0.15); color: #fff; }

/* ── DARK MODE TOGGLE BUTTON ──────────────────────────────── */
.dark-mode-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    background: var(--color-bg-alt);
    border: 1px solid var(--color-border);
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.1rem;
    transition: all 0.2s ease;
    flex-shrink: 0;
}
.dark-mode-toggle:hover {
    background: var(--color-primary);
    border-color: var(--color-primary);
}
.dark-mode-toggle__icon--dark  { display: none; }
.dark-mode-toggle__icon--light { display: block; }

/* ── DARK MODE VARIABLES ──────────────────────────────────── */
html.dark-mode {
    --color-bg:      #0f172a;
    --color-bg-alt:  #1e293b;
    --color-text:    #e2e8f0;
    --color-muted:   #94a3b8;
    --color-border:  #334155;
    --shadow:        0 2px 12px rgba(0,0,0,0.4);
}

html.dark-mode .dark-mode-toggle__icon--dark  { display: block; }
html.dark-mode .dark-mode-toggle__icon--light { display: none; }

html.dark-mode #site-header {
    background: var(--color-bg);
    border-bottom-color: var(--color-border);
}
html.dark-mode .post-card,
html.dark-mode .post-list-item,
html.dark-mode .search-result-item,
html.dark-mode .widget-item,
html.dark-mode .author-bio-box,
html.dark-mode .related-card,
html.dark-mode .comment-body {
    background: var(--color-bg-alt);
    border-color: var(--color-border);
}
html.dark-mode .post-card:hover,
html.dark-mode .post-list-item:hover { box-shadow: 0 8px 28px rgba(0,0,0,0.4); }
html.dark-mode .social-share-box,
html.dark-mode .search-no-results__suggestions,
html.dark-mode .category-filter .cat-btn:not(.is-active) {
    background: var(--color-bg-alt);
    border-color: var(--color-border);
}
html.dark-mode .cat-btn:not(.is-active) { color: var(--color-muted); }
html.dark-mode .preloader { background: var(--color-bg); }
html.dark-mode .mobile-nav {
    background: var(--color-bg);
    border-bottom-color: var(--color-border);
}
html.dark-mode .mobile-nav ul li a:hover { background: var(--color-bg-alt); }
html.dark-mode .page-wrapper--single,
html.dark-mode .blog-page-header { border-bottom-color: var(--color-border); }
html.dark-mode input,
html.dark-mode textarea,
html.dark-mode select {
    background: var(--color-bg-alt);
    border-color: var(--color-border);
    color: var(--color-text);
}
html.dark-mode .search-refine-input,
html.dark-mode .error-404-search__input { color: var(--color-text); }
html.dark-mode .tag-pill,
html.dark-mode .error-404-cat-pill { background: var(--color-bg-alt); border-color: var(--color-border); }
html.dark-mode mark.search-highlight { background: #3d3200; color: #fcd34d; }

/* Smooth dark mode transition */
html { transition: background-color 0.3s ease, color 0.3s ease; }

/* ── COMMENTS ─────────────────────────────────────────────── */
.comments-area { margin-top: var(--spacing-xl); }
.comments-title {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: var(--spacing-lg);
    padding-bottom: var(--spacing-xs);
    border-bottom: 2px solid var(--color-border);
}
.comments-title span { color: var(--color-primary); }

.comment-list { list-style: none; display: flex; flex-direction: column; gap: var(--spacing-md); }
.comment-item { }
.comment-item.parent > .comment-body > .children {
    margin-top: var(--spacing-md);
    margin-left: var(--spacing-lg);
    padding-left: var(--spacing-md);
    border-left: 3px solid var(--color-border);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    list-style: none;
}

.comment-body {
    background: var(--color-bg-alt);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: var(--spacing-md);
}
.comment-meta {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-sm);
}
.comment-author-avatar { flex-shrink: 0; }
.comment-avatar {
    width: 48px !important;
    height: 48px !important;
    border-radius: 50%;
    object-fit: cover;
}
.comment-author-info { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.comment-author-name { font-weight: 700; font-size: var(--font-sm); }
.comment-author-name a { color: var(--color-text); text-decoration: none; }
.comment-date { font-size: 12px; color: var(--color-muted); }
.comment-actions { margin-left: auto; display: flex; gap: 8px; }
.comment-reply-link,
.comment-edit-link {
    font-size: 12px;
    font-weight: 600;
    color: var(--color-primary);
    text-decoration: none;
    padding: 3px 10px;
    border: 1px solid var(--color-primary);
    border-radius: 4px;
    transition: all 0.2s ease;
}
.comment-reply-link:hover,
.comment-edit-link:hover { background: var(--color-primary); color: #fff; }
.comment-awaiting-moderation {
    font-size: var(--font-sm);
    color: #856404;
    background: #fff3cd;
    border-radius: 4px;
    padding: 6px 12px;
    margin-bottom: var(--spacing-xs);
}
.comment-content p { margin-bottom: var(--spacing-xs); font-size: var(--font-sm); }
.comment-content p:last-child { margin-bottom: 0; }

/* Comment form */
.comment-respond { margin-top: var(--spacing-lg); }
.comment-respond .comment-reply-title {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: var(--spacing-md);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-sm);
}
.comment-respond .comment-reply-title small a {
    font-size: var(--font-sm);
    font-weight: 500;
    color: var(--color-muted);
}
.comment-form { display: flex; flex-direction: column; gap: var(--spacing-sm); }
.comment-form-fields { display: flex; gap: var(--spacing-sm); }
.comment-form-field { display: flex; flex-direction: column; gap: 6px; flex: 1; }
.comment-form-field label {
    font-size: var(--font-sm);
    font-weight: 600;
    color: var(--color-text);
}
.comment-form-field .required { color: var(--color-primary); }
.comment-form-field input,
.comment-form-field textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: var(--font-sm);
    font-family: inherit;
    transition: border-color 0.2s ease;
    background: var(--color-bg);
    color: var(--color-text);
}
.comment-form-field input:focus,
.comment-form-field textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(0,115,170,0.15);
}
.comment-form-cookies { display: flex; align-items: center; gap: 8px; flex-direction: row !important; }
.comment-form-cookies label { display: flex; align-items: center; gap: 8px; font-weight: 400; cursor: pointer; }
.comment-submit-btn {
    align-self: flex-start;
    padding: 11px 28px;
    background: var(--color-primary);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-size: var(--font-sm);
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.1s ease;
}
.comment-submit-btn:hover { background: var(--color-secondary); transform: translateY(-1px); }
.comments-password-notice,
.no-comments-notice {
    padding: var(--spacing-md);
    background: var(--color-bg-alt);
    border-radius: var(--radius);
    border: 1px solid var(--color-border);
    font-size: var(--font-sm);
    color: var(--color-muted);
    text-align: center;
}

/* ── CUSTOM PAGE TEMPLATES ────────────────────────────────── */
.landing-page-body { margin: 0; padding: 0; }
.page-wrapper--single { max-width: var(--max-width); margin: 0 auto; padding: var(--spacing-lg) var(--spacing-sm); }
.page-title { font-size: clamp(1.6rem, 4vw, 2.4rem); font-weight: 700; margin-bottom: var(--spacing-md); }

/* ── RESPONSIVE ───────────────────────────────────────────── */
@media (max-width: 767px) {
    .cookie-banner__inner { flex-direction: column; align-items: flex-start; gap: var(--spacing-sm); }
    .cookie-banner__actions { width: 100%; }
    .cookie-btn { flex: 1; text-align: center; }
    .back-to-top { bottom: 80px; right: 16px; width: 42px; height: 42px; }
    .comment-form-fields { flex-direction: column; }
    .comment-item.parent > .comment-body > .children { margin-left: var(--spacing-sm); }
    .comment-meta { flex-wrap: wrap; }
    .comment-actions { margin-left: 0; width: 100%; }
}

@media (max-width: 480px) {
    .cookie-banner { padding: var(--spacing-sm); }
    .dark-mode-toggle { width: 34px; height: 34px; font-size: 1rem; }
}
