/**
 * Shadowlytics Theme - CSS Variables & Base Styles
 * For use with Django projects
 */

/* ============================================
   CSS VARIABLES
   ============================================ */

:root {
  /* Primary Colors */
  --primary: #e1a65d;
  --primary-hover: #d4973e;
  --primary-foreground: #141414;

  /* Background Colors */
  --background: #141414;
  --background-secondary: #1a1a1a;
  --foreground: #fafafa;

  /* Card Colors */
  --card: #141414;
  --card-foreground: #fafafa;

  /* Muted Colors */
  --muted: #2a2a2a;
  --muted-foreground: #a3a3a3;

  /* Secondary Colors */
  --secondary: #2a2a2a;
  --secondary-hover: #333333;
  --secondary-foreground: #fafafa;

  /* Sidebar Colors */
  --sidebar: #141414;
  --sidebar-foreground: #fafafa;
  --sidebar-border: #2a2a2a;
  --sidebar-accent: #2a2a2a;

  /* Border Colors */
  --border: #4a4a4a;
  --border-light: #333333;
  --input: #2a2a2a;
  --ring: #e1a65d;

  /* Semantic Colors */
  --destructive: #ef4444;
  --destructive-hover: #dc2626;
  --destructive-foreground: #fafafa;
  --success: #22c55e;
  --warning: #f59e0b;
  --info: #22d3ee;

  /* Chart Colors */
  --chart-1: #e1a65d;
  --chart-2: #22d3ee;
  --chart-3: #f59e0b;
  --chart-4: #a855f7;
  --chart-5: #ef4444;

  /* Typography */
  --font-sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, 'SF Mono', 'Roboto Mono', Menlo, Monaco, monospace;

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

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.5);

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition: 200ms ease;
  --transition-slow: 300ms ease;
}

/* ============================================
   BASE STYLES
   ============================================ */

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background-color: var(--background);
  color: var(--foreground);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.5;
  min-height: 100vh;
}

/* ============================================
   TYPOGRAPHY
   ============================================ */

h1, h2, h3, h4, h5, h6 {
  color: var(--foreground);
  font-weight: 700;
  line-height: 1.2;
}

h1 {
  font-size: 2.25rem;  /* 36px */
  letter-spacing: -0.025em;
}

h2 {
  font-size: 1.875rem; /* 30px */
  letter-spacing: -0.02em;
}

h3 {
  font-size: 1.5rem;   /* 24px */
  font-weight: 600;
  letter-spacing: -0.015em;
}

h4 {
  font-size: 1.25rem;  /* 20px */
  font-weight: 600;
}

h5 {
  font-size: 1rem;     /* 16px */
  font-weight: 500;
}

h6 {
  font-size: 0.875rem; /* 14px */
  font-weight: 500;
}

p {
  color: var(--muted-foreground);
  line-height: 1.625;
}

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

a:hover {
  color: var(--primary-hover);
}

small {
  font-size: 0.875rem;
  color: var(--muted-foreground);
}

code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background-color: var(--muted);
  padding: 0.125rem 0.375rem;
  border-radius: var(--radius-sm);
}

/* ============================================
   LAYOUT
   ============================================ */

.app-layout {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.app-content {
  display: flex;
  flex: 1;
}

.main-content {
  flex: 1;
  padding: 1.5rem;
  overflow-y: auto;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* Page Header */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.5rem;
  gap: 1rem;
}

.page-header-content {
  flex: 1;
}

.page-title {
  font-size: 1.875rem;
  font-weight: 700;
  color: var(--foreground);
  margin-bottom: 0.25rem;
}

.page-description {
  font-size: 1rem;
  color: var(--muted-foreground);
}

.page-actions {
  display: flex;
  gap: 0.5rem;
}

/* ============================================
   HEADER / NAVBAR
   ============================================ */

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1.5rem;
  background-color: var(--background);
  border-bottom: 1px solid var(--sidebar-border);
  position: sticky;
  top: 0;
  z-index: 50;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--primary);
  font-size: 1.25rem;
  font-weight: 600;
  text-decoration: none;
}

.logo:hover {
  color: var(--primary);
}

.logo-icon {
  width: 32px;
  height: 32px;
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-email {
  font-size: 0.875rem;
  color: var(--foreground);
}

/* ============================================
   SIDEBAR
   ============================================ */

.sidebar {
  width: 280px;
  background-color: var(--sidebar);
  border-right: 1px solid var(--sidebar-border);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  color: var(--muted-foreground);
  font-size: 0.875rem;
  text-decoration: none;
  transition: all var(--transition-fast);
}

.sidebar-nav-item:hover {
  background-color: var(--sidebar-accent);
  color: var(--foreground);
}

.sidebar-nav-item.active {
  background-color: rgba(225, 166, 93, 0.1);
  color: var(--primary);
}

.sidebar-nav-item svg,
.sidebar-nav-item .icon {
  width: 1.25rem;
  height: 1.25rem;
  flex-shrink: 0;
}

.sidebar-section {
  margin-top: 0.5rem;
}

.sidebar-section-title {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted-foreground);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.5rem 0.75rem;
}

.sidebar-sub-item {
  padding-left: 2.5rem;
}

/* ============================================
   BUTTONS
   ============================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.25rem;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn svg,
.btn .icon {
  width: 1rem;
  height: 1rem;
}

/* Primary Button */
.btn-primary {
  background-color: var(--primary);
  color: var(--primary-foreground);
}

.btn-primary:hover:not(:disabled) {
  background-color: var(--primary-hover);
}

/* Secondary Button */
.btn-secondary {
  background-color: var(--secondary);
  color: var(--secondary-foreground);
  border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background-color: var(--secondary-hover);
}

/* Outline Button */
.btn-outline {
  background-color: transparent;
  color: var(--foreground);
  border: 1px solid var(--border);
}

.btn-outline:hover:not(:disabled) {
  background-color: var(--secondary);
}

/* Ghost Button */
.btn-ghost {
  background-color: transparent;
  color: var(--foreground);
}

.btn-ghost:hover:not(:disabled) {
  background-color: var(--secondary);
}

/* Destructive Button */
.btn-destructive {
  background-color: transparent;
  color: var(--destructive);
  border: 1px solid var(--border);
}

.btn-destructive:hover:not(:disabled) {
  background-color: rgba(239, 68, 68, 0.1);
  border-color: var(--destructive);
}

/* Button Sizes */
.btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.75rem;
}

.btn-lg {
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
}

.btn-icon {
  padding: 0.5rem;
}

/* ============================================
   CARDS
   ============================================ */

.card {
  background-color: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
}

.card-header {
  margin-bottom: 1rem;
}

.card-title {
  font-size: 1rem;
  font-weight: 500;
  color: var(--card-foreground);
  margin-bottom: 0.25rem;
}

.card-description {
  font-size: 0.875rem;
  color: var(--muted-foreground);
}

.card-content {
  /* Content styles */
}

.card-footer {
  margin-top: 1rem;
  display: flex;
  gap: 0.5rem;
}

/* Selection Card */
.selection-card {
  background-color: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  cursor: pointer;
  transition: border-color var(--transition-fast);
}

.selection-card:hover:not(.disabled) {
  border-color: var(--primary);
}

.selection-card.active {
  border-color: var(--primary);
}

.selection-card.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Stats Card */
.stats-card {
  background-color: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
}

.stats-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.stats-card-title {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--muted-foreground);
}

.stats-card-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--foreground);
}

.stats-card-description {
  font-size: 0.875rem;
  color: var(--muted-foreground);
}

/* Card Grid */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
}

.card-grid-2 {
  grid-template-columns: repeat(2, 1fr);
}

.card-grid-3 {
  grid-template-columns: repeat(3, 1fr);
}

/* ============================================
   FORMS
   ============================================ */

.form-group {
  margin-bottom: 1rem;
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--foreground);
  margin-bottom: 0.375rem;
}

.form-input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  line-height: 1.25rem;
  color: var(--foreground);
  background-color: var(--input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: all var(--transition-fast);
}

.form-input::placeholder {
  color: var(--muted-foreground);
}

.form-input:focus {
  outline: none;
  border-color: var(--ring);
  box-shadow: 0 0 0 2px rgba(225, 166, 93, 0.2);
}

.form-input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.form-hint {
  font-size: 0.75rem;
  color: var(--muted-foreground);
  margin-top: 0.25rem;
}

.form-error {
  font-size: 0.75rem;
  color: var(--destructive);
  margin-top: 0.25rem;
}

/* Textarea */
.form-textarea {
  min-height: 100px;
  resize: vertical;
}

/* Select */
.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23a3a3a3' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.5rem;
}

/* Checkbox */
.form-checkbox {
  width: 1rem;
  height: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background-color: var(--input);
  cursor: pointer;
  accent-color: var(--primary);
}

/* File Input */
.form-file {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.form-file-button {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--foreground);
  background-color: var(--secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
}

/* ============================================
   DROPDOWN MENU
   ============================================ */

.dropdown {
  position: relative;
}

.dropdown-trigger {
  cursor: pointer;
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  min-width: 200px;
  background-color: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.25rem;
  box-shadow: var(--shadow-lg);
  z-index: 50;
  display: none;
}

.dropdown-menu.open {
  display: block;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  color: var(--foreground);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background-color var(--transition-fast);
}

.dropdown-item:hover {
  background-color: var(--muted);
}

.dropdown-item svg,
.dropdown-item .icon {
  width: 1rem;
  height: 1rem;
  color: var(--muted-foreground);
}

.dropdown-separator {
  height: 1px;
  background-color: var(--border);
  margin: 0.25rem 0;
}

/* ============================================
   MODAL
   ============================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal {
  background-color: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  max-width: 500px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem 1.5rem 0;
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  color: var(--muted-foreground);
  cursor: pointer;
  padding: 0.25rem;
}

.modal-close:hover {
  color: var(--foreground);
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 0 1.5rem 1.5rem;
}

/* ============================================
   ALERTS
   ============================================ */

.alert {
  padding: 1rem;
  border-radius: var(--radius-md);
  border: 1px solid;
}

.alert-title {
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.25rem;
}

.alert-description {
  font-size: 0.875rem;
}

/* Info Alert */
.alert-info {
  background-color: rgba(34, 211, 238, 0.1);
  border-color: rgba(34, 211, 238, 0.3);
}

.alert-info .alert-title {
  color: var(--info);
}

/* Success Alert */
.alert-success {
  background-color: rgba(34, 197, 94, 0.1);
  border-color: rgba(34, 197, 94, 0.3);
}

.alert-success .alert-title {
  color: var(--success);
}

/* Warning Alert */
.alert-warning {
  background-color: rgba(245, 158, 11, 0.1);
  border-color: rgba(245, 158, 11, 0.3);
}

.alert-warning .alert-title {
  color: var(--warning);
}

/* Destructive/Error Alert */
.alert-destructive {
  background-color: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.3);
}

.alert-destructive .alert-title {
  color: var(--destructive);
}

/* ============================================
   AVATAR
   ============================================ */

.avatar {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--radius-full);
  border: 2px solid var(--primary);
  overflow: hidden;
  flex-shrink: 0;
}

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

.avatar-sm {
  width: 2rem;
  height: 2rem;
}

.avatar-lg {
  width: 3rem;
  height: 3rem;
}

/* ============================================
   BADGES
   ============================================ */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: var(--radius-full);
  background-color: var(--muted);
  color: var(--muted-foreground);
}

.badge-primary {
  background-color: rgba(225, 166, 93, 0.2);
  color: var(--primary);
}

.badge-success {
  background-color: rgba(34, 197, 94, 0.2);
  color: var(--success);
}

.badge-warning {
  background-color: rgba(245, 158, 11, 0.2);
  color: var(--warning);
}

.badge-destructive {
  background-color: rgba(239, 68, 68, 0.2);
  color: var(--destructive);
}

/* ============================================
   EMPTY STATE
   ============================================ */

.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
}

.empty-state-icon {
  width: 3rem;
  height: 3rem;
  margin: 0 auto 1rem;
  color: var(--muted-foreground);
}

.empty-state-title {
  font-size: 1rem;
  font-weight: 500;
  color: var(--foreground);
  margin-bottom: 0.5rem;
}

.empty-state-description {
  font-size: 0.875rem;
  color: var(--muted-foreground);
  margin-bottom: 1.5rem;
}

/* ============================================
   TABLES
   ============================================ */

.table-container {
  overflow-x: auto;
}

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

.table th {
  text-align: left;
  font-weight: 500;
  color: var(--muted-foreground);
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}

.table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--foreground);
}

.table tbody tr:hover {
  background-color: var(--muted);
}

/* ============================================
   UTILITIES
   ============================================ */

/* Text Colors */
.text-primary { color: var(--primary); }
.text-muted { color: var(--muted-foreground); }
.text-destructive { color: var(--destructive); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }

/* Background Colors */
.bg-primary { background-color: var(--primary); }
.bg-muted { background-color: var(--muted); }
.bg-card { background-color: var(--card); }

/* Flex Utilities */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }

/* Spacing */
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.p-4 { padding: 1rem; }
.p-6 { padding: 1.5rem; }

/* Width */
.w-full { width: 100%; }

/* Visibility */
.hidden { display: none; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

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

@media (max-width: 768px) {
  .sidebar {
    display: none;
  }

  .card-grid {
    grid-template-columns: 1fr;
  }

  .card-grid-2,
  .card-grid-3 {
    grid-template-columns: 1fr;
  }

  .page-header {
    flex-direction: column;
  }
}
