/* ============================================================
   KinSoft AI — Dashboard Styles
   Shares the same CSS custom properties as styles.css
   ============================================================ */

:root {
  --bg: #ffffff;
  --bg-alt: #f8fafc;
  --surface: #ffffff;
  --surface-muted: #f1f5f9;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-muted: #475569;
  --text-light: #64748b;
  --accent: #1d4ed8;
  --accent-hover: #1e40af;
  --accent-soft: #eff6ff;
  --green-bg: #dcfce7;
  --green-text: #166534;
  --orange-bg: #fff7ed;
  --orange-text: #c2410c;
  --code-bg: #0f172a;
  --code-text: #e2e8f0;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 8px 24px -6px rgba(15, 23, 42, 0.08);
  --radius: 10px;
  --sidebar-width: 220px;
  --header-height: 58px;
}

html[data-theme="dark"] {
  --bg: #090d16;
  --bg-alt: #0e1422;
  --surface: #111827;
  --surface-muted: #1e293b;
  --border: #1f2937;
  --border-strong: #334155;
  --text: #f8fafc;
  --text-muted: #94a3b8;
  --text-light: #64748b;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-soft: rgba(59, 130, 246, 0.14);
  --green-bg: rgba(34, 197, 94, 0.16);
  --green-text: #4ade80;
  --orange-bg: rgba(249, 115, 22, 0.14);
  --orange-text: #fb923c;
  --code-bg: #060912;
  --code-text: #e2e8f0;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 12px 28px -8px rgba(0, 0, 0, 0.45);
}

/* ── Reset & Base ── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 15px;
  scroll-behavior: smooth;
}

body {
  font-family: "Cairo", "Inter", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  direction: rtl;
}

a {
  text-decoration: none;
  color: inherit;
}

button {
  font-family: inherit;
  cursor: pointer;
}

/* ── Layout Shell ── */
.dash-shell {
  display: grid;
  grid-template-rows: var(--header-height) 1fr;
  grid-template-columns: var(--sidebar-width) 1fr;
  grid-template-areas:
    "header header"
    "sidebar main";
  min-height: 100vh;
}

/* ── Header ── */
.dash-header {
  grid-area: header;
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  gap: 16px;
}

.dash-brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
  font-size: 1rem;
  color: var(--text);
  letter-spacing: -0.01em;
}

.dash-brand img {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  object-fit: cover;
}

.brand-sub {
  color: var(--accent);
  font-weight: 600;
}

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

.user-greeting {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-muted);
}

.points-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 700;
  padding: 4px 11px;
  border-radius: 999px;
  border: 1px solid var(--accent);
  opacity: 0.85;
}

.btn-logout {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-muted);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.btn-logout:hover {
  background: var(--surface-muted);
  color: var(--text);
}

.btn-theme {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  transition: background 0.15s, border-color 0.15s;
}

.btn-theme:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

/* ── Sidebar ── */
.dash-sidebar {
  grid-area: sidebar;
  position: sticky;
  top: var(--header-height);
  height: calc(100vh - var(--header-height));
  overflow-y: auto;
  background: var(--bg-alt);
  border-inline-end: 1px solid var(--border);
  padding: 16px 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-light);
  padding: 10px 16px 4px;
  text-transform: uppercase;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-muted);
  border-radius: 0;
  transition: background 0.13s, color 0.13s;
  position: relative;
}

.sidebar-nav-item:hover {
  background: var(--surface-muted);
  color: var(--text);
}

.sidebar-nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.sidebar-nav-item.active::before {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}

.sidebar-icon {
  font-size: 1rem;
  line-height: 1;
}

/* ── Main Content ── */
.dash-main {
  grid-area: main;
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  overflow-y: auto;
}

/* ── Welcome Card ── */
.welcome-card {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
  color: #ffffff;
  border-radius: var(--radius);
  padding: 22px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  box-shadow: var(--shadow-md);
}

.welcome-card h2 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.welcome-card p {
  font-size: 0.88rem;
  opacity: 0.88;
}

.welcome-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.btn-white {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 16px;
  font-size: 0.84rem;
  font-weight: 600;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.4);
  background: rgba(255,255,255,0.18);
  color: #ffffff;
  transition: background 0.15s;
  font-family: inherit;
}

.btn-white:hover {
  background: rgba(255,255,255,0.28);
}

.btn-white-solid {
  background: #ffffff;
  color: var(--accent);
  border-color: transparent;
}

.btn-white-solid:hover {
  background: #f0f4ff;
}

/* ── Section Heading ── */
.section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 2px;
}

.section-sub {
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* ── Studio Cards ── */
.studio-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.studio-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: box-shadow 0.2s, border-color 0.2s;
}

.studio-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
}

.studio-card-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
  font-size: 1.3rem;
}

.studio-card h3 {
  font-size: 0.95rem;
  font-weight: 700;
}

.studio-card p {
  font-size: 0.82rem;
  color: var(--text-muted);
  flex: 1;
}

.studio-card-cost {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 9px;
  border-radius: 999px;
  margin-bottom: 4px;
}

.btn-start {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 16px;
  font-size: 0.84rem;
  font-weight: 600;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: #ffffff;
  transition: background 0.15s;
  font-family: inherit;
  text-decoration: none;
}

.btn-start:hover {
  background: var(--accent-hover);
}

/* ── Points Usage ── */
.points-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.points-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 10px;
}

.points-label {
  font-size: 0.88rem;
  font-weight: 600;
}

.points-count {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.progress-bar-wrap {
  height: 10px;
  background: var(--surface-muted);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 10px;
}

.progress-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.4s ease;
}

.points-hint {
  font-size: 0.78rem;
  color: var(--text-light);
}

.btn-upgrade {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: 7px;
  padding: 5px 12px;
  transition: background 0.15s;
  font-family: inherit;
  text-decoration: none;
}

.btn-upgrade:hover {
  background: var(--accent);
  color: #ffffff;
}

/* ── Recent Files Table ── */
.files-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.files-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  gap: 10px;
}

.files-header h3 {
  font-size: 0.95rem;
  font-weight: 700;
}

.files-empty {
  padding: 40px 20px;
  text-align: center;
}

.files-empty-icon {
  font-size: 2.5rem;
  margin-bottom: 10px;
  opacity: 0.4;
}

.files-empty p {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.files-empty small {
  font-size: 0.78rem;
  color: var(--text-light);
}

.files-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}

.files-table th,
.files-table td {
  padding: 11px 20px;
  text-align: start;
  border-bottom: 1px solid var(--border);
}

.files-table th {
  font-size: 0.75rem;
  color: var(--text-light);
  font-weight: 600;
  background: var(--bg-alt);
}

.files-table tbody tr:last-child td {
  border-bottom: 0;
}

.files-table tbody tr:hover td {
  background: var(--surface-muted);
}

/* ── Quick Stats ── */
.quick-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}

.stat-card-label {
  font-size: 0.75rem;
  color: var(--text-light);
  font-weight: 600;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-card-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
}

.stat-card-sub {
  font-size: 0.76rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── Responsive ── */
@media (max-width: 900px) {
  .dash-shell {
    grid-template-columns: 1fr;
    grid-template-areas:
      "header"
      "main";
  }

  .dash-sidebar {
    display: none;
  }

  .studio-grid,
  .quick-stats {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 600px) {
  .dash-main {
    padding: 16px 14px;
  }

  .studio-grid,
  .quick-stats {
    grid-template-columns: 1fr;
  }

  .welcome-card {
    flex-direction: column;
    align-items: flex-start;
  }
}
