/* ==========================================================================
   CardStudio — Comprehensive Design System
   ========================================================================== */

:root {
  /* Color Palette - Vibrant Indigo & Slate */
  --cs-primary: #2563eb;
  --cs-primary-hover: #1d4ed8;
  --cs-primary-light: #dbeafe;
  --cs-primary-dark: #1e40af;
  
  --cs-secondary: #4f46e5;
  --cs-secondary-hover: #4338ca;
  
  --cs-success: #10b981;
  --cs-success-light: #d1fae5;
  --cs-warning: #f59e0b;
  --cs-warning-light: #fef3c7;
  --cs-danger: #ef4444;
  --cs-danger-light: #fee2e2;
  --cs-info: #0284c7;
  --cs-info-light: #e0f2fe;

  /* Neutrals (Light Theme) */
  --cs-bg: #f8fafc;
  --cs-surface: #ffffff;
  --cs-surface-alt: #f1f5f9;
  --cs-border: #e2e8f0;
  --cs-border-strong: #cbd5e1;
  --cs-text: #0f172a;
  --cs-text-muted: #64748b;
  --cs-text-inverse: #ffffff;

  /* Typography */
  --cs-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --cs-font-display: "Cinzel", Georgia, serif;
  --cs-font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  /* Radii */
  --cs-radius-sm: 4px;
  --cs-radius-md: 8px;
  --cs-radius-lg: 12px;
  --cs-radius-xl: 16px;
  --cs-radius-full: 9999px;

  /* Shadows */
  --cs-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --cs-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
  --cs-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
  --cs-shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);

  /* Transitions */
  --cs-transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --cs-transition: 250ms cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
  --cs-bg: #0b0f19;
  --cs-surface: #111827;
  --cs-surface-alt: #1f2937;
  --cs-border: #2d3748;
  --cs-border-strong: #4a5568;
  --cs-text: #f8fafc;
  --cs-text-muted: #94a3b8;
  --cs-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
  --cs-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
}

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

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

body {
  font-family: var(--cs-font);
  background-color: var(--cs-bg);
  color: var(--cs-text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--cs-primary);
  text-decoration: none;
  transition: color var(--cs-transition-fast);
}
a:hover {
  color: var(--cs-primary-hover);
}

img, svg {
  vertical-align: middle;
  max-width: 100%;
}

/* Layout Utilities */
.container {
  width: 100%;
  max-width: 1240px;
  margin-left: auto;
  margin-right: auto;
  padding-left: 1.5rem;
  padding-right: 1.5rem;
}

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.justify-end { justify-content: flex-end; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1 1 0%; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }
.gap-8 { gap: 2rem; }

.grid { display: grid; }
.grid-cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
.grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

@media (max-width: 1024px) {
  .grid-cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .grid-cols-4, .grid-cols-3, .grid-cols-2 { grid-template-columns: 1fr; }
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  color: var(--cs-text);
  font-weight: 700;
  line-height: 1.25;
}
h1 { font-size: 2.25rem; }
h2 { font-size: 1.75rem; }
h3 { font-size: 1.35rem; }
h4 { font-size: 1.15rem; }
p { margin-bottom: 0.75rem; }
p:last-child { margin-bottom: 0; }
.text-muted { color: var(--cs-text-muted); }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-lg { font-size: 1.125rem; }
.text-xl { font-size: 1.25rem; }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.text-center { text-align: center; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1.25rem;
  font-size: 0.9375rem;
  font-weight: 600;
  border-radius: var(--cs-radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--cs-transition-fast);
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-primary {
  background-color: var(--cs-primary);
  color: #ffffff;
}
.btn-primary:hover {
  background-color: var(--cs-primary-hover);
  color: #ffffff;
}

.btn-secondary {
  background-color: var(--cs-surface-alt);
  color: var(--cs-text);
  border-color: var(--cs-border);
}
.btn-secondary:hover {
  background-color: var(--cs-border);
  color: var(--cs-text);
}

.btn-outline {
  background-color: transparent;
  border-color: var(--cs-border-strong);
  color: var(--cs-text);
}
.btn-outline:hover {
  background-color: var(--cs-surface-alt);
}

.btn-danger {
  background-color: var(--cs-danger);
  color: #ffffff;
}
.btn-danger:hover { background-color: #dc2626; color: #ffffff; }

.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8125rem; }
.btn-lg { padding: 0.85rem 1.75rem; font-size: 1.05rem; }
.btn-icon { padding: 0.5rem; border-radius: var(--cs-radius-md); }

/* Forms & Inputs */
.form-group {
  margin-bottom: 1.25rem;
}
.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
  color: var(--cs-text);
}
.form-control, .form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 0.65rem 0.85rem;
  font-size: 0.9375rem;
  color: var(--cs-text);
  background-color: var(--cs-surface);
  border: 1px solid var(--cs-border-strong);
  border-radius: var(--cs-radius-md);
  transition: border-color var(--cs-transition-fast), box-shadow var(--cs-transition-fast);
}
.form-control:focus, .form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--cs-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
.form-help {
  font-size: 0.75rem;
  color: var(--cs-text-muted);
  margin-top: 0.25rem;
}

/* Cards & Containers */
.card {
  background-color: var(--cs-surface);
  border: 1px solid var(--cs-border);
  border-radius: var(--cs-radius-lg);
  box-shadow: var(--cs-shadow-sm);
  overflow: hidden;
  transition: transform var(--cs-transition), box-shadow var(--cs-transition);
}
.card-hover:hover {
  transform: translateY(-3px);
  box-shadow: var(--cs-shadow-lg);
}
.card-body {
  padding: 1.5rem;
}
.card-header {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--cs-border);
  background-color: var(--cs-surface-alt);
  font-weight: 600;
}
.card-footer {
  padding: 0.85rem 1.5rem;
  border-top: 1px solid var(--cs-border);
  background-color: var(--cs-surface-alt);
}

/* Navbar */
.navbar {
  background-color: var(--cs-surface);
  border-bottom: 1px solid var(--cs-border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(8px);
}
.navbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 4.25rem;
}
.navbar-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--cs-text);
  letter-spacing: -0.02em;
}
.navbar-brand svg {
  color: var(--cs-primary);
}
.navbar-brand:hover { color: var(--cs-text); }
.nav-links {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  list-style: none;
}
.nav-link {
  color: var(--cs-text-muted);
  font-weight: 500;
  font-size: 0.9375rem;
  transition: color var(--cs-transition-fast);
}
.nav-link:hover, .nav-link.active {
  color: var(--cs-primary);
}

/* Badge */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: var(--cs-radius-full);
}
.badge-primary { background-color: var(--cs-primary-light); color: var(--cs-primary-dark); }
.badge-success { background-color: var(--cs-success-light); color: #065f46; }
.badge-warning { background-color: var(--cs-warning-light); color: #92400e; }
.badge-danger { background-color: var(--cs-danger-light); color: #991b1b; }

/* Alerts & Flash Messages */
.alert {
  padding: 1rem 1.25rem;
  border-radius: var(--cs-radius-md);
  margin-bottom: 1.25rem;
  font-size: 0.9375rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.alert-success { background-color: var(--cs-success-light); color: #065f46; border: 1px solid #a7f3d0; }
.alert-error, .alert-danger { background-color: var(--cs-danger-light); color: #991b1b; border: 1px solid #fecaca; }
.alert-info { background-color: var(--cs-info-light); color: #075985; border: 1px solid #bae6fd; }

/* Template Preview Card in Gallery */
.template-card {
  display: flex;
  flex-direction: column;
  background-color: var(--cs-surface);
  border: 1px solid var(--cs-border);
  border-radius: var(--cs-radius-lg);
  overflow: hidden;
  transition: all var(--cs-transition);
}
.template-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--cs-shadow-lg);
  border-color: var(--cs-primary);
}
.template-card-preview {
  position: relative;
  background-color: var(--cs-surface-alt);
  padding: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 180px;
  overflow: hidden;
}
.template-card-content {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  flex: 1;
}

/* Footer */
.footer {
  margin-top: auto;
  background-color: var(--cs-surface);
  border-top: 1px solid var(--cs-border);
  padding: 3rem 0 2rem;
  font-size: 0.875rem;
  color: var(--cs-text-muted);
}

/* Dashboard Sidebar Layout */
.dashboard-wrapper {
  display: flex;
  min-height: calc(100vh - 4.25rem);
}
.dashboard-sidebar {
  width: 260px;
  background-color: var(--cs-surface);
  border-right: 1px solid var(--cs-border);
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 1rem;
  border-radius: var(--cs-radius-md);
  color: var(--cs-text-muted);
  font-weight: 500;
  transition: all var(--cs-transition-fast);
}
.sidebar-link:hover, .sidebar-link.active {
  background-color: var(--cs-surface-alt);
  color: var(--cs-primary);
}
.dashboard-content {
  flex: 1;
  padding: 2rem;
  background-color: var(--cs-bg);
}

/* RTL Support (Arabic) */
[dir="rtl"] {
  text-align: right;
}
[dir="rtl"] .dashboard-sidebar {
  border-right: none;
  border-left: 1px solid var(--cs-border);
}
