/* Optimized Core CSS - Consolidated and Performance Optimized */
/* This file consolidates common styles to reduce redundancy and improve loading performance */

/* ===== CSS VARIABLES (Consolidated) ===== */
:root {
  /* Primary Colors */
  --primary-color: #667eea;
  --primary-dark: #764ba2;
  --secondary-color: #f093fb;
  
  /* Status Colors */
  --success-color: #28a745;
  --warning-color: #ffc107;
  --danger-color: #dc3545;
  --info-color: #17a2b8;
  
  /* Neutral Colors */
  --light-color: #f8f9fa;
  --dark-color: #343a40;
  --text-primary: #374151;
  --text-secondary: #6c757d;
  --text-muted: #bdc3c7;
  --background-light: #f8fafc;
  --border-light: #e1e8ed;
  
  /* Typography */
  --font-family-base: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-size-base: 1rem;
  --font-size-sm: 0.875rem;
  --font-size-lg: 1.125rem;
  --line-height-normal: 1.6;
  
  /* Spacing */
  --spacing-xs: 0.25rem;
  --spacing-sm: 0.5rem;
  --spacing-md: 1rem;
  --spacing-lg: 1.5rem;
  --spacing-xl: 2rem;
  
  /* Layout */
  --border-radius: 8px;
  --box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  --transition: all 0.3s ease;
}

/* ===== BASE STYLES ===== */
* {
  box-sizing: border-box;
}

body {
  font-family: var(--font-family-base);
  font-size: var(--font-size-base);
  line-height: var(--line-height-normal);
  color: var(--text-primary);
  background-color: var(--background-light);
  margin: 0;
  padding: 0;
}

/* ===== LAYOUT ===== */
.lw-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--spacing-md);
}

/* ===== BUTTONS (Consolidated) ===== */
.lw-btn {
  display: inline-block;
  padding: 12px 24px;
  border: none;
  border-radius: var(--border-radius);
  text-decoration: none;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  font-weight: 500;
  font-size: var(--font-size-sm);
  line-height: 1.5;
  min-height: 44px; /* Touch-friendly */
  min-width: 44px;
}

.lw-btn:hover {
  text-decoration: none;
  transform: translateY(-1px);
}

.lw-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

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

.lw-btn-primary:hover {
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.lw-btn-secondary {
  background-color: var(--text-secondary);
  color: white;
}

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

.lw-btn-danger {
  background-color: var(--danger-color);
  color: white;
}

/* ===== FORMS (Consolidated) ===== */
.form-group {
  margin-bottom: var(--spacing-md);
}

.form-control {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border-light);
  border-radius: var(--border-radius);
  font-size: var(--font-size-base);
  transition: var(--transition);
  min-height: 44px; /* Touch-friendly */
}

.form-control:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
  border-color: var(--primary-color);
}

.form-label {
  font-weight: 600;
  margin-bottom: 0.5rem;
  display: block;
}

.form-label.required::after {
  content: " *";
  color: var(--danger-color);
}

.invalid-feedback {
  display: block;
  width: 100%;
  margin-top: 0.25rem;
  font-size: var(--font-size-sm);
  color: var(--danger-color);
}

/* ===== CARDS ===== */
.lw-card {
  background: white;
  border-radius: var(--border-radius);
  box-shadow: var(--box-shadow);
  border: 1px solid var(--border-light);
  overflow: hidden;
}

.lw-card .card-header {
  padding: var(--spacing-md);
  background-color: var(--light-color);
  border-bottom: 1px solid var(--border-light);
}

.lw-card .card-body {
  padding: var(--spacing-md);
}

/* ===== ALERTS ===== */
.lw-alert {
  padding: var(--spacing-md);
  border-radius: var(--border-radius);
  border-left: 4px solid;
  margin-bottom: var(--spacing-md);
}

.lw-alert-success {
  background-color: #d4edda;
  color: #155724;
  border-left-color: var(--success-color);
}

.lw-alert-danger {
  background-color: #f8d7da;
  color: #721c24;
  border-left-color: var(--danger-color);
}

.lw-alert-warning {
  background-color: #fff3cd;
  color: #856404;
  border-left-color: var(--warning-color);
}

.lw-alert-info {
  background-color: #d1ecf1;
  color: #0c5460;
  border-left-color: var(--info-color);
}

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

.d-none { display: none; }
.d-block { display: block; }
.d-flex { display: flex; }
.d-grid { display: grid; }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: var(--spacing-xs); }
.mb-2 { margin-bottom: var(--spacing-sm); }
.mb-3 { margin-bottom: var(--spacing-md); }
.mb-4 { margin-bottom: var(--spacing-lg); }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: var(--spacing-xs); }
.mt-2 { margin-top: var(--spacing-sm); }
.mt-3 { margin-top: var(--spacing-md); }
.mt-4 { margin-top: var(--spacing-lg); }

/* ===== LOADING STATES ===== */
.loading {
  position: relative;
}

.loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid #f3f3f3;
  border-top: 2px 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: 768px) {
  .container {
    padding: 0 var(--spacing-sm);
  }
  
  .btn {
    padding: 14px 16px;
    font-size: 16px; /* Prevent zoom on iOS */
  }
  
  .form-control {
    font-size: 16px; /* Prevent zoom on iOS */
  }
}

/* ===== ACCESSIBILITY ===== */
@media (prefers-reduced-motion: reduce) {
  *, ::after, ::before {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

@media (prefers-contrast: high) {
  .btn {
    border: 2px solid currentColor;
  }
  
  .card {
    border: 1px solid #000;
  }
  
  .form-control {
    border: 2px solid #000;
  }
}

/* Screen reader only */
.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;
}

/* Skip link for accessibility */
.skip-link {
  position: absolute;
  top: -40px;
  left: 6px;
  background: #000;
  color: #fff;
  padding: 8px;
  text-decoration: none;
  z-index: 9999;
  border-radius: 4px;
}

.skip-link:focus {
  top: 6px;
}