/**
 * Core CSS - Combined Foundation
 * File: public/assets/css/core.css
 * 
 * Combines: Variables + Reset + Typography + Layout
 * Single file for all foundational styles to reduce HTTP requests
 * and eliminate duplication across core systems
 */

/* ========================================
   CSS VARIABLES - DESIGN SYSTEM
   ======================================== */
:root {
  /* Colors */
  --primary: #3b82f6;
  --primary-dark: #2563eb;
  --primary-light: #93c5fd;
  --secondary: #6b7280;
  --success: #10b981;
  --warning: #f59e0b;
  --error: #ef4444;
  --info: #3b82f6;
  
  /* Backgrounds */
  --bg-primary: #ffffff;
  --bg-secondary: #f8fafc;
  --bg-light: #f1f5f9;
  --bg-muted: #e2e8f0;
  
  /* Text */
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --text-inverse: #ffffff;
  
  /* Borders */
  --border-color: #e2e8f0;
  --border-focus: var(--primary);
  
  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 0.75rem;
  --space-lg: 1rem;
  --space-xl: 1.5rem;
  --space-2xl: 2rem;
  --space-3xl: 3rem;
  
  /* Typography */
  --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-size-xs: 0.75rem;
  --font-size-sm: 0.875rem;
  --font-size-base: 1rem;
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.25rem;
  --font-size-2xl: 1.5rem;
  --font-size-3xl: 1.875rem;
  
  /* Layout */
  --border-radius: 0.375rem;
  --border-radius-lg: 0.5rem;
  --border-radius-full: 9999px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
  --transition: all 0.2s ease;
  
  /* Component Specific */
  --container-max-width: 1200px;
  --header-height: 64px;
}

/* ========================================
   CSS RESET & NORMALIZE
   ======================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  line-height: 1.15;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  line-height: 1.5;
  color: var(--text-primary);
  background-color: var(--bg-secondary);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

img, picture, svg {
  max-width: 100%;
  height: auto;
  display: block;
}

input, button, textarea, select {
  font: inherit;
}

button {
  background: none;
  border: none;
  cursor: pointer;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: var(--transition);
}

a:hover {
  color: var(--primary-dark);
  text-decoration: underline;
}

/* ========================================
   TYPOGRAPHY
   ======================================== */
h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  line-height: 1.25;
  margin-bottom: var(--space-lg);
  color: var(--text-primary);
}

h1 { font-size: var(--font-size-3xl); }
h2 { font-size: var(--font-size-2xl); }
h3 { font-size: var(--font-size-xl); }
h4 { font-size: var(--font-size-lg); }
h5 { font-size: var(--font-size-base); }
h6 { font-size: var(--font-size-sm); text-transform: uppercase; letter-spacing: 0.05em; }

p {
  margin-bottom: var(--space-lg);
  line-height: 1.6;
}

/* Typography Utilities */
.text-xs { font-size: var(--font-size-xs); }
.text-sm { font-size: var(--font-size-sm); }
.text-lg { font-size: var(--font-size-lg); }
.text-xl { font-size: var(--font-size-xl); }

.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-error { color: var(--error); }

.text-center { text-align: center; }
.text-right { text-align: right; }

.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

/* ========================================
   LAYOUT SYSTEM
   ======================================== */

/* Container */
.container {
  width: 100%;
  max-width: var(--container-max-width);
  margin: 0 auto;
  padding: 0 var(--space-lg);
}

.container-narrow {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 var(--space-lg);
}

/* Main Layout */
.main-layout {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.main-content {
  flex: 1;
  padding: var(--space-xl) 0;
}

.content-wrapper {
  background: var(--bg-primary);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow);
  padding: var(--space-2xl);
  margin-bottom: var(--space-xl);
}

/* Header */
.header {
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-height);
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  padding: 0 var(--space-lg);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  font-weight: 600;
  font-size: var(--font-size-lg);
  color: var(--text-primary);
  text-decoration: none;
}

/* Navigation */
.nav-list {
  display: flex;
  list-style: none;
  gap: var(--space-md);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--border-radius);
  transition: var(--transition);
  font-weight: 500;
}

.nav-link:hover {
  color: var(--text-primary);
  background-color: var(--bg-light);
  text-decoration: none;
}

.nav-link.active {
  color: var(--primary);
  background-color: rgba(59, 130, 246, 0.1);
}

/* User Menu */
.user-menu {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.user-name {
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--text-primary);
}

.logout-btn {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-md);
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--border-radius);
  transition: var(--transition);
  font-size: var(--font-size-sm);
}

.logout-btn:hover {
  color: var(--error);
  background-color: rgba(239, 68, 68, 0.1);
  text-decoration: none;
}

/* Grid System */
.grid {
  display: grid;
  gap: var(--space-lg);
}

.grid-cols-1 { grid-template-columns: repeat(1, 1fr); }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }

/* Flexbox */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }
.flex-1 { flex: 1; }

/* Spacing */
.m-0 { margin: 0; }
.mb-0 { margin-bottom: 0; }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.mb-xl { margin-bottom: var(--space-xl); }
.mt-lg { margin-top: var(--space-lg); }
.mx-auto { margin-left: auto; margin-right: auto; }

.p-0 { padding: 0; }
.p-md { padding: var(--space-md); }
.p-lg { padding: var(--space-lg); }
.p-xl { padding: var(--space-xl); }

/* Display */
.block { display: block; }
.hidden { display: none; }
.w-full { width: 100%; }
.h-full { height: 100%; }

/* Position */
.relative { position: relative; }
.absolute { position: absolute; }

/* ========================================
   FOOTER
   ======================================== */
.footer {
  background: var(--bg-primary);
  border-top: 1px solid var(--border-color);
  padding: var(--space-xl) 0;
  margin-top: auto;
}

.footer-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-lg);
  flex-wrap: wrap;
}

.footer-section {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.footer-text {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  margin: 0;
}

.footer-links {
  display: flex;
  gap: var(--space-lg);
}

.footer-link {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  text-decoration: none;
  transition: var(--transition);
}

.footer-link:hover {
  color: var(--text-primary);
  text-decoration: underline;
}

.footer-info {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  font-size: var(--font-size-xs);
  color: var(--text-muted);
}

.version-info {
  background: var(--bg-light);
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--border-radius);
  font-family: var(--font-family-mono, monospace);
}

/* Mobile Overlay */
.mobile-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;
  display: none;
  opacity: 0;
  transition: opacity var(--transition);
}

.mobile-overlay.show {
  display: block;
  opacity: 1;
}

/* Mobile Menu Styles */
.mobile-menu-toggle {
  display: none;
  position: fixed;
  top: var(--space-lg);
  right: var(--space-lg);
  z-index: 1001;
  background: var(--primary);
  color: white;
  border: none;
  width: 44px;
  height: 44px;
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: var(--transition);
}

.mobile-menu-toggle:hover {
  background: var(--primary-dark);
}

.hamburger {
  display: block;
  width: 20px;
  height: 2px;
  background: currentColor;
  position: relative;
  transition: var(--transition);
}

.hamburger::before,
.hamburger::after {
  content: '';
  position: absolute;
  width: 100%;
  height: 2px;
  background: currentColor;
  transition: var(--transition);
}

.hamburger::before {
  top: -6px;
}

.hamburger::after {
  bottom: -6px;
}

.mobile-menu-toggle.active .hamburger {
  background: transparent;
}

.mobile-menu-toggle.active .hamburger::before {
  transform: rotate(45deg);
  top: 0;
}

.mobile-menu-toggle.active .hamburger::after {
  transform: rotate(-45deg);
  bottom: 0;
}

.mobile-nav {
  position: fixed;
  top: 0;
  left: -100%;
  width: 280px;
  height: 100vh;
  background: var(--bg-primary);
  border-right: 1px solid var(--border-color);
  z-index: 1000;
  padding: var(--space-xl) 0;
  transition: left var(--transition);
  overflow-y: auto;
}

.mobile-nav.show {
  left: 0;
}

.mobile-nav-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.mobile-nav-item {
  border-bottom: 1px solid var(--border-color);
}

.mobile-nav-link {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-lg) var(--space-xl);
  color: var(--text-primary);
  text-decoration: none;
  transition: var(--transition);
}

.mobile-nav-link:hover {
  background: var(--bg-light);
  text-decoration: none;
}

.mobile-nav-link.active {
  background: rgba(59, 130, 246, 0.1);
  color: var(--primary);
}

/* Debug Tools */
.debug-info {
  position: fixed;
  bottom: var(--space-lg);
  right: var(--space-lg);
  z-index: 1050;
}

.debug-toggle {
  background: var(--warning);
  color: white;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: var(--border-radius-full);
  cursor: pointer;
  font-size: var(--font-size-lg);
  transition: var(--transition);
}

.debug-toggle:hover {
  transform: scale(1.1);
}

.debug-panel {
  position: absolute;
  bottom: 50px;
  right: 0;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: var(--space-lg);
  min-width: 250px;
  box-shadow: var(--shadow-lg);
}

.debug-panel h4 {
  margin-bottom: var(--space-md);
  font-size: var(--font-size-sm);
  color: var(--text-primary);
}

.debug-panel ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.debug-panel li {
  padding: var(--space-xs) 0;
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-color);
}

.debug-panel li:last-child {
  border-bottom: none;
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */
@media (max-width: 1024px) {
  .grid-cols-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-cols-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .container, .container-narrow {
    padding: 0 var(--space-md);
  }
  
  .main-content {
    padding: var(--space-lg) 0;
  }
  
  .content-wrapper {
    padding: var(--space-lg);
  }
  
  .header-content {
    padding: 0 var(--space-md);
  }
  
  .grid-cols-2,
  .grid-cols-3,
  .grid-cols-4 {
    grid-template-columns: 1fr;
  }
  
  h1 { font-size: var(--font-size-2xl); }
  h2 { font-size: var(--font-size-xl); }
  
  .user-menu .user-name {
    display: none;
  }
  
  /* Mobile Header */
  .header-nav {
    display: none;
  }
  
  .mobile-menu-toggle {
    display: block;
  }
  
  /* Mobile Footer */
  .footer-content {
    flex-direction: column;
    text-align: center;
    gap: var(--space-md);
  }
  
  .footer-links {
    flex-direction: column;
    gap: var(--space-sm);
  }
  
  .footer-info {
    flex-direction: column;
    gap: var(--space-sm);
  }
}