/* Eptiz UI v2.0 - Custom CSS Variables & Tailwind Overrides
   Light/Dark tema desteği için CSS custom properties
   Requirements: 1.3, 6.1, 6.5
*/

/* ============================================
   COLOR PALETTE - LIGHT THEME (Default)
   WCAG AA Compliant Contrast Ratios
   ============================================ */
:root {
  /* Background Colors */
  --bg-primary: #f8fafc;      /* slate-50 */
  --bg-secondary: #ffffff;     /* white */
  --bg-tertiary: #f1f5f9;      /* slate-100 */
  --bg-elevated: #ffffff;      /* cards, modals */
  --bg-overlay: rgba(15, 23, 42, 0.5);
  
  /* Text Colors - WCAG AA compliant on light backgrounds */
  --text-primary: #0f172a;     /* slate-900 - 15.4:1 contrast */
  --text-secondary: #475569;   /* slate-600 - 7.0:1 contrast */
  --text-muted: #64748b;       /* slate-500 - 4.6:1 contrast */
  --text-inverse: #ffffff;
  
  /* Brand Colors - Kurumsal Lacivert */
  --accent-primary: #0b3a6a;   /* kurumsal lacivert */
  --accent-secondary: #0ea5e9; /* sky-500 */
  --accent-hover: #0a2f56;     /* darker lacivert */
  --accent-light: #e0f2fe;     /* sky-100 */
  --accent-muted: rgba(11, 58, 106, 0.1);
  
  /* Semantic Colors */
  --success: #059669;          /* emerald-600 - 4.5:1 contrast */
  --success-light: #d1fae5;    /* emerald-100 */
  --success-bg: rgba(5, 150, 105, 0.1);
  
  --warning: #d97706;          /* amber-600 - 4.5:1 contrast */
  --warning-light: #fef3c7;    /* amber-100 */
  --warning-bg: rgba(217, 119, 6, 0.1);
  
  --danger: #dc2626;           /* red-600 - 4.5:1 contrast */
  --danger-light: #fee2e2;     /* red-100 */
  --danger-bg: rgba(220, 38, 38, 0.1);
  
  --info: #2563eb;             /* blue-600 - 4.5:1 contrast */
  --info-light: #dbeafe;       /* blue-100 */
  --info-bg: rgba(37, 99, 235, 0.1);
  
  /* Border Colors */
  --border-color: #e2e8f0;     /* slate-200 */
  --border-hover: #cbd5e1;     /* slate-300 */
  --border-focus: #0b3a6a;     /* accent */
  
  /* Shadow Colors */
  --shadow-color: rgba(15, 23, 42, 0.08);
  --shadow-sm: 0 1px 2px 0 var(--shadow-color);
  --shadow: 0 4px 6px -1px var(--shadow-color), 0 2px 4px -2px var(--shadow-color);
  --shadow-md: 0 10px 15px -3px var(--shadow-color), 0 4px 6px -4px var(--shadow-color);
  --shadow-lg: 0 20px 25px -5px var(--shadow-color), 0 8px 10px -6px var(--shadow-color);
  --shadow-xl: 0 25px 50px -12px rgba(15, 23, 42, 0.25);
  
  /* Border Radius */
  --radius-xs: 0.25rem;        /* 4px */
  --radius-sm: 0.375rem;       /* 6px */
  --radius: 0.5rem;            /* 8px */
  --radius-md: 0.75rem;        /* 12px */
  --radius-lg: 1rem;           /* 16px */
  --radius-xl: 1.5rem;         /* 24px */
  --radius-full: 9999px;
  
  /* Spacing Scale */
  --space-1: 0.25rem;          /* 4px */
  --space-2: 0.5rem;           /* 8px */
  --space-3: 0.75rem;          /* 12px */
  --space-4: 1rem;             /* 16px */
  --space-5: 1.25rem;          /* 20px */
  --space-6: 1.5rem;           /* 24px */
  --space-8: 2rem;             /* 32px */
  --space-10: 2.5rem;          /* 40px */
  --space-12: 3rem;            /* 48px */
  
  /* Typography */
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
  
  --text-xs: 0.75rem;          /* 12px */
  --text-sm: 0.875rem;         /* 14px */
  --text-base: 1rem;           /* 16px */
  --text-lg: 1.125rem;         /* 18px */
  --text-xl: 1.25rem;          /* 20px */
  --text-2xl: 1.5rem;          /* 24px */
  --text-3xl: 1.875rem;        /* 30px */
  
  /* Line Heights */
  --leading-tight: 1.25;
  --leading-normal: 1.5;
  --leading-relaxed: 1.625;
  
  /* Transitions */
  --transition-fast: 150ms;
  --transition-normal: 200ms;
  --transition-slow: 300ms;
  --ease-default: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-in: cubic-bezier(0.4, 0, 1, 1);
  --ease-out: cubic-bezier(0, 0, 0.2, 1);
  --ease-bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);
  
  /* Z-Index Scale */
  --z-dropdown: 1000;
  --z-sticky: 1020;
  --z-fixed: 1030;
  --z-modal-backdrop: 1040;
  --z-modal: 1050;
  --z-popover: 1060;
  --z-tooltip: 1070;
  --z-toast: 1080;
  
  /* Layout */
  --sidebar-width: 240px;
  --sidebar-collapsed-width: 64px;
  --topbar-height: 64px;
  --container-max: 1280px;
  
  /* Breakpoints (for reference in JS) */
  --breakpoint-sm: 640px;
  --breakpoint-md: 768px;
  --breakpoint-lg: 1024px;
  --breakpoint-xl: 1280px;
}

/* ============================================
   COLOR PALETTE - DARK THEME
   WCAG AA Compliant Contrast Ratios
   ============================================ */
[data-theme="dark"] {
  /* Background Colors */
  --bg-primary: #0f172a;       /* slate-900 */
  --bg-secondary: #1e293b;     /* slate-800 */
  --bg-tertiary: #334155;      /* slate-700 */
  --bg-elevated: #1e293b;
  --bg-overlay: rgba(0, 0, 0, 0.7);
  
  /* Text Colors - WCAG AA compliant on dark backgrounds */
  --text-primary: #f1f5f9;     /* slate-100 - 13.5:1 contrast */
  --text-secondary: #cbd5e1;   /* slate-300 - 9.7:1 contrast */
  --text-muted: #94a3b8;       /* slate-400 - 5.9:1 contrast */
  --text-inverse: #0f172a;
  
  /* Brand Colors - Adjusted for dark mode */
  --accent-primary: #38bdf8;   /* sky-400 */
  --accent-secondary: #0ea5e9; /* sky-500 */
  --accent-hover: #7dd3fc;     /* sky-300 */
  --accent-light: #0c4a6e;     /* sky-900 */
  --accent-muted: rgba(56, 189, 248, 0.15);
  
  /* Semantic Colors - Adjusted for dark mode */
  --success: #34d399;          /* emerald-400 */
  --success-light: #064e3b;    /* emerald-900 */
  --success-bg: rgba(52, 211, 153, 0.15);
  
  --warning: #fbbf24;          /* amber-400 */
  --warning-light: #78350f;    /* amber-900 */
  --warning-bg: rgba(251, 191, 36, 0.15);
  
  --danger: #f87171;           /* red-400 */
  --danger-light: #7f1d1d;     /* red-900 */
  --danger-bg: rgba(248, 113, 113, 0.15);
  
  --info: #60a5fa;             /* blue-400 */
  --info-light: #1e3a8a;       /* blue-900 */
  --info-bg: rgba(96, 165, 250, 0.15);
  
  /* Border Colors */
  --border-color: #334155;     /* slate-700 */
  --border-hover: #475569;     /* slate-600 */
  --border-focus: #38bdf8;     /* accent */
  
  /* Shadow Colors - Darker for dark mode */
  --shadow-color: rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 1px 2px 0 var(--shadow-color);
  --shadow: 0 4px 6px -1px var(--shadow-color), 0 2px 4px -2px var(--shadow-color);
  --shadow-md: 0 10px 15px -3px var(--shadow-color), 0 4px 6px -4px var(--shadow-color);
  --shadow-lg: 0 20px 25px -5px var(--shadow-color), 0 8px 10px -6px var(--shadow-color);
  --shadow-xl: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

/* System preference detection - when no explicit theme is set */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    /* Background Colors */
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --bg-elevated: #1e293b;
    --bg-overlay: rgba(0, 0, 0, 0.7);
    
    /* Text Colors */
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --text-inverse: #0f172a;
    
    /* Brand Colors */
    --accent-primary: #38bdf8;
    --accent-secondary: #0ea5e9;
    --accent-hover: #7dd3fc;
    --accent-light: #0c4a6e;
    --accent-muted: rgba(56, 189, 248, 0.15);
    
    /* Semantic Colors */
    --success: #34d399;
    --success-light: #064e3b;
    --success-bg: rgba(52, 211, 153, 0.15);
    
    --warning: #fbbf24;
    --warning-light: #78350f;
    --warning-bg: rgba(251, 191, 36, 0.15);
    
    --danger: #f87171;
    --danger-light: #7f1d1d;
    --danger-bg: rgba(248, 113, 113, 0.15);
    
    --info: #60a5fa;
    --info-light: #1e3a8a;
    --info-bg: rgba(96, 165, 250, 0.15);
    
    /* Border Colors */
    --border-color: #334155;
    --border-hover: #475569;
    --border-focus: #38bdf8;
    
    /* Shadow Colors */
    --shadow-color: rgba(0, 0, 0, 0.4);
  }
}

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--text-primary);
  background-color: var(--bg-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Theme transition - smooth color changes */
html,
body,
.theme-transition,
.theme-transition * {
  transition: 
    background-color var(--transition-normal) var(--ease-default),
    border-color var(--transition-normal) var(--ease-default),
    color var(--transition-fast) var(--ease-default),
    box-shadow var(--transition-normal) var(--ease-default);
}

/* Disable transitions on page load */
.no-transitions,
.no-transitions * {
  transition: none !important;
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

/* Background utilities */
.bg-primary { background-color: var(--bg-primary); }
.bg-secondary { background-color: var(--bg-secondary); }
.bg-tertiary { background-color: var(--bg-tertiary); }
.bg-elevated { background-color: var(--bg-elevated); }
.bg-accent { background-color: var(--accent-primary); }
.bg-accent-muted { background-color: var(--accent-muted); }
.bg-success { background-color: var(--success-bg); }
.bg-warning { background-color: var(--warning-bg); }
.bg-danger { background-color: var(--danger-bg); }
.bg-info { background-color: var(--info-bg); }

/* Text utilities */
.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.text-inverse { color: var(--text-inverse); }
.text-accent { color: var(--accent-primary); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }
.text-info { color: var(--info); }

/* Border utilities */
.border-theme { border-color: var(--border-color); }
.border-hover { border-color: var(--border-hover); }
.border-focus { border-color: var(--border-focus); }
.border-accent { border-color: var(--accent-primary); }

/* Shadow utilities */
.shadow-theme-sm { box-shadow: var(--shadow-sm); }
.shadow-theme { box-shadow: var(--shadow); }
.shadow-theme-md { box-shadow: var(--shadow-md); }
.shadow-theme-lg { box-shadow: var(--shadow-lg); }
.shadow-theme-xl { box-shadow: var(--shadow-xl); }

/* ============================================
   ALPINE.JS SUPPORT
   ============================================ */

/* Hide elements until Alpine initializes */
[x-cloak] { display: none !important; }

/* ============================================
   ACCESSIBILITY
   ============================================ */

/* Focus visible for keyboard navigation */
:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}

/* Remove focus outline for mouse users */
:focus:not(:focus-visible) {
  outline: none;
}

/* Skip link for screen readers */
.skip-link {
  position: absolute;
  top: -100%;
  left: var(--space-4);
  background: var(--accent-primary);
  color: var(--text-inverse);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius);
  z-index: var(--z-tooltip);
  font-weight: 600;
  text-decoration: none;
  transition: top var(--transition-fast) var(--ease-default);
}

.skip-link:focus {
  top: var(--space-4);
}

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

/* 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;
}

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

/* Card base */
.card-theme {
  background-color: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

/* Button base */
.btn-theme {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: var(--leading-tight);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast) var(--ease-default);
  user-select: none;
}

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

/* Primary button */
.btn-primary-theme {
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  color: var(--text-inverse);
  box-shadow: var(--shadow-sm);
}

.btn-primary-theme:hover:not(:disabled) {
  filter: brightness(1.1);
  box-shadow: var(--shadow);
}

/* Ghost button */
.btn-ghost-theme {
  background: transparent;
  color: var(--accent-primary);
  border-color: var(--border-color);
}

.btn-ghost-theme:hover:not(:disabled) {
  background: var(--accent-muted);
  border-color: var(--accent-primary);
}

/* Input base */
.input-theme {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
  color: var(--text-primary);
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast) var(--ease-default);
}

.input-theme::placeholder {
  color: var(--text-muted);
}

.input-theme:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-muted);
  outline: none;
}

.input-theme:disabled {
  background-color: var(--bg-tertiary);
  cursor: not-allowed;
}

/* Badge base */
.badge-theme {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-2);
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: 1;
  border-radius: var(--radius-full);
  border: 1px solid transparent;
}

.badge-success-theme {
  background-color: var(--success-bg);
  color: var(--success);
  border-color: var(--success);
}

.badge-warning-theme {
  background-color: var(--warning-bg);
  color: var(--warning);
  border-color: var(--warning);
}

.badge-danger-theme {
  background-color: var(--danger-bg);
  color: var(--danger);
  border-color: var(--danger);
}

.badge-info-theme {
  background-color: var(--info-bg);
  color: var(--info);
  border-color: var(--info);
}

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

/* Mobile first approach */
/* sm: 640px and up */
@media (min-width: 640px) {
  :root {
    --container-padding: var(--space-6);
  }
}

/* md: 768px and up (tablet) */
@media (min-width: 768px) {
  :root {
    --container-padding: var(--space-8);
  }
}

/* lg: 1024px and up */
@media (min-width: 1024px) {
  :root {
    --container-padding: var(--space-10);
  }
}

/* xl: 1280px and up (desktop) */
@media (min-width: 1280px) {
  :root {
    --container-padding: var(--space-12);
  }
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
  :root {
    --bg-primary: #ffffff;
    --bg-secondary: #ffffff;
    --text-primary: #000000;
    --text-secondary: #333333;
  }
  
  .no-print {
    display: none !important;
  }
  
  body {
    background: white;
    color: black;
  }
  
  a[href]::after {
    content: none;
  }
}

/* ============================================
   TASK 15: ACCESSIBILITY ENHANCEMENTS
   ============================================ */

/* Enhanced Focus Indicators */
.focus-ring:focus,
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px var(--accent-muted);
}

/* High contrast focus for dark mode */
[data-theme="dark"] .focus-ring:focus,
[data-theme="dark"] button:focus-visible,
[data-theme="dark"] a:focus-visible {
  outline-color: var(--accent-primary);
  box-shadow: 0 0 0 4px rgba(56, 189, 248, 0.3);
}

/* Focus within for form groups */
.form-group:focus-within {
  border-color: var(--border-focus);
}

/* Interactive element hover states */
.interactive {
  cursor: pointer;
  transition: all var(--transition-fast) var(--ease-default);
}

.interactive:hover {
  background-color: var(--accent-muted);
}

.interactive:active {
  transform: scale(0.98);
}

/* ============================================
   LAZY LOADING STYLES
   ============================================ */

/* Lazy load placeholder */
.lazy-load {
  opacity: 0;
  transition: opacity var(--transition-slow) var(--ease-default);
}

.lazy-load.loaded {
  opacity: 1;
}

/* Image lazy loading */
img[loading="lazy"] {
  background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--bg-secondary) 50%, var(--bg-tertiary) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

img[loading="lazy"].loaded {
  background: none;
  animation: none;
}

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

/* Skeleton loading animation */
.skeleton {
  background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--bg-secondary) 50%, var(--bg-tertiary) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius);
}

.skeleton-text {
  height: 1em;
  margin-bottom: 0.5em;
}

.skeleton-text:last-child {
  width: 70%;
}

.skeleton-circle {
  border-radius: 50%;
}

.skeleton-button {
  height: 2.5rem;
  width: 6rem;
}

/* ============================================
   ARIA & SCREEN READER ENHANCEMENTS
   ============================================ */

/* Visually hidden but accessible */
.visually-hidden,
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* Show on focus for skip links */
.visually-hidden-focusable:focus,
.sr-only-focusable:focus {
  position: static !important;
  width: auto !important;
  height: auto !important;
  padding: var(--space-2) var(--space-4) !important;
  margin: 0 !important;
  overflow: visible !important;
  clip: auto !important;
  white-space: normal !important;
}

/* Live region for announcements */
[aria-live] {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

[aria-live].visible {
  position: static;
  left: auto;
  width: auto;
  height: auto;
  overflow: visible;
}

/* Required field indicator */
.required::after {
  content: " *";
  color: var(--danger);
  font-weight: bold;
}

/* Error state for form fields */
.has-error input,
.has-error select,
.has-error textarea,
input[aria-invalid="true"],
select[aria-invalid="true"],
textarea[aria-invalid="true"] {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-bg);
}

.error-message {
  color: var(--danger);
  font-size: var(--text-sm);
  margin-top: var(--space-1);
}

/* Success state for form fields */
.has-success input,
.has-success select,
.has-success textarea,
input[aria-invalid="false"],
select[aria-invalid="false"],
textarea[aria-invalid="false"] {
  border-color: var(--success);
}

/* Disabled state */
[disabled],
[aria-disabled="true"] {
  opacity: 0.6;
  cursor: not-allowed;
  pointer-events: none;
}

/* ============================================
   KEYBOARD NAVIGATION HELPERS
   ============================================ */

/* Tab navigation indicator */
.tab-focus {
  position: relative;
}

.tab-focus::after {
  content: "";
  position: absolute;
  inset: -2px;
  border: 2px solid transparent;
  border-radius: inherit;
  pointer-events: none;
  transition: border-color var(--transition-fast);
}

.tab-focus:focus-visible::after {
  border-color: var(--accent-primary);
}

/* Keyboard shortcut hints */
.kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.5em;
  padding: 0.125em 0.375em;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xs);
  box-shadow: 0 1px 0 var(--border-color);
}

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

/* Touch target size (minimum 44x44px for mobile) */
@media (pointer: coarse) {
  button,
  a,
  input[type="checkbox"],
  input[type="radio"],
  select,
  .touch-target {
    min-height: 44px;
    min-width: 44px;
  }
  
  /* Increase spacing for touch */
  .touch-spacing > * + * {
    margin-top: var(--space-4);
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  :root {
    --border-color: currentColor;
    --border-hover: currentColor;
  }
  
  button,
  input,
  select,
  textarea {
    border-width: 2px;
  }
  
  :focus-visible {
    outline-width: 3px;
  }
}

/* Forced colors mode (Windows High Contrast) */
@media (forced-colors: active) {
  .btn-primary-theme,
  .btn-ghost-theme {
    border: 2px solid currentColor;
  }
  
  :focus-visible {
    outline: 3px solid Highlight;
  }
}
