@import url("https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&family=Plus+Jakarta+Sans:wght@300;400;500;600;700&display=swap");

:root {
  --bg-dark: #09090b;
  --bg-card: rgba(18, 18, 22, 0.7);
  --bg-card-hover: rgba(24, 24, 28, 0.85);
  --accent: #6366f1;
  --accent-glow: rgba(99, 102, 241, 0.3);
  --accent-secondary: #a855f7;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --border: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.15);
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 12px;
  
  --shadow-sm: 0 4px 6px -1px rgb(0 0 0 / 0.1);
  --shadow-md: 0 10px 15px -3px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.2);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-dark);
  color: var(--text-primary);
  font-family: 'Plus Jakarta Sans', sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: hidden;
}

h1, h2, h3, h4, .brand-name {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
}

/* Base Styles */
button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

.hidden { display: none !important; }

/* Glow Background */
.glow-container {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  overflow: hidden;
}

.glow-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.15;
}

.glow-1 {
  width: 600px;
  height: 600px;
  background: var(--accent);
  top: -200px;
  left: -100px;
  animation: float 20s infinite alternate;
}

.glow-2 {
  width: 500px;
  height: 500px;
  background: var(--accent-secondary);
  bottom: -100px;
  right: -50px;
  animation: float 25s infinite alternate-reverse;
}

.glow-3 {
  width: 300px;
  height: 300px;
  background: var(--success);
  top: 40%;
  left: 30%;
  opacity: 0.05;
}

@keyframes float {
  from { transform: translate(0, 0); }
  to { transform: translate(50px, 30px); }
}

/* Navbar */
.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px 5%;
  background: rgba(9, 9, 11, 0.8);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid var(--border);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.logo-box {
  width: 48px;
  height: 48px;
  background: var(--accent);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 20px var(--accent-glow);
}

.logo-icon { color: white; width: 28px; height: 28px; }

.brand-text { display: flex; flex-direction: column; }
.brand-name { font-size: 24px; letter-spacing: -0.5px; }
.accent-text { color: var(--accent); }
.brand-tagline { font-size: 11px; text-transform: uppercase; color: var(--text-muted); letter-spacing: 2px; }

.nav-links { display: flex; gap: 12px; }

/* Main Container */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 40px 5%;
  display: flex;
  flex-direction: column;
  gap: 40px;
}

/* Dashboard Grid */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 24px;
}

.hero-card {
  background: radial-gradient(circle at top right, rgba(99, 102, 241, 0.15), transparent), var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 48px;
  display: flex;
  align-items: center;
  backdrop-filter: blur(8px);
}

.hero-title { font-size: 48px; line-height: 1.1; margin-bottom: 20px; }
.hero-desc { font-size: 18px; color: var(--text-secondary); max-width: 500px; margin-bottom: 32px; }

.hero-actions { display: flex; gap: 16px; }

.stats-sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.stat-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 20px;
  backdrop-filter: blur(4px);
  transition: transform 0.3s ease;
}

.stat-box:hover { transform: translateY(-4px); }

.stat-icon {
  width: 52px;
  height: 52px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
}

.stat-label { font-size: 13px; color: var(--text-muted); text-transform: uppercase; font-weight: 600; }
.stat-value { font-size: 24px; color: var(--text-primary); }

/* Interface Grid */
.interface-grid {
  display: grid;
  grid-template-columns: 1fr 400px;
  gap: 24px;
  align-items: flex-start;
}

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  backdrop-filter: blur(10px);
}

.card-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header-main { display: flex; align-items: center; gap: 12px; }
.header-main i { color: var(--accent); width: 20px; }
.header-main h2 { font-size: 18px; font-weight: 600; }

.count-badge {
  background: rgba(255, 255, 255, 0.05);
  padding: 4px 12px;
  border-radius: 99px;
  font-size: 13px;
  color: var(--text-secondary);
}

/* Search Panel */
.search-panel {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: rgba(255, 255, 255, 0.01);
}

.search-row { display: flex; gap: 12px; }

.input-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
}

.input-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
}

.input-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  color: var(--text-muted);
  pointer-events: none;
}

.main-search .input-icon { top: 50%; } /* center since no label */

input, select, textarea {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  color: var(--text-primary);
  transition: all 0.2s ease;
}

.main-search input, .advanced-filters input { padding-left: 44px; }

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.06);
  box-shadow: 0 0 0 4px var(--accent-glow);
}

.year-range {
  display: flex;
  align-items: center;
  gap: 8px;
}

.year-range input { width: 100px; text-align: center; }
.range-sep { color: var(--text-muted); }

.sort-controls { display: grid; grid-template-columns: 1fr 1fr 100px; }
.select-group { display: flex; flex-direction: column; gap: 8px; }
.select-group label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; }

/* Book List */
.book-grid-list {
  padding: 0 24px 24px;
  display: grid;
  gap: 12px;
  max-height: 600px;
  overflow-y: auto;
}

.book-item {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  animation: fadeIn 0.4s ease forwards;
}

.book-item:hover {
  background: var(--bg-card-hover);
  border-color: rgba(99, 102, 241, 0.4);
  transform: translateX(6px);
}

.book-item.active {
  background: rgba(99, 102, 241, 0.1);
  border-color: var(--accent);
  box-shadow: 0 0 20px rgba(99, 102, 241, 0.1);
}

/* Rows are <button>s for keyboard access; reset native button chrome. */
button.book-item {
  width: 100%;
  color: inherit;
  font: inherit;
  text-align: left;
}

.book-item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.book-main-info { display: flex; flex-direction: column; gap: 4px; }
.book-title { font-weight: 600; font-size: 16px; }
.book-author { color: var(--text-secondary); font-size: 14px; }

.book-meta { display: flex; align-items: center; gap: 12px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; }
.status-dot.available { background: var(--success); box-shadow: 0 0 8px var(--success); }
.status-dot.borrowed { background: var(--warning); }
.status-dot.reserved { background: var(--accent); }
.status-dot.maintenance { background: var(--danger); }

.book-year { font-size: 13px; color: var(--text-muted); font-weight: 500; }

/* Side Panel */
.side-panel { display: flex; flex-direction: column; gap: 24px; }

/* Inspector */
.placeholder-state {
  padding: 60px 40px;
  text-align: center;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.placeholder-icon {
  width: 64px;
  height: 64px;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 24px;
}

.book-details { padding: 24px; display: flex; flex-direction: column; gap: 24px; }

.details-top { display: flex; gap: 20px; align-items: flex-start; }

.detail-cover {
  width: 100px;
  height: 140px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.detail-cover img { width: 100%; height: 100%; object-fit: cover; }
.cover-fallback { color: var(--text-muted); opacity: 0.5; }

.details-header { flex: 1; }
.details-header h3 { font-size: 20px; margin-bottom: 4px; line-height: 1.2; }
.detail-author { color: var(--text-secondary); margin-bottom: 12px; }

.status-tag {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.detail-info-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.info-item {
  background: rgba(255, 255, 255, 0.02);
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.info-label { display: block; font-size: 11px; color: var(--text-muted); text-transform: uppercase; margin-bottom: 4px; }
.info-value { font-size: 14px; font-weight: 600; color: var(--text-secondary); }

.detail-description p { font-size: 14px; color: var(--text-secondary); line-height: 1.6; }

.detail-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* Form */
#book-form { padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.form-row { display: flex; gap: 16px; }
.form-row.col-2 > div { flex: 1; }

.isbn-field { display: flex; gap: 8px; }
.isbn-field input { flex: 1; }

.btn-lookup {
  width: 46px;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  color: white;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-lookup:hover { background: var(--accent-secondary); transform: scale(1.05); }

textarea { resize: vertical; min-height: 80px; }

.form-actions { margin-top: 8px; }

/* Buttons */
.btn-primary, .btn-outline, .btn-ghost, .btn-danger, .btn-icon {
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: all 0.2s ease;
  border: none;
}

.full-width { width: 100%; }

.btn-primary {
  background: var(--accent);
  color: white;
  box-shadow: 0 4px 14px var(--accent-glow);
}

.btn-primary:hover {
  background: #4f46e5;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px var(--accent-glow);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-primary);
}

.btn-outline:hover { background: rgba(255, 255, 255, 0.05); border-color: var(--text-secondary); }

.btn-ghost {
  background: rgba(255, 255, 255, 0.01);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.btn-ghost:hover { background: rgba(255, 255, 255, 0.05); color: var(--text-primary); }

.btn-danger {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

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

.btn-icon {
  width: 38px; height: 38px; padding: 0;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-muted);
}
.btn-icon:hover { background: rgba(255, 255, 255, 0.08); color: var(--text-primary); }

.nav-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 8px;
  transition: color 0.2s;
}
.nav-btn:hover { color: var(--accent); }

.nav-link {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s;
}
.nav-link:hover { color: var(--text-primary); }

.nav-btn:focus-visible,
.nav-link:focus-visible,
.ms-footer a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
  border-radius: 4px;
}

.ms-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;
}

/* Author Footer */
.ms-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 5%;
}

.ms-footer {
  border-top: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 14px;
}

.ms-footer__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 24px;
  padding-top: 24px;
  padding-bottom: 32px;
}

.ms-footer__signature,
.ms-footer__links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
}

.ms-footer a {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.2s;
}
.ms-footer a:hover { color: var(--text-primary); text-decoration: underline; }

.ms-footer__meta {
  flex-basis: 100%;
  font-size: 12px;
}

/* Loader */
.list-status {
  padding: 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  color: var(--text-muted);
}

.loader-spinner {
  width: 24px;
  height: 24px;
  border: 2px solid rgba(99, 102, 241, 0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.loader-spinner-sm { width: 14px; height: 14px; border-width: 1px; }

.demo-notice {
  margin: -16px 0 24px;
  padding: 12px 16px;
  border: 1px solid var(--border-hover);
  border-left: 4px solid var(--warning);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 14px;
}

.demo-notice strong { color: var(--text-primary); }

button:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* Toast */
.toast-stack {
  position: fixed;
  bottom: 30px;
  right: 30px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 1000;
}

.toast {
  background: #1e1e24;
  color: white;
  padding: 16px 24px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-xl);
  border-left: 4px solid var(--accent);
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 300px;
  animation: slideIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.1); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.2); }

/* Responsive */
@media (max-width: 1200px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .stats-sidebar { flex-direction: row; flex-wrap: wrap; }
  .stat-box { flex: 1; min-width: 200px; }
  .interface-grid { grid-template-columns: 1fr; }
  .side-panel { order: -1; }
}

@media (max-width: 768px) {
  .hero-card { padding: 32px; }
  .hero-title { font-size: 32px; }
  .navbar { padding: 16px 5%; flex-wrap: wrap; gap: 12px; }
  .nav-links { align-items: center; }
  .nav-link__label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
  }
  .sort-controls { grid-template-columns: 1fr 1fr; }
  .sort-controls > :last-child { grid-column: span 2; }
}
