/* ========= DrawSortAI – Modern UI with Cyan Theme ========= */
:root {
  /* Dark theme (default) */
  --bg: #0f172a;
  --bg-secondary: #1e293b;
  --panel: #1e293b;
  --panel-light: #334155;
  --text: #f1f5f9;
  --text-dim: #94a3b8;
  --text-muted: #64748b;
  
  /* Brand colors from logo */
  --brand: #06b6d4;
  --brand-light: #22d3ee;
  --brand-lighter: #67e8f9;
  --brand-dark: #0891b2;
  
  /* Status colors */
  --success: #10b981;
  --warning: #f59e0b;
  --error: #ef4444;
  --info: #3b82f6;
  
  /* UI elements */
  --border: #334155;
  --border-light: #475569;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.4);
  --radius: 12px;
  --radius-lg: 16px;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f8fafc;
    --bg-secondary: #f1f5f9;
    --panel: #ffffff;
    --panel-light: #f8fafc;
    --text: #0f172a;
    --text-dim: #475569;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --border-light: #cbd5e1;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.12);
  }
}

/* ========= Reset & Base ========= */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 
               'Helvetica Neue', Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  background-image: 
    radial-gradient(at 0% 0%, rgba(6, 182, 212, 0.1) 0px, transparent 50%),
    radial-gradient(at 100% 0%, rgba(34, 211, 238, 0.08) 0px, transparent 50%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ========= Layout ========= */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ========= Header & Navigation ========= */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  max-width: 1200px;
  margin: 0 auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  font-size: 1.25rem;
  transition: opacity 0.2s;
}

.brand:hover {
  opacity: 0.8;
}

.brand-logo {
  width: 40px;
  height: 40px;
}

.brand-text {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.brand-draw {
  color: var(--brand);
  font-weight: 800;
}

.brand-sort {
  color: var(--text-dim);
  font-weight: 800;
}

.brand-ai {
  color: var(--brand-light);
  font-size: 0.85em;
  font-weight: 600;
  margin-left: -2px;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 8px;
  list-style: none;
}

.nav-links a {
  color: var(--text);  /* Changed from var(--text-dim) */
  text-decoration: none;
  padding: 10px 16px;
  border-radius: 8px;
  font-weight: 500;
  transition: all 0.2s;
}

.nav-links a:hover {
  color: var(--brand);  /* Changed to cyan on hover */
  background: var(--panel);
}

.nav-links a.active {
  color: var(--brand);
  background: rgba(6, 182, 212, 0.1);
}

/* ========= Cards & Panels ========= */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow);
  margin-bottom: 24px;
}

.card-compact {
  padding: 20px;
}

.card-header {
  margin-bottom: 24px;
}

.card-title {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}

.card-subtitle {
  color: var(--text-dim);
  font-size: 1rem;
}

/* ========= Typography ========= */
h1, h2, h3, h4, h5, h6 {
  margin: 0 0 16px 0;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text);
}

h1 {
  font-size: 2.5rem;
}

h2 {
  font-size: 2rem;
}

h3 {
  font-size: 1.5rem;
}

p {
  margin: 0 0 16px 0;
}

.text-muted {
  color: var(--text-dim);
}

.text-brand {
  color: var(--brand);
}

/* ========= Buttons ========= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  font-size: 1rem;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel-light);
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn:active:not(:disabled) {
  transform: translateY(0);
}

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

.btn-primary {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
  border-color: var(--brand);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--brand-light) 0%, var(--brand) 100%);
  box-shadow: 0 4px 20px rgba(6, 182, 212, 0.4);
}

.btn-success {
  background: var(--success);
  border-color: var(--success);
  color: white;
}

.btn-warning {
  background: var(--warning);
  border-color: var(--warning);
  color: white;
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
}

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

.btn-lg {
  padding: 16px 32px;
  font-size: 1.125rem;
}

.btn-sm {
  padding: 8px 16px;
  font-size: 0.875rem;
}

/* ========= Forms ========= */
.form-group {
  margin-bottom: 24px;
}

label {
  display: block;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
  font-size: 0.95rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
select,
textarea {
  width: 100%;
  padding: 12px 16px;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-secondary);
  color: var(--text);
  transition: all 0.2s;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.1);
}

/* ========= Dropzone ========= */
.dropzone {
  position: relative;
  padding: 48px 32px;
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  text-align: center;
  cursor: pointer;
  background: var(--panel);
  transition: all 0.3s ease;
}

.dropzone:hover {
  border-color: var(--brand);
  background: rgba(6, 182, 212, 0.03);
  transform: translateY(-2px);
}

.dropzone.is-hovered {
  border-color: var(--brand);
  background: rgba(6, 182, 212, 0.08);
  border-style: solid;
}

.dropzone-icon {
  font-size: 4rem;
  margin-bottom: 16px;
  opacity: 0.8;
}

.dropzone-text {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}

.dropzone-subtext {
  color: var(--text-dim);
  font-size: 0.95rem;
}

.dropzone-limit {
  margin-top: 16px;
  padding: 8px 16px;
  background: var(--bg-secondary);
  border-radius: 8px;
  color: var(--text-dim);
  font-size: 0.875rem;
  display: inline-block;
}

/* ========= Flash Messages ========= */
.flash-wrap {
  max-width: 1200px;
  margin: 24px auto;
  padding: 0 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.flash {
  padding: 16px 20px;
  border-radius: var(--radius);
  border-left: 4px solid;
  display: flex;
  align-items: center;
  gap: 12px;
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.flash-success {
  background: rgba(16, 185, 129, 0.1);
  border-color: var(--success);
  color: var(--success);
}

.flash-warning {
  background: rgba(245, 158, 11, 0.1);
  border-color: var(--warning);
  color: var(--warning);
}

.flash-danger {
  background: rgba(239, 68, 68, 0.1);
  border-color: var(--error);
  color: var(--error);
}

.flash-info {
  background: rgba(6, 182, 212, 0.1);
  border-color: var(--brand);
  color: var(--brand);
}

/* ========= Progress ========= */
.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--bg-secondary);
  border-radius: 4px;
  overflow: hidden;
  margin: 16px 0;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--brand) 0%, var(--brand-light) 100%);
  transition: width 0.3s ease;
  border-radius: 4px;
}

/* ========= Stats Grid ========= */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin: 24px 0;
}

.stat-card {
  background: var(--panel-light);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
}

.stat-value {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--brand);
  line-height: 1;
  margin-bottom: 8px;
}

.stat-label {
  color: var(--text-dim);
  font-size: 0.9rem;
  font-weight: 500;
}

/* ========= Tables ========= */
.table-container {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
}

th {
  background: var(--panel-light);
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  color: var(--text);
  border-bottom: 2px solid var(--border);
}

td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

tr:last-child td {
  border-bottom: none;
}

tr:hover {
  background: var(--panel-light);
}

/* ========= Footer ========= */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 32px 24px;
  margin-top: 64px;
  color: var(--text-dim);
  text-align: center;
}

.site-footer ul {
  list-style: none;
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-top: 16px;
}

.site-footer a {
  color: var(--text-dim);
  text-decoration: none;
  transition: color 0.2s;
}

.site-footer a:hover {
  color: var(--brand);
}

/* ========= Utilities ========= */
.hidden {
  display: none !important;
}

.text-center {
  text-align: center;
}

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.mb-4 { margin-bottom: 32px; }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mt-4 { margin-top: 32px; }

.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.items-center {
  align-items: center;
}

.justify-center {
  justify-content: center;
}

.justify-between {
  justify-content: space-between;
}

.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.gap-3 { gap: 24px; }

/* ========= Responsive ========= */
@media (max-width: 768px) {
  .nav {
    flex-direction: column;
    gap: 16px;
  }
  
  .nav-links {
    flex-wrap: wrap;
    justify-content: center;
  }
  
  .card {
    padding: 20px;
  }
  
  h1 {
    font-size: 2rem;
  }
  
  h2 {
    font-size: 1.5rem;
  }
  
  .stats-grid {
    grid-template-columns: 1fr;
  }
}