/* ===== CSS Variables ===== */
:root {
  --primary-color: #6366f1;
  --primary-dark: #4f46e5;
  --primary-light: #818cf8;
  --secondary-color: #8b5cf6;
  --success-color: #10b981;
  --warning-color: #f59e0b;
  --danger-color: #ef4444;
  --dark-bg: #0f172a;
  --dark-surface: #1e293b;
  --dark-surface-light: #334155;
  --light-bg: #f8fafc;
  --light-surface: #ffffff;
  --light-surface-hover: #f1f5f9;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --text-inverse: #f8fafc;
  --border-color: #e2e8f0;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --border-radius: 12px;
  --border-radius-sm: 8px;
  --border-radius-lg: 16px;
}

[data-theme="dark"] {
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --border-color: #334155;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.25);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.3), 0 2px 4px -2px rgb(0 0 0 / 0.3);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.4), 0 4px 6px -4px rgb(0 0 0 / 0.4);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.5), 0 8px 10px -6px rgb(0 0 0 / 0.5);
}

/* ===== Base Styles ===== */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: linear-gradient(135deg, var(--light-bg) 0%, #e0e7ff 100%);
  color: var(--text-primary);
  line-height: 1.6;
  transition: var(--transition);
}

[data-theme="dark"] body {
  background: linear-gradient(135deg, var(--dark-bg) 0%, #1a1f3a 100%);
}

/* ===== Layout ===== */
.container {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ===== Sidebar ===== */
nav {
  width: 280px;
  background: linear-gradient(180deg, var(--primary-color) 0%, var(--secondary-color) 100%);
  color: var(--text-inverse);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-xl);
  position: relative;
  z-index: 10;
}

nav::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="grid" width="10" height="10" patternUnits="userSpaceOnUse"><path d="M 10 0 L 0 0 0 10" fill="none" stroke="rgba(255,255,255,0.05)" stroke-width="1"/></pattern></defs><rect width="100" height="100" fill="url(%23grid)"/></svg>');
  pointer-events: none;
}

nav .nav-header {
  padding: 2rem 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  position: relative;
}

nav .nav-header h2 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

nav .nav-header .logo {
  width: 40px;
  height: 40px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: var(--border-radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 1.2rem;
}

nav .nav-items {
  flex: 1;
  padding: 1.5rem 0;
  position: relative;
}

nav a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  color: rgba(255, 255, 255, 0.8);
  text-decoration: none;
  transition: var(--transition);
  position: relative;
  font-weight: 500;
}

nav a::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--text-inverse);
  transform: scaleY(0);
  transition: var(--transition);
}

nav a:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-inverse);
}

nav a.active {
  background: rgba(255, 255, 255, 0.15);
  color: var(--text-inverse);
}

nav a.active::before {
  transform: scaleY(1);
}

nav .nav-icon {
  width: 20px;
  height: 20px;
  opacity: 0.8;
}

/* ===== Main Content ===== */
main {
  flex: 1;
  padding: 2rem;
  overflow-y: auto;
  background: transparent;
}

/* ===== Header ===== */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  background: var(--light-surface);
  padding: 1.5rem 2rem;
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(10px);
}

[data-theme="dark"] .header {
  background: var(--dark-surface);
}

h1 {
  margin: 0;
  font-size: 2rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* ===== Buttons ===== */
.btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: var(--border-radius);
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  text-decoration: none;
  position: relative;
  overflow: hidden;
}

.btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: var(--transition);
}

.btn:hover::before {
  left: 100%;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
  color: white;
  box-shadow: var(--shadow-md);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.btn-danger {
  background: linear-gradient(135deg, var(--danger-color), #dc2626);
  color: white;
}

.btn-danger:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.btn-success {
  background: linear-gradient(135deg, var(--success-color), #059669);
  color: white;
}

.btn-success:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 2px solid var(--border-color);
}

.btn-ghost:hover {
  background: var(--light-surface-hover);
  border-color: var(--primary-color);
  color: var(--primary-color);
}

.btn-icon {
  padding: 0.75rem;
  border-radius: 50%;
}

.logout-btn {
  @extend .btn, .btn-danger;
}

/* ===== Sections ===== */
section {
  background: var(--light-surface);
  padding: 2rem;
  margin-bottom: 2rem;
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-color);
  transition: var(--transition);
}

section:hover {
  box-shadow: var(--shadow-lg);
}

[data-theme="dark"] section {
  background: var(--dark-surface);
  border-color: var(--dark-surface-light);
}

.form-container {
  @extend section;
}

/* ===== Tables ===== */
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin-bottom: 1.5rem;
  background: var(--light-surface);
  border-radius: var(--border-radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

[data-theme="dark"] table {
  background: var(--dark-surface);
}

th, td {
  padding: 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

th {
  background: linear-gradient(135deg, var(--primary-light), var(--primary-color));
  color: white;
  font-weight: 600;
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  position: sticky;
  top: 0;
  z-index: 5;
}

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

[data-theme="dark"] tr:hover {
  background: var(--dark-surface-light);
}

/* ===== Controls & Filters ===== */
.controls {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.filter-group {
  display: flex;
  gap: 1rem;
  align-items: flex-end;
  flex-wrap: wrap;
}

.filter-label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 0.875rem;
}

/* ===== Form Elements ===== */
input[type="text"],
input[type="number"],
input[type="password"],
input[type="date"],
select,
textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 2px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  font-size: 0.875rem;
  transition: var(--transition);
  background: var(--light-surface);
  color: var(--text-primary);
}

[data-theme="dark"] input[type="text"],
[data-theme="dark"] input[type="number"],
[data-theme="dark"] input[type="password"],
[data-theme="dark"] input[type="date"],
[data-theme="dark"] select,
[data-theme="dark"] textarea {
  background: var(--dark-surface);
  border-color: var(--dark-surface-light);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.controls input[type="text"],
.controls input[type="number"],
.controls input[type="date"],
.controls select {
  width: 200px;
}

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

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* ===== Pagination ===== */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  margin-top: 2rem;
}

.pagination button {
  padding: 0.75rem 1.25rem;
  border: none;
  background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
  color: white;
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  transition: var(--transition);
  font-weight: 600;
}

.pagination button:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.pagination button:disabled {
  background: var(--text-secondary);
  cursor: not-allowed;
  opacity: 0.5;
}

#pageInfo {
  padding: 0.5rem 1rem;
  background: var(--light-surface-hover);
  border-radius: var(--border-radius-sm);
  font-weight: 600;
  color: var(--text-secondary);
}

/* ===== Switch/Toggle ===== */
.switch {
  position: relative;
  display: inline-block;
  width: 60px;
  height: 32px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, #94a3b8, #64748b);
  transition: var(--transition);
  border-radius: 34px;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.slider:before {
  position: absolute;
  content: "";
  height: 24px;
  width: 24px;
  left: 4px;
  bottom: 4px;
  background: white;
  transition: var(--transition);
  border-radius: 50%;
  box-shadow: var(--shadow-md);
}

input:checked + .slider {
  background: linear-gradient(135deg, var(--success-color), #059669);
}

input:checked + .slider:before {
  transform: translateX(28px);
}

/* ===== Modal ===== */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(5px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  animation: fadeIn 0.3s ease;
}

.modal-content {
  background: var(--light-surface);
  padding: 2rem;
  border-radius: var(--border-radius-lg);
  max-width: 600px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  animation: slideUp 0.3s ease;
  border: 1px solid var(--border-color);
}

[data-theme="dark"] .modal-content {
  background: var(--dark-surface);
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ===== Array Editor ===== */
.array-item {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
  padding: 1rem;
  background: var(--light-surface-hover);
  border-radius: var(--border-radius-sm);
  align-items: center;
}

[data-theme="dark"] .array-item {
  background: var(--dark-surface-light);
}

.array-item input {
  flex: 1;
  padding: 0.5rem;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
}

/* ===== File Upload ===== */
.file-upload-wrapper {
  position: relative;
  display: inline-block;
  width: 100%;
  padding: 2rem;
  border: 2px dashed var(--border-color);
  border-radius: var(--border-radius);
  background: var(--light-surface-hover);
  text-align: center;
  transition: var(--transition);
  cursor: pointer;
}

.file-upload-wrapper:hover {
  border-color: var(--primary-color);
  background: rgba(99, 102, 241, 0.05);
}

.file-upload-wrapper input[type="file"] {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.file-upload-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  color: var(--text-secondary);
}

/* ===== Theme Toggle ===== */
.theme-toggle {
  position: fixed;
  top: 2rem;
  right: 2rem;
  z-index: 1000;
  padding: 0.75rem;
  border-radius: 50%;
  background: var(--light-surface);
  border: 2px solid var(--border-color);
  cursor: pointer;
  transition: var(--transition);
  box-shadow: var(--shadow-md);
}

.theme-toggle:hover {
  transform: scale(1.1);
  box-shadow: var(--shadow-lg);
}

[data-theme="dark"] .theme-toggle {
  background: var(--dark-surface);
}

/* ===== Loading Spinner ===== */
.loading {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid var(--border-color);
  border-top: 3px solid var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* ===== Responsive Design ===== */
@media (max-width: 1024px) {
  .container {
    flex-direction: column;
  }
  
  nav {
    width: 100%;
    height: auto;
    flex-direction: row;
    overflow-x: auto;
  }
  
  nav .nav-header {
    display: none;
  }
  
  nav .nav-items {
    display: flex;
    padding: 0;
  }
  
  main {
    padding: 1rem;
  }
  
  .header {
    flex-direction: column;
    gap: 1rem;
    padding: 1rem;
  }
  
  .controls {
    flex-direction: column;
    align-items: stretch;
  }
  
  .filter-group {
    flex-direction: column;
    align-items: stretch;
  }
  
  .controls input[type="text"],
  .controls input[type="number"],
  .controls input[type="date"],
  .controls select {
    width: 100%;
  }
}

@media (max-width: 640px) {
  main {
    padding: 0.5rem;
  }
  
  section {
    padding: 1rem;
    margin-bottom: 1rem;
  }
  
  h1 {
    font-size: 1.5rem;
  }
  
  .header {
    padding: 1rem;
  }
  
  .pagination {
    flex-wrap: wrap;
  }
  
  table {
    font-size: 0.875rem;
  }
  
  th, td {
    padding: 0.5rem;
  }
}

/* ===== Stats Cards ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--light-surface);
  padding: 1.5rem;
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: var(--transition);
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

[data-theme="dark"] .stat-card {
  background: var(--dark-surface);
  border-color: var(--dark-surface-light);
}

.stat-icon {
  width: 60px;
  height: 60px;
  border-radius: var(--border-radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
}

.stat-icon.primary {
  background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
}

.stat-icon.success {
  background: linear-gradient(135deg, var(--success-color), #059669);
}

.stat-icon.warning {
  background: linear-gradient(135deg, var(--warning-color), #d97706);
}

.stat-icon.info {
  background: linear-gradient(135deg, var(--secondary-color), #7c3aed);
}

.stat-content h3 {
  margin: 0 0 0.25rem;
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
}

.stat-content p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.875rem;
}

/* ===== Search Box ===== */
.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-box svg {
  position: absolute;
  left: 1rem;
  color: var(--text-secondary);
  z-index: 1;
}

.search-box input {
  padding-left: 3rem;
  width: 300px;
}

/* ===== Table Responsive ===== */
.table-responsive {
  overflow-x: auto;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-sm);
}

/* ===== Filter Actions ===== */
.filter-actions {
  display: flex;
  gap: 1rem;
  align-items: flex-end;
}

.form-select {
  min-width: 150px;
}

/* ===== Rows and Columns ===== */
.row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin: -0.5rem;
}

.col-md-6 {
  flex: 0 0 calc(50% - 1rem);
  margin: 0.5rem;
}

/* ===== User Status Badge ===== */
.user-status {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}

.user-status.active {
  background: rgba(16, 185, 129, 0.1);
  color: var(--success-color);
}

.user-status.blocked {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger-color);
}

/* ===== Table Elements ===== */
.user-id {
  font-family: 'Monaco', 'Menlo', monospace;
  background: var(--light-surface-hover);
  padding: 0.25rem 0.5rem;
  border-radius: var(--border-radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
}

.user-link {
  color: var(--primary-color);
  text-decoration: none;
  font-weight: 600;
  transition: var(--transition);
}

.user-link:hover {
  color: var(--primary-dark);
  text-decoration: underline;
}

.badge {
  background: var(--primary-color);
  color: white;
  padding: 0.25rem 0.5rem;
  border-radius: var(--border-radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  display: inline-block;
}

.discount-badge {
  background: var(--warning-color);
  color: white;
  padding: 0.25rem 0.5rem;
  border-radius: var(--border-radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  display: inline-block;
}

.amount {
  font-weight: 700;
  color: var(--success-color);
}

.deals-stats {
  font-size: 0.875rem;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.25rem;
}

.stat-value {
  font-family: 'Monaco', 'Menlo', monospace;
  font-size: 0.8rem;
}

.action-buttons {
  display: flex;
  gap: 0.5rem;
}

.btn-sm {
  padding: 0.5rem;
  font-size: 0.75rem;
  min-width: auto;
}

/* ===== Loading States ===== */
.skeleton {
  background: linear-gradient(90deg, var(--light-surface-hover) 25%, var(--border-color) 50%, var(--light-surface-hover) 75%);
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
}

@keyframes loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ===== Utility Classes ===== */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }
.mt-5 { margin-top: 2rem; }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }
.mb-5 { margin-bottom: 2rem; }

.p-0 { padding: 0; }
.p-1 { padding: 0.25rem; }
.p-2 { padding: 0.5rem; }
.p-3 { padding: 1rem; }
.p-4 { padding: 1.5rem; }
.p-5 { padding: 2rem; }

.hidden { display: none; }
.flex { display: flex; }
.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: 1rem; }
.gap-4 { gap: 1.5rem; }

.rounded { border-radius: var(--border-radius); }
.rounded-sm { border-radius: var(--border-radius-sm); }
.rounded-lg { border-radius: var(--border-radius-lg); }

.shadow-sm { box-shadow: var(--shadow-sm); }
.shadow-md { box-shadow: var(--shadow-md); }
.shadow-lg { box-shadow: var(--shadow-lg); }
.shadow-xl { box-shadow: var(--shadow-xl); }