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

/* ===== LIGHT THEME (DEFAULT) ===== */
:root {
  --bg: #f4f2ee;
  --surface: #ffffff;
  --surface2: #f0eeea;
  --surface3: #e8e6e1;
  --accent: #6c5ce7;
  --accent2: #5a4bd1;
  --accent-glow: rgba(108, 92, 231, 0.08);
  --accent-glow2: rgba(108, 92, 231, 0.14);
  --text: #1a1a2e;
  --text-muted: #6e6e82;
  --text-dim: #9e9eb0;
  --border: rgba(0, 0, 0, 0.08);
  --border-hover: rgba(108, 92, 231, 0.3);
  --green: #00a884;
  --green-bg: rgba(0, 168, 132, 0.08);
  --orange: #d4a017;
  --orange-bg: rgba(212, 160, 23, 0.08);
  --red: #d63031;
  --red-bg: rgba(214, 48, 49, 0.08);
  --radius: 14px;
  --radius-sm: 8px;
  --radius-lg: 20px;
  --shadow: 0 1px 3px rgba(0,0,0,0.04), 0 4px 12px rgba(0,0,0,0.03);
  --input-bg: #f8f7f4;
  --nav-bg: rgba(255, 255, 255, 0.85);
  --card-hover-shadow: 0 4px 20px rgba(108, 92, 231, 0.08);
}

/* ===== DARK THEME ===== */
[data-theme="dark"] {
  --bg: #0a0a0f;
  --surface: #12121a;
  --surface2: #1a1a26;
  --surface3: #22222f;
  --accent: #6c5ce7;
  --accent2: #a29bfe;
  --accent-glow: rgba(108, 92, 231, 0.15);
  --accent-glow2: rgba(108, 92, 231, 0.25);
  --text: #e8e8ef;
  --text-muted: #6b6b80;
  --text-dim: #4a4a5e;
  --border: rgba(108, 92, 231, 0.15);
  --border-hover: rgba(108, 92, 231, 0.35);
  --green: #00b894;
  --green-bg: rgba(0, 184, 148, 0.12);
  --orange: #fdcb6e;
  --orange-bg: rgba(253, 203, 110, 0.12);
  --red: #e74c3c;
  --red-bg: rgba(231, 76, 60, 0.12);
  --shadow: none;
  --input-bg: #0a0a0f;
  --nav-bg: rgba(18, 18, 26, 0.85);
  --card-hover-shadow: none;
}

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

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

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

/* ===== LAYOUT ===== */
.page-wrapper { min-height: 100vh; display: flex; flex-direction: column; }
.main-content { flex: 1; padding: 28px 32px; max-width: 1200px; margin: 0 auto; width: 100%; }

/* ===== NAVBAR ===== */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 32px;
  background: var(--nav-bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(20px);
  transition: background 0.3s, border-color 0.3s;
}

.nav-logo {
  font-family: 'Space Mono', monospace;
  font-size: 20px;
  font-weight: 700;
  color: var(--accent2);
  letter-spacing: -1px;
}
.nav-logo span { color: var(--text); }

.nav-links {
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-link {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  transition: all 0.2s;
}
.nav-link:hover { color: var(--text); background: var(--surface2); }
.nav-link.active { color: var(--accent2); background: var(--accent-glow); }

.nav-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  color: white;
}

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

/* ===== THEME TOGGLE ===== */
.theme-toggle {
  width: 44px;
  height: 24px;
  border-radius: 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  cursor: pointer;
  position: relative;
  transition: all 0.3s;
  flex-shrink: 0;
}

.theme-toggle::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  top: 2px;
  left: 2px;
  transition: transform 0.3s;
}

[data-theme="dark"] .theme-toggle::after {
  transform: translateX(20px);
}

.theme-toggle-icon {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  line-height: 1;
  pointer-events: none;
}
.theme-toggle-icon.sun { left: 5px; }
.theme-toggle-icon.moon { right: 6px; }

.theme-toggle-icon.sun { opacity: 1; }
.theme-toggle-icon.moon { opacity: 0.3; }
[data-theme="dark"] .theme-toggle-icon.sun { opacity: 0.3; }
[data-theme="dark"] .theme-toggle-icon.moon { opacity: 1; }

/* ===== LOGIN ===== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  position: relative;
  overflow: hidden;
  transition: background 0.3s;
}

.login-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(108,92,231,0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(108,92,231,0.06) 1px, transparent 1px);
  background-size: 44px 44px;
}

[data-theme="dark"] .login-grid {
  background-image:
    linear-gradient(rgba(108,92,231,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(108,92,231,0.04) 1px, transparent 1px);
}

.login-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.12;
}
[data-theme="dark"] .login-orb { opacity: 0.25; }
.login-orb.o1 { width: 400px; height: 400px; background: #6c5ce7; top: -150px; right: -100px; }
.login-orb.o2 { width: 350px; height: 350px; background: #a29bfe; bottom: -100px; left: -80px; }

.login-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 48px 40px;
  width: 400px;
  text-align: center;
  box-shadow: var(--shadow);
  transition: background 0.3s, border-color 0.3s, box-shadow 0.3s;
}

.login-title {
  font-family: 'Space Mono', monospace;
  font-size: 30px;
  font-weight: 700;
  color: var(--accent2);
  margin-bottom: 4px;
}
.login-title span { color: var(--text); }

.login-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  letter-spacing: 3px;
  text-transform: uppercase;
  margin-bottom: 36px;
}

.login-error {
  background: var(--red-bg);
  color: var(--red);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
}

.login-theme-toggle {
  position: absolute;
  top: 16px;
  left: 16px;
}

/* ===== FORMS ===== */
.form-group { margin-bottom: 14px; text-align: right; }
.form-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  color: var(--text);
  font-family: 'Rubik', sans-serif;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s, background 0.3s;
  direction: rtl;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--accent);
}
.form-input::placeholder, .form-textarea::placeholder {
  color: var(--text-dim);
}
.form-textarea { min-height: 100px; resize: vertical; }
.form-select { cursor: pointer; }
.form-select option { background: var(--surface); }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: 10px;
  font-family: 'Rubik', sans-serif;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #a29bfe);
  color: white;
}
.btn-primary:hover { opacity: 0.9; transform: translateY(-1px); }
.btn-primary:active { transform: scale(0.98); }

.btn-secondary {
  background: var(--accent-glow);
  border: 1px solid var(--border);
  color: var(--accent2);
}
.btn-secondary:hover { background: var(--accent-glow2); }

.btn-danger {
  background: var(--red-bg);
  color: var(--red);
  border: 1px solid rgba(231,76,60,0.2);
}
.btn-danger:hover { background: rgba(231,76,60,0.2); }

.btn-download {
  background: linear-gradient(135deg, var(--accent), #a29bfe);
  color: white;
  padding: 12px 28px;
  font-size: 15px;
  border-radius: var(--radius);
}

.btn-sm { padding: 6px 14px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }

/* ===== CARDS ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  transition: border-color 0.2s, transform 0.15s, background 0.3s, box-shadow 0.3s;
}
.card:hover { border-color: var(--border-hover); }
.card-clickable:hover { transform: translateY(-2px); }

/* ===== STATS ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  transition: background 0.3s, border-color 0.3s, box-shadow 0.3s;
}

.stat-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 8px;
}

.stat-value {
  font-family: 'Space Mono', monospace;
  font-size: 28px;
  font-weight: 700;
  color: var(--accent2);
}

/* ===== APP GRID ===== */
.section-title {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 18px;
}

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

.app-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  transition: all 0.25s;
  display: block;
  color: var(--text);
  box-shadow: var(--shadow);
}
.app-card:hover {
  border-color: var(--accent);
  transform: translateY(-3px);
  color: var(--text);
  box-shadow: var(--card-hover-shadow);
}

.app-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Space Mono', monospace;
  font-size: 20px;
  font-weight: 700;
  color: white;
  margin-bottom: 14px;
}

.app-name {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 6px;
}

.app-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 14px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.app-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.app-version {
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  color: var(--text-dim);
}

.tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.5px;
}
.tag-stable { background: var(--green-bg); color: var(--green); }
.tag-beta { background: var(--orange-bg); color: var(--orange); }
.tag-dev { background: var(--red-bg); color: var(--red); }

/* ===== APP DETAIL ===== */
.app-detail-header {
  display: flex;
  gap: 24px;
  align-items: flex-start;
  margin-bottom: 32px;
}

.app-detail-icon {
  width: 80px;
  height: 80px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Space Mono', monospace;
  font-size: 32px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.app-detail-info { flex: 1; }

.app-detail-name {
  font-size: 26px;
  font-weight: 700;
  margin-bottom: 6px;
}

.app-detail-category {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.app-detail-stats {
  display: flex;
  gap: 20px;
  margin-bottom: 16px;
}

.app-detail-stat {
  font-size: 13px;
  color: var(--text-muted);
}
.app-detail-stat strong {
  color: var(--text);
  font-weight: 600;
}

.app-detail-actions { display: flex; gap: 10px; }

.app-screenshots {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 28px;
}

.app-screenshot {
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}
.app-screenshot img {
  width: 100%;
  height: 180px;
  object-fit: cover;
}

.app-long-desc {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  font-size: 14px;
  line-height: 1.8;
  color: var(--text-muted);
  white-space: pre-wrap;
  box-shadow: var(--shadow);
  transition: background 0.3s, border-color 0.3s;
}

/* ===== TABLES ===== */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  transition: border-color 0.3s, box-shadow 0.3s;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th {
  background: var(--surface2);
  padding: 12px 16px;
  text-align: right;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  transition: background 0.3s;
}

td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  background: var(--surface);
  transition: background 0.3s;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--accent-glow); }

/* ===== PROFILE ===== */
.profile-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
  transition: background 0.3s, border-color 0.3s, box-shadow 0.3s;
}

.profile-header {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 24px;
}

.profile-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #a29bfe);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 700;
  color: white;
}

.profile-name { font-size: 20px; font-weight: 600; }
.profile-role {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ===== ADMIN ===== */
.admin-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
}

.admin-tab {
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  transition: all 0.2s;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  font-family: 'Rubik', sans-serif;
}
.admin-tab:hover { color: var(--text); }
.admin-tab.active { color: var(--accent2); border-bottom-color: var(--accent2); }

.admin-section { display: none; }
.admin-section.active { display: block; }

/* ===== ALERTS ===== */
.alert {
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
}
.alert-success { background: var(--green-bg); color: var(--green); }
.alert-error { background: var(--red-bg); color: var(--red); }

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-dim);
}
.empty-state-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.3;
}
.empty-state-text { font-size: 15px; }

/* ===== FILE INFO ===== */
.file-info {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-muted);
  transition: background 0.3s;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .main-content { padding: 16px; }
  .navbar { padding: 12px 16px; }
  .apps-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .app-detail-header { flex-direction: column; }
  .login-card { width: 90%; padding: 32px 24px; }
}
