/* ==========================================================================
   RICCOVA BOOKSTORE - MODERN CSS ARCHITECTURE
   Modern Features: OKLCH Colors, CSS Nesting, Light/Dark Modes, 
   Container Queries, Native Transitions & Utility Systems
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. COLOR SCHEME & DESIGN TOKENS
   -------------------------------------------------------------------------- */
:root {
  /* Enable Automatic Light/Dark Engine */
  color-scheme: light dark;

  /* Dynamic Light/Dark Color Engine using OKLCH */
  --surface-1: light-dark(oklch(99% 0.005 240), oklch(14% 0.015 240));
  --surface-2: light-dark(oklch(100% 0 0), oklch(20% 0.02 240));
  --surface-3: light-dark(oklch(96% 0.01 240), oklch(26% 0.025 240));

  --text-main: light-dark(oklch(20% 0.025 240), oklch(96% 0.01 240));
  --text-muted: light-dark(oklch(48% 0.03 240), oklch(72% 0.02 240));

  /* Brand Palette (Predictable OKLCH perception) */
  --primary: oklch(55% 0.22 255);
  --primary-hover: oklch(48% 0.22 255);
  --primary-subtle: oklch(93% 0.04 255 / 0.5);

  /* Status Colors */
  --success: oklch(62% 0.17 145);
  --success-bg: oklch(94% 0.05 145);
  --warning: oklch(75% 0.15 75);
  --warning-bg: oklch(96% 0.06 75);
  --danger: oklch(63% 0.21 25);
  --danger-bg: oklch(95% 0.06 25);

  /* Borders & Shadows */
  --border: light-dark(oklch(92% 0.01 240), oklch(30% 0.02 240));
  --border-focus: var(--primary);
  
  --shadow-sm: 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.08), 0 2px 4px -2px rgb(0 0 0 / 0.05);
  --shadow-lg: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.05);

  /* Standard Geometry */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  /* Animation Tokens */
  --ease-elastic: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-smooth: cubic-bezier(0.16, 1, 0.3, 1);
  --transition-fast: 150ms var(--ease-smooth);
  --transition-normal: 250ms var(--ease-smooth);
}

/* --------------------------------------------------------------------------
   2. MODERN RESET & BASE STYLES
   -------------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  scrollbar-gutter: stable;
}

body {
  font-family: 'Inter Variable', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.5;
  color: var(--text-main);
  background-color: var(--surface-1);
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
  min-block-size: 100vh;
  -webkit-font-smoothing: antialiased;
}

img, picture, video, canvas, svg {
  display: block;
  max-inline-size: 100%;
}

/* --------------------------------------------------------------------------
   3. LAYOUT & CONTAINERS (Container Queries Enabled)
   -------------------------------------------------------------------------- */
.container {
  max-inline-size: min(100% - 2rem, 1280px);
  margin-inline: auto;
  container-type: inline-size;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
  gap: 1.5rem;
  margin-block: 2rem;
}

/* --------------------------------------------------------------------------
   4. CARDS, METRICS & ELEVATED COMPONENTS
   -------------------------------------------------------------------------- */
.stat-card, 
.book-card, 
.metric-card,
.panel-card,
.feature-item {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: 
    transform var(--transition-normal), 
    box-shadow var(--transition-normal), 
    border-color var(--transition-normal);

  &:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
  }

  &:focus-within {
    outline: 2px solid var(--border-focus);
    outline-offset: 2px;
  }
}

.stat-card, .metric-card {
  padding: 1.5rem;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  gap: 1.25rem;

  & .metric-icon {
    inline-size: 56px;
    block-size: 56px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;

    &.icon-blue { background: oklch(92% 0.04 255); color: var(--primary); }
    &.icon-green { background: var(--success-bg); color: var(--success); }
    &.icon-orange { background: var(--warning-bg); color: var(--warning); }
    &.icon-purple { background: oklch(93% 0.05 300); color: oklch(55% 0.22 300); }
  }

  & h3 {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-block-end: 0.25rem;
  }

  & .value {
    font-size: clamp(1.5rem, 1rem + 1.5vw, 2rem);
    font-weight: 800;
    color: var(--text-main);
    line-height: 1.1;
  }
}

/* --------------------------------------------------------------------------
   5. FORMS & DROPZONE CONTROLS (For add_book.php & edit_book.php)
   -------------------------------------------------------------------------- */
.form-group {
  margin-block-end: 1.25rem;

  & label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    font-size: 0.9rem;
    margin-block-end: 0.5rem;
    color: var(--text-main);
  }
}

.form-control {
  inline-size: 100%;
  padding: 0.75rem 1rem;
  background: var(--surface-2);
  color: var(--text-main);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);

  &:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--primary-subtle);
  }
}

.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  text-align: center;
  background: var(--surface-3);
  position: relative;
  cursor: pointer;
  transition: border-color var(--transition-fast), background-color var(--transition-fast);

  &:hover, &.dragover {
    border-color: var(--primary);
    background: var(--primary-subtle);
  }

  & input[type="file"] {
    position: absolute;
    inset: 0;
    inline-size: 100%;
    block-size: 100%;
    opacity: 0;
    cursor: pointer;
  }
}

/* --------------------------------------------------------------------------
   6. TABLES & DATA STRUCTURES
   -------------------------------------------------------------------------- */
.table-wrapper {
  inline-size: 100%;
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface-2);
  box-shadow: var(--shadow-sm);
}

table {
  inline-size: 100%;
  border-collapse: collapse;
  text-align: start;

  & th {
    background: var(--surface-3);
    padding: 1rem 1.25rem;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-block-end: 1px solid var(--border);
  }

  & td {
    padding: 1rem 1.25rem;
    border-block-end: 1px solid var(--border);
    transition: background-color var(--transition-fast);
  }

  & tbody tr {
    &:last-child td {
      border-block-end: none;
    }

    &:hover td {
      background-color: var(--surface-3);
    }
  }
}

/* --------------------------------------------------------------------------
   7. UI CONTROLS & BADGES
   -------------------------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  padding: 0.25em 0.75em;
  border-radius: var(--radius-full);
  font-size: 0.775rem;
  font-weight: 600;

  &.badge-success {
    background: var(--success-bg);
    color: var(--success);
  }

  &.badge-pending {
    background: var(--warning-bg);
    color: var(--warning);
  }

  &.badge-danger {
    background: var(--danger-bg);
    color: var(--danger);
  }
}

.btn, 
.action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: var(--primary);
  color: oklch(100% 0 0);
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: 
    background-color var(--transition-fast), 
    transform var(--transition-fast) var(--ease-elastic), 
    box-shadow var(--transition-fast);

  &:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px oklch(from var(--primary) l c h / 0.3);
  }

  &:active {
    transform: translateY(0);
  }
}

/* --------------------------------------------------------------------------
   8. GLASSMORPHISM ENGINE
   -------------------------------------------------------------------------- */
.glass {
  background: light-dark(rgba(255, 255, 255, 0.65), rgba(20, 25, 35, 0.65));
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border: 1px solid light-dark(rgba(255, 255, 255, 0.4), rgba(255, 255, 255, 0.08));
}

/* --------------------------------------------------------------------------
   9. NATIVE CONTAINER QUERIES & SCROLLBARS
   -------------------------------------------------------------------------- */
@container (max-width: 640px) {
  .stats-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
}

* {
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}