@import url('https://fonts.googleapis.com/css2?family=Rubik:wght@300;400;500;600;700&display=swap');

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --primary: #1a1a2e;
  --accent: #e94560;
  --accent-hover: #c73652;
  --bg: #f8f9fa;
  --sidebar-bg: #ffffff;
  --sidebar-width: 280px;
  --text-primary: #1a1a2e;
  --text-secondary: #6c757d;
  --border: #e9ecef;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
  --radius: 12px;
  --radius-sm: 8px;
}

html, body {
  direction: rtl;
  font-family: 'Rubik', sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
}

/* ========== LOGIN PAGE ========== */

.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.login-page::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -20%;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(233,69,96,0.15) 0%, transparent 70%);
  border-radius: 50%;
}

.login-page::after {
  content: '';
  position: absolute;
  bottom: -30%;
  left: -10%;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(233,69,96,0.1) 0%, transparent 70%);
  border-radius: 50%;
}

.login-card {
  background: #ffffff;
  border-radius: 20px;
  padding: 48px 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.3);
  position: relative;
  z-index: 1;
  animation: fadeInUp 0.5s ease;
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: translateY(0); }
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo .logo-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, var(--accent), #c73652);
  border-radius: 16px;
  margin-bottom: 16px;
  box-shadow: 0 8px 24px rgba(233,69,96,0.35);
}

.login-logo .logo-badge svg {
  width: 32px;
  height: 32px;
  fill: white;
}

.login-logo h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 4px;
  letter-spacing: -0.5px;
}

.login-logo p {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 400;
}

.login-form .form-group {
  margin-bottom: 20px;
}

.login-form label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.login-form input {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: 'Rubik', sans-serif;
  font-size: 15px;
  color: var(--text-primary);
  background: #fafafa;
  transition: all 0.2s;
  direction: ltr;
  text-align: right;
  outline: none;
}

.login-form input:focus {
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(233,69,96,0.12);
}

.login-form input::placeholder {
  color: #adb5bd;
  direction: rtl;
}

.btn-login {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, var(--accent), #c73652);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-family: 'Rubik', sans-serif;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 16px rgba(233,69,96,0.3);
  letter-spacing: 0.3px;
}

.btn-login:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(233,69,96,0.4);
}

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

.btn-login:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none;
}

.login-error {
  margin-top: 16px;
  padding: 12px 16px;
  background: #fff5f5;
  border: 1px solid #fed7d7;
  border-radius: var(--radius-sm);
  color: #c53030;
  font-size: 14px;
  text-align: center;
  display: none;
}

.login-error.show {
  display: block;
  animation: shake 0.3s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

.login-footer {
  margin-top: 24px;
  text-align: center;
  font-size: 12px;
  color: var(--text-secondary);
}

/* ========== WIKI PAGE ========== */

.wiki-layout {
  display: flex;
  flex-direction: row-reverse;
  min-height: 100vh;
}

/* Topbar */
.topbar {
  position: fixed;
  top: 0;
  right: 0;
  left: 0;
  height: 60px;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: white;
  text-decoration: none;
}

.topbar-brand .brand-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--accent), #c73652);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.topbar-brand span {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.3px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-user {
  font-size: 13px;
  color: rgba(255,255,255,0.7);
}

.btn-logout {
  padding: 6px 14px;
  background: rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.9);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 6px;
  font-family: 'Rubik', sans-serif;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-logout:hover {
  background: rgba(255,255,255,0.18);
  border-color: rgba(255,255,255,0.35);
}

/* Mobile menu toggle */
.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: white;
  font-size: 22px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  border-left: 1px solid var(--border);
  position: fixed;
  top: 60px;
  right: 0;
  bottom: 0;
  overflow-y: auto;
  padding: 20px 0;
  z-index: 50;
  transition: transform 0.3s ease;
}

.sidebar-header {
  padding: 0 20px 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}

.sidebar-header h3 {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.guide-list {
  list-style: none;
  padding: 8px 0;
}

.guide-list-item {
  padding: 0;
}

.guide-list-item a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: var(--text-primary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 400;
  transition: all 0.15s;
  cursor: pointer;
  border-right: 3px solid transparent;
}

.guide-list-item a:hover {
  background: #f8f9fa;
  color: var(--accent);
}

.guide-list-item a.active {
  background: #fff0f3;
  color: var(--accent);
  border-right-color: var(--accent);
  font-weight: 500;
}

.guide-list-item .guide-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  background: var(--border);
  border-radius: 50%;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  flex-shrink: 0;
  transition: all 0.15s;
}

.guide-list-item a.active .guide-num {
  background: var(--accent);
  color: white;
}

.guide-list-item .guide-title-text {
  flex: 1;
  line-height: 1.4;
}

/* Main content */
.main-content {
  margin-right: var(--sidebar-width);
  margin-top: 60px;
  flex: 1;
  padding: 40px;
  max-width: 860px;
  width: 100%;
}

.content-header {
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 2px solid var(--border);
}

.content-header h1 {
  font-size: 28px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 8px;
  line-height: 1.3;
}

.content-header .content-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 13px;
  color: var(--text-secondary);
}

.content-meta .badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  background: #fff0f3;
  color: var(--accent);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}

/* Guide content */
.guide-body {
  line-height: 1.85;
  font-size: 16px;
}

.guide-body p {
  margin-bottom: 16px;
  color: #2d3748;
}

.guide-body a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid rgba(233,69,96,0.3);
  transition: border-color 0.2s;
}

.guide-body a:hover {
  border-bottom-color: var(--accent);
}

.guide-body h2 {
  font-size: 20px;
  font-weight: 600;
  color: var(--primary);
  margin: 28px 0 12px;
}

.guide-body h3 {
  font-size: 17px;
  font-weight: 600;
  color: var(--primary);
  margin: 20px 0 8px;
}

.guide-body ul, .guide-body ol {
  margin: 12px 0 16px 0;
  padding-right: 24px;
}

.guide-body li {
  margin-bottom: 6px;
  color: #2d3748;
}

.guide-image {
  margin: 24px 0;
  text-align: center;
}

.guide-image img {
  max-width: 90%;
  width: auto;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.12);
  display: inline-block;
}

/* Loading & empty states */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  color: var(--text-secondary);
  gap: 16px;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}

.empty-state h3 {
  font-size: 18px;
  margin-bottom: 8px;
  color: var(--text-primary);
}

/* ========== LIGHTBOX ========== */

.lightbox-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.92);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
  touch-action: pinch-zoom;
}

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

.lightbox-overlay img {
  max-width: 95vw;
  max-height: 92vh;
  border-radius: 8px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.5);
  object-fit: contain;
  touch-action: pinch-zoom;
  user-select: none;
}

.lightbox-close {
  position: fixed;
  top: 16px;
  left: 16px;
  width: 40px;
  height: 40px;
  background: rgba(255,255,255,0.15);
  border: none;
  border-radius: 50%;
  color: white;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1001;
  transition: background 0.2s;
}

.lightbox-close:hover {
  background: rgba(255,255,255,0.25);
}

/* Desktop images also clickable */
.guide-image img {
  cursor: zoom-in;
  transition: opacity 0.15s;
}

.guide-image img:hover {
  opacity: 0.92;
}

/* ========== RESPONSIVE ========== */

/* Prevent horizontal scroll globally */
html, body {
  overflow-x: hidden;
  max-width: 100vw;
}

@media (max-width: 768px) {
  .menu-toggle {
    display: block;
  }

  .sidebar {
    transform: translateX(100%);
    width: min(300px, 85vw);
    box-shadow: var(--shadow-lg);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 49;
    top: 60px;
  }

  .sidebar-overlay.show {
    display: block;
  }

  .main-content {
    margin-right: 0;
    padding: 16px 14px 40px;
    max-width: 100vw;
    overflow-x: hidden;
  }

  .content-header {
    margin-bottom: 20px;
    padding-bottom: 16px;
  }

  .content-header h1 {
    font-size: 20px;
    line-height: 1.4;
  }

  .content-header .content-meta {
    flex-wrap: wrap;
    gap: 8px;
  }

  .guide-body {
    font-size: 15px;
  }

  .guide-body p {
    margin-bottom: 12px;
  }

  /* Images: centered with padding on mobile */
  .guide-image {
    margin: 16px 0;
    text-align: center;
    width: 100%;
  }

  .guide-image img {
    max-width: 92%;
    width: auto;
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.12);
    cursor: zoom-in;
  }

  .login-card {
    padding: 28px 20px;
    border-radius: 16px;
  }

  .topbar-user {
    display: none;
  }

  .topbar {
    padding: 0 14px;
  }

  .topbar-brand span {
    font-size: 14px;
  }

  /* Wiki layout on mobile: no sidebar shifting */
  .wiki-layout {
    flex-direction: column;
  }
}
