/*
Theme Name: Elementha
Theme URI: https://elementha.ir
Author: Hamed Bagheri
Author URI: https://hamedbagheri.ir
Description: قالب اختصاصی سایت المنتها - کتابخانه المان‌های المنتور
Version: 1.0.0
Requires at least: 6.0
Tested up to: 6.5
Requires PHP: 8.0
License: GPL-2.0-or-later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: elementha
Tags: rtl-language, custom-menu, featured-images, dark-mode
*/

/* ==========================================
   ELEMENTHA THEME - MAIN STYLES
   ========================================== */

:root {
  /* Colors - Light Mode */
  --bg-primary: #F7F8FA;
  --bg-secondary: #FFFFFF;
  --bg-tertiary: #EEF0F4;
  --text-primary: #0D0F14;
  --text-secondary: #4A5568;
  --text-muted: #8A9BB0;
  --border-color: #E2E8F0;
  --accent: #4361EE;
  --accent-hover: #3451D1;
  --accent-soft: rgba(67,97,238,0.10);
  --accent-glow: rgba(67,97,238,0.25);
  --free-color: #10B981;
  --free-bg: rgba(16,185,129,0.10);
  --pro-color: #F59E0B;
  --pro-bg: rgba(245,158,11,0.10);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --sidebar-width: 260px;
  --header-height: 64px;
  --transition: 0.2s ease;
}

[data-theme="dark"] {
  --bg-primary: #0D0F14;
  --bg-secondary: #161921;
  --bg-tertiary: #1E2230;
  --text-primary: #F0F4FF;
  --text-secondary: #A0AEC0;
  --text-muted: #556070;
  --border-color: #252A38;
  --accent-soft: rgba(67,97,238,0.15);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.5);
}

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

html {
  scroll-behavior: smooth;
  direction: rtl;
}

body {
  font-family: 'Vazirmatn', 'Tahoma', sans-serif;
  font-size: 15px;
  line-height: 1.7;
  background: var(--bg-primary);
  color: var(--text-primary);
  transition: background var(--transition), color var(--transition);
  -webkit-font-smoothing: antialiased;
}

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

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

/* ========== HEADER ========== */
#site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-height);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  box-shadow: var(--shadow-sm);
  transition: background var(--transition), border-color var(--transition);
}

.site-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  flex-shrink: 0;
}

.site-logo .logo-icon {
  width: 36px;
  height: 36px;
  background: var(--accent);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 18px;
  font-weight: 900;
}

.site-logo .logo-text {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

.site-logo .logo-text span { color: var(--accent); }

.header-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-right: auto;
}

.header-nav a {
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all var(--transition);
}

.header-nav a:hover,
.header-nav a.active {
  color: var(--accent);
  background: var(--accent-soft);
}

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

.btn-theme-toggle {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: all var(--transition);
}

.btn-theme-toggle:hover { color: var(--accent); border-color: var(--accent); }

.btn-pro {
  padding: 7px 16px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition);
  font-family: inherit;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-pro:hover { background: var(--accent-hover); color: white; }

/* ========== LAYOUT ========== */
#main-wrapper {
  display: flex;
  min-height: calc(100vh - var(--header-height));
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 16px;
  gap: 0;
}

/* ========== SIDEBAR ========== */
#sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  padding: 24px 0 24px 16px;
  position: sticky;
  top: calc(var(--header-height) + 16px);
  align-self: flex-start;
  max-height: calc(100vh - var(--header-height) - 32px);
  overflow-y: auto;
}

#sidebar::-webkit-scrollbar { width: 4px; }
#sidebar::-webkit-scrollbar-track { background: transparent; }
#sidebar::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 2px; }

.sidebar-section { margin-bottom: 28px; }

.sidebar-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-bottom: 10px;
  padding-right: 4px;
}

.category-list { list-style: none; }

.category-list li a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-secondary);
  transition: all var(--transition);
  gap: 8px;
}

.category-list li a:hover,
.category-list li.current-cat a {
  background: var(--accent-soft);
  color: var(--accent);
}

.cat-count {
  font-size: 11px;
  background: var(--bg-tertiary);
  color: var(--text-muted);
  padding: 2px 7px;
  border-radius: 20px;
  font-weight: 600;
}

.category-list li.current-cat .cat-count {
  background: var(--accent);
  color: white;
}

/* ========== CONTENT AREA ========== */
#content {
  flex: 1;
  min-width: 0;
  padding: 24px 0 24px 0;
  padding-right: 24px;
}

/* ========== FILTER BAR ========== */
.filter-bar {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 20px;
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.search-box {
  flex: 1;
  min-width: 200px;
  position: relative;
}

.search-box input {
  width: 100%;
  padding: 9px 40px 9px 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-primary);
  font-family: inherit;
  transition: border-color var(--transition);
  outline: none;
}

.search-box input:focus { border-color: var(--accent); }
.search-box input::placeholder { color: var(--text-muted); }

.search-box .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 14px;
  pointer-events: none;
}

.filter-tabs {
  display: flex;
  gap: 6px;
  background: var(--bg-tertiary);
  padding: 4px;
  border-radius: var(--radius-sm);
}

.filter-tab {
  padding: 6px 14px;
  border-radius: 5px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  gap: 6px;
}

.filter-tab.active {
  background: var(--bg-secondary);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

.filter-tab .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.dot-all { background: var(--accent); }
.dot-free { background: var(--free-color); }
.dot-pro { background: var(--pro-color); }

/* ========== ELEMENTS GRID ========== */
.elements-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.elements-count {
  font-size: 13px;
  color: var(--text-muted);
}

.elements-count strong { color: var(--text-primary); }

.elements-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

/* ========== ELEMENT CARD ========== */
.element-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: all var(--transition);
  position: relative;
  cursor: pointer;
}

.element-card:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow), var(--shadow-md);
  transform: translateY(-2px);
}

.card-thumb {
  position: relative;
  aspect-ratio: 16/10;
  overflow: hidden;
  background: var(--bg-tertiary);
}

.card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}

.element-card:hover .card-thumb img { transform: scale(1.04); }

.card-thumb .no-image {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 32px;
}

.badge {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
}

.badge-free { background: var(--free-bg); color: var(--free-color); }
.badge-pro { background: var(--pro-bg); color: var(--pro-color); }

.card-preview-btn {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.5);
  opacity: 0;
  transition: opacity var(--transition);
  color: white;
  font-size: 14px;
  font-weight: 600;
  gap: 8px;
}

.element-card:hover .card-preview-btn { opacity: 1; }

.card-body {
  padding: 14px;
}

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

.card-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--text-muted);
}

.card-meta span { display: flex; align-items: center; gap: 4px; }

/* ========== SINGLE ELEMENT ========== */
.single-element-wrap {
  max-width: 900px;
}

.element-hero {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 24px;
}

.element-hero-image {
  width: 100%;
  aspect-ratio: 16/7;
  object-fit: cover;
}

.element-hero-body {
  padding: 28px;
}

.element-meta-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.element-cats a {
  font-size: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 3px 10px;
  border-radius: 20px;
  font-weight: 600;
}

.element-stats {
  display: flex;
  gap: 16px;
  font-size: 13px;
  color: var(--text-muted);
  margin-right: auto;
}

.element-stats span { display: flex; align-items: center; gap: 5px; }

.element-title-single {
  font-size: 26px;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 14px;
  line-height: 1.4;
}

.element-description {
  color: var(--text-secondary);
  line-height: 1.9;
  font-size: 15px;
}

.element-description p { margin-bottom: 12px; }
.element-description h2, .element-description h3 { margin: 20px 0 10px; color: var(--text-primary); }

/* ========== ACTION BUTTONS ========== */
.element-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 22px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  border: none;
  font-family: inherit;
  transition: all var(--transition);
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: white;
}

.btn-primary:hover { background: var(--accent-hover); color: white; transform: translateY(-1px); }

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }

.btn-copy {
  background: linear-gradient(135deg, #4361EE, #7B2FBE);
  color: white;
}

.btn-copy:hover { opacity: 0.9; transform: translateY(-1px); }
.btn-copy.copied { background: var(--free-color); }

.btn-download {
  background: var(--free-color);
  color: white;
}

.btn-download:hover { opacity: 0.9; transform: translateY(-1px); }

/* ========== RCP LOCK BOX ========== */
.rcp-lock-box {
  margin-top: 24px;
  padding: 24px;
  background: linear-gradient(135deg, rgba(245,158,11,0.06), rgba(245,158,11,0.02));
  border: 1px solid rgba(245,158,11,0.25);
  border-radius: var(--radius-md);
  text-align: center;
}

.rcp-lock-box .lock-icon {
  font-size: 32px;
  margin-bottom: 12px;
}

.rcp-lock-box h3 {
  font-size: 17px;
  font-weight: 800;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.rcp-lock-box p {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

/* ========== LIGHTBOX PREVIEW ========== */
.lightbox-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.88);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.lightbox-overlay.active { display: flex; }

.lightbox-box {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 1100px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  box-shadow: 0 32px 80px rgba(0,0,0,0.5);
}

.lightbox-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.lightbox-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

.lightbox-close {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  line-height: 1;
  transition: all var(--transition);
}

.lightbox-close:hover { color: var(--text-primary); border-color: var(--text-primary); }

.lightbox-iframe-wrap {
  flex: 1;
  position: relative;
  min-height: 500px;
}

.lightbox-iframe-wrap iframe {
  width: 100%;
  height: 100%;
  min-height: 500px;
  border: none;
  display: block;
}

/* ========== COMMENTS AREA ========== */
.comments-section {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 28px;
  margin-top: 24px;
}

.comments-section h3 {
  font-size: 17px;
  font-weight: 800;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-color);
}

.comment-item {
  display: flex;
  gap: 14px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border-color);
}

.comment-item:last-child { border-bottom: none; }

.comment-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent-soft);
  flex-shrink: 0;
  overflow: hidden;
}

.comment-avatar img { width: 100%; height: 100%; object-fit: cover; }

.comment-content .comment-author {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.comment-content .comment-date {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.comment-content .comment-text {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.7;
}

/* ========== COMMENT FORM ========== */
.comment-form { margin-top: 24px; }

.comment-form h4 {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 16px;
}

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-group input,
.form-group textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-primary);
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition);
  direction: rtl;
}

.form-group input:focus,
.form-group textarea:focus { border-color: var(--accent); }

.form-group textarea { min-height: 100px; resize: vertical; }

/* ========== PAGINATION ========== */
.pagination {
  display: flex;
  gap: 6px;
  margin-top: 32px;
  justify-content: center;
}

.pagination a,
.pagination span {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  transition: all var(--transition);
}

.pagination a:hover,
.pagination .current {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

/* ========== FOOTER ========== */
#site-footer {
  border-top: 1px solid var(--border-color);
  padding: 24px;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 40px;
}

#site-footer a { color: var(--accent); }

/* ========== RESPONSIVE ========== */
@media (max-width: 900px) {
  #main-wrapper { flex-direction: column; }
  #sidebar {
    width: 100%;
    position: static;
    padding: 16px 0;
    max-height: none;
  }
  #content { padding: 0; }
  .elements-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
  .form-row { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  #site-header { padding: 0 16px; }
  .header-nav { display: none; }
  .element-title-single { font-size: 20px; }
  .elements-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .filter-bar { flex-direction: column; align-items: stretch; }
  .lightbox-box { max-height: 95vh; }
  .lightbox-iframe-wrap { min-height: 350px; }
  .lightbox-iframe-wrap iframe { min-height: 350px; }
}

/* ========== UTILITY ========== */
.text-center { text-align: center; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }

/* ========== LOADING SKELETON ========== */
.skeleton {
  background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--border-color) 50%, var(--bg-tertiary) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ========== TOAST ========== */
.toast {
  position: fixed;
  bottom: 24px;
  left: 24px;
  background: #1a1a1a;
  color: white;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  z-index: 9999;
  display: flex;
  align-items: center;
  gap: 8px;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.34,1.56,0.64,1);
  box-shadow: var(--shadow-lg);
}

.toast.show { transform: translateY(0); opacity: 1; }
.toast-success { background: var(--free-color); }
