/* ========================================
   DEFAULT.CSS - Complete CSS Framework
   Themes: Light, Dark, Book
   UI/UX: Accessible, Responsive, Modern
   ======================================== */

/* ---------- CSS Variables & Root ---------- */
:root {
  /* ----- Light Theme (Default) ----- */
  --bg-primary: #ffffff;
  --bg-secondary: #f8f9fa;
  --bg-tertiary: #f1f3f5;
  --bg-accent: #e9ecef;
  
  --text-primary: #212529;
  --text-secondary: #495057;
  --text-muted: #6c757d;
  --text-inverse: #ffffff;
  
  --border-color: #dee2e6;
  --shadow-color: rgba(0, 0, 0, 0.1);
  --shadow-hover: rgba(0, 0, 0, 0.15);
  
  --accent-color: #4a6cf7;
  --accent-hover: #3a56d4;
  --success-color: #28a745;
  --warning-color: #ffc107;
  --danger-color: #dc3545;
  --info-color: #17a2b8;
  
  --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'Courier New', monospace;
  --font-size-base: 16px;
  --line-height-base: 1.6;
  
  --border-radius: 8px;
  --border-radius-sm: 4px;
  --border-radius-lg: 12px;
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  
  --container-max: 1200px;
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;
  --spacing-xxl: 48px;
}

/* ----- Dark Theme ----- */
[data-theme="dark"] {
  --bg-primary: #1a1a2e;
  --bg-secondary: #16213e;
  --bg-tertiary: #0f3460;
  --bg-accent: #2a2a4a;
  
  --text-primary: #e8e8e8;
  --text-secondary: #b8b8b8;
  --text-muted: #888888;
  --text-inverse: #1a1a2e;
  
  --border-color: #3a3a5a;
  --shadow-color: rgba(0, 0, 0, 0.3);
  --shadow-hover: rgba(0, 0, 0, 0.5);
  
  --accent-color: #6c8cff;
  --accent-hover: #5a7ae8;
}

/* ----- Book Theme (Warm/Paper) ----- */
[data-theme="book"] {
  --bg-primary: #f5f0e8;
  --bg-secondary: #ede7dd;
  --bg-tertiary: #e5ddd0;
  --bg-accent: #dcd2c4;
  
  --text-primary: #2c241a;
  --text-secondary: #4a3f33;
  --text-muted: #6b5f52;
  --text-inverse: #f5f0e8;
  
  --border-color: #c9bdb0;
  --shadow-color: rgba(80, 60, 40, 0.15);
  --shadow-hover: rgba(80, 60, 40, 0.25);
  
  --accent-color: #8b6b4a;
  --accent-hover: #7a5d3f;
}

/* ---------- Reset & Base ---------- */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: var(--font-size-base);
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-family);
  font-size: 1rem;
  line-height: var(--line-height-base);
  color: var(--text-primary);
  background-color: var(--bg-primary);
  transition: background-color var(--transition), color var(--transition);
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ---------- Typography ---------- */
h1, h2, h3, h4, h5, h6 {
  margin-bottom: 0.5em;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-primary);
}

h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.75rem; }
h4 { font-size: 1.5rem; }
h5 { font-size: 1.25rem; }
h6 { font-size: 1rem; }

p {
  margin-bottom: 1rem;
  color: var(--text-secondary);
}

a {
  color: var(--accent-color);
  text-decoration: none;
  transition: color var(--transition);
}

a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

small {
  font-size: 0.875rem;
  color: var(--text-muted);
}

strong, b { font-weight: 700; }
em, i { font-style: italic; }

ul, ol {
  margin-bottom: 1rem;
  padding-left: 1.5rem;
  color: var(--text-secondary);
}

li { margin-bottom: 0.25rem; }

blockquote {
  margin: 1.5rem 0;
  padding: 1rem 1.5rem;
  border-left: 4px solid var(--accent-color);
  background: var(--bg-secondary);
  border-radius: 0 var(--border-radius-sm) var(--border-radius-sm) 0;
  color: var(--text-secondary);
}

code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  padding: 0.2rem 0.4rem;
  background: var(--bg-accent);
  border-radius: var(--border-radius-sm);
  color: var(--text-primary);
}

pre {
  margin: 1.5rem 0;
  padding: 1.5rem;
  background: var(--bg-secondary);
  border-radius: var(--border-radius);
  overflow-x: auto;
  border: 1px solid var(--border-color);
}

pre code {
  background: transparent;
  padding: 0;
  font-size: 0.9rem;
}

hr {
  margin: 2rem 0;
  border: 0;
  border-top: 1px solid var(--border-color);
}

/* ---------- Links & Buttons ---------- */
button,
input[type="submit"],
input[type="reset"],
input[type="button"] {
  display: inline-block;
  font-family: var(--font-family);
  font-size: 1rem;
  font-weight: 500;
  padding: 0.625rem 1.25rem;
  border: none;
  border-radius: var(--border-radius);
  background: var(--accent-color);
  color: var(--text-inverse);
  cursor: pointer;
  transition: all var(--transition);
  line-height: 1.5;
}

button:hover,
input[type="submit"]:hover,
input[type="reset"]:hover,
input[type="button"]:hover {
  background: var(--accent-hover);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px var(--shadow-hover);
}

button:active,
input[type="submit"]:active {
  transform: translateY(0);
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* Button Variants */
.btn-secondary {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: var(--bg-accent);
  border-color: var(--text-muted);
}

.btn-success { background: var(--success-color); }
.btn-danger { background: var(--danger-color); }
.btn-warning { background: var(--warning-color); color: #212529; }
.btn-info { background: var(--info-color); }

.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.875rem; }
.btn-lg { padding: 0.875rem 1.75rem; font-size: 1.125rem; }

/* ---------- Forms ---------- */
input:not([type="submit"]):not([type="reset"]):not([type="button"]),
textarea,
select {
  display: block;
  width: 100%;
  padding: 0.625rem 0.875rem;
  font-family: var(--font-family);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  transition: border-color var(--transition), box-shadow var(--transition);
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px rgba(74, 108, 247, 0.15);
}

textarea {
  min-height: 100px;
  resize: vertical;
}

label {
  display: block;
  margin-bottom: 0.375rem;
  font-weight: 500;
  color: var(--text-secondary);
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236c757d' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  padding-right: 2.5rem;
}

/* Checkbox & Radio */
input[type="checkbox"],
input[type="radio"] {
  display: inline-block;
  width: auto;
  margin-right: 0.5rem;
  accent-color: var(--accent-color);
}

/* ---------- Tables ---------- */
table {
  width: 100%;
  margin-bottom: 1.5rem;
  border-collapse: collapse;
  background: var(--bg-primary);
  border-radius: var(--border-radius);
  overflow: hidden;
}

th, td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

th {
  font-weight: 600;
  background: var(--bg-secondary);
  color: var(--text-primary);
}

tr:hover {
  background: var(--bg-secondary);
}

/* ---------- Images & Media ---------- */
img {
  max-width: 100%;
  height: auto;
  display: block;
  border-radius: var(--border-radius);
}

figure {
  margin: 1.5rem 0;
}

figcaption {
  margin-top: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  text-align: center;
}

/* ---------- Layout Utilities ---------- */
.container {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 var(--spacing-md);
}

/* Flex Grid */
.row {
  display: flex;
  flex-wrap: wrap;
  margin: 0 calc(-1 * var(--spacing-sm));
}

.col {
  flex: 1;
  padding: 0 var(--spacing-sm);
  min-width: 0;
}

.col-1 { flex: 0 0 8.333%; max-width: 8.333%; }
.col-2 { flex: 0 0 16.666%; max-width: 16.666%; }
.col-3 { flex: 0 0 25%; max-width: 25%; }
.col-4 { flex: 0 0 33.333%; max-width: 33.333%; }
.col-5 { flex: 0 0 41.666%; max-width: 41.666%; }
.col-6 { flex: 0 0 50%; max-width: 50%; }
.col-7 { flex: 0 0 58.333%; max-width: 58.333%; }
.col-8 { flex: 0 0 66.666%; max-width: 66.666%; }
.col-9 { flex: 0 0 75%; max-width: 75%; }
.col-10 { flex: 0 0 83.333%; max-width: 83.333%; }
.col-11 { flex: 0 0 91.666%; max-width: 91.666%; }
.col-12 { flex: 0 0 100%; max-width: 100%; }

/* ---------- Cards ---------- */
.card {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: var(--spacing-lg);
  box-shadow: 0 2px 8px var(--shadow-color);
  transition: all var(--transition);
}

.card:hover {
  box-shadow: 0 8px 24px var(--shadow-hover);
  transform: translateY(-4px);
}

.card-header {
  margin-bottom: var(--spacing-md);
  padding-bottom: var(--spacing-sm);
  border-bottom: 1px solid var(--border-color);
}

.card-footer {
  margin-top: var(--spacing-md);
  padding-top: var(--spacing-sm);
  border-top: 1px solid var(--border-color);
}

/* ---------- Navigation ---------- */
nav {
  background: var(--bg-secondary);
  padding: var(--spacing-md) 0;
  border-bottom: 1px solid var(--border-color);
}

nav ul {
  list-style: none;
  display: flex;
  gap: var(--spacing-lg);
  padding: 0;
  margin: 0;
}

nav li {
  margin: 0;
}

nav a {
  color: var(--text-secondary);
  font-weight: 500;
  padding: 0.375rem 0.75rem;
  border-radius: var(--border-radius-sm);
  transition: all var(--transition);
}

nav a:hover {
  color: var(--text-primary);
  background: var(--bg-accent);
  text-decoration: none;
}

/* ---------- Alerts ---------- */
.alert {
  padding: var(--spacing-md) var(--spacing-lg);
  margin-bottom: var(--spacing-md);
  border-radius: var(--border-radius);
  border-left: 4px solid var(--accent-color);
  background: var(--bg-secondary);
  color: var(--text-secondary);
}

.alert-success { border-left-color: var(--success-color); background: #d4edda; color: #155724; }
.alert-danger { border-left-color: var(--danger-color); background: #f8d7da; color: #721c24; }
.alert-warning { border-left-color: var(--warning-color); background: #fff3cd; color: #856404; }
.alert-info { border-left-color: var(--info-color); background: #d1ecf1; color: #0c5460; }

[data-theme="dark"] .alert-success { background: #1e3a2a; color: #7ddb9a; }
[data-theme="dark"] .alert-danger { background: #3a1e22; color: #f5a3a9; }
[data-theme="dark"] .alert-warning { background: #3a2e1e; color: #e8c86a; }
[data-theme="dark"] .alert-info { background: #1a2e3a; color: #6fcde8; }

/* ---------- Badges ---------- */
.badge {
  display: inline-block;
  padding: 0.25rem 0.625rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 50px;
  background: var(--bg-accent);
  color: var(--text-secondary);
}

.badge-primary { background: var(--accent-color); color: var(--text-inverse); }
.badge-success { background: var(--success-color); color: white; }
.badge-danger { background: var(--danger-color); color: white; }
.badge-warning { background: var(--warning-color); color: #212529; }

/* ---------- Theme Switcher ---------- */
.theme-switcher {
  display: flex;
  gap: var(--spacing-sm);
  padding: var(--spacing-sm);
  background: var(--bg-secondary);
  border-radius: var(--border-radius);
  border: 1px solid var(--border-color);
}

.theme-switcher button {
  padding: 0.375rem 0.875rem;
  font-size: 0.875rem;
  background: transparent;
  color: var(--text-secondary);
  border-radius: var(--border-radius-sm);
}

.theme-switcher button:hover {
  background: var(--bg-accent);
  color: var(--text-primary);
  transform: none;
  box-shadow: none;
}

.theme-switcher button.active {
  background: var(--accent-color);
  color: var(--text-inverse);
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
  h1 { font-size: 2rem; }
  h2 { font-size: 1.75rem; }
  h3 { font-size: 1.5rem; }
  
  .container { padding: 0 var(--spacing-sm); }
  
  .col { flex: 0 0 100%; max-width: 100%; }
  
  [class*="col-"] {
    flex: 0 0 100%;
    max-width: 100%;
  }
  
  nav ul {
    flex-direction: column;
    gap: var(--spacing-sm);
  }
  
  .theme-switcher {
    flex-wrap: wrap;
  }
}

@media (max-width: 480px) {
  html { font-size: 14px; }
  
  button,
  input[type="submit"],
  input[type="reset"],
  input[type="button"] {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
  }
  
  .card { padding: var(--spacing-md); }
}

/* ---------- Accessibility ---------- */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

:focus-visible {
  outline: 2px solid var(--accent-color);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
  background: var(--text-muted);
  border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* ---------- Print ---------- */
@media print {
  body { background: white; color: black; }
  .theme-switcher { display: none; }
  .card { box-shadow: none; border: 1px solid #ddd; }
  a { color: black; }
}