/* Custom Google Fonts imports */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Playfair+Display:ital,wght@0,600;0,700;1,500&display=swap');

:root {
  /* HSL Tailored Color Palette - Velvet Indigo Theme */
  --bg-main: hsl(230, 25%, 8%);
  --bg-surface: rgba(20, 20, 35, 0.65);
  --bg-sidebar: rgba(13, 13, 23, 0.95);
  --outline-glow: rgba(99, 102, 241, 0.15);
  
  --primary: hsl(250, 85%, 65%);
  --primary-hover: hsl(250, 85%, 72%);
  --secondary: hsl(270, 75%, 60%);
  --accent: hsl(330, 85%, 60%);
  --success: hsl(142, 70%, 45%);
  --warning: hsl(38, 92%, 50%);
  --danger: hsl(350, 80%, 55%);
  
  --text-primary: hsl(210, 25%, 98%);
  --text-secondary: hsl(220, 15%, 70%);
  --text-muted: hsl(220, 10%, 45%);
  
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-serif: 'Playfair Display', Georgia, serif;
  
  --sidebar-width: 280px;
  --radius-xl: 20px;
  --radius-lg: 14px;
  --radius-md: 8px;
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --shadow-premium: 0 10px 30px -10px rgba(0, 0, 0, 0.5), 0 1px 1px rgba(255, 255, 255, 0.05) inset;
  --glass-effect: backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
}

/* Base Styles & Reset */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-main);
  color: var(--text-primary);
  font-family: var(--font-sans);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.5;
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(99, 102, 241, 0.15) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(168, 85, 247, 0.1) 0%, transparent 45%);
  background-attachment: fixed;
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-main);
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--primary);
}

/* Page Layout */
.app-container {
  display: flex;
  min-height: 100vh;
}

/* Glassmorphic Sidebar */
aside.sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-sidebar);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  padding: 2.5rem 1.5rem;
  transition: var(--transition-smooth);
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 3.5rem;
}

.brand-logo {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

.brand-name {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 1.35rem;
  letter-spacing: -0.02em;
  background: linear-gradient(to right, var(--text-primary), hsl(250, 100%, 90%));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.user-profile-badge {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-lg);
  margin-bottom: 2.5rem;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--outline-glow);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: var(--primary);
  border: 2px solid rgba(255, 255, 255, 0.1);
}

.user-details {
  display: flex;
  flex-direction: column;
  text-align: left;
}

.user-name {
  font-weight: 600;
  font-size: 0.85rem;
}

.user-role {
  font-size: 0.7rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

nav.nav-menu {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex-grow: 1;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 1rem;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  border-radius: var(--radius-lg);
  transition: var(--transition-smooth);
  cursor: pointer;
  border: 1px solid transparent;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
}

.nav-link.active {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(168, 85, 247, 0.05));
  border: 1px solid rgba(99, 102, 241, 0.25);
  color: var(--text-primary);
  box-shadow: 0 4px 20px rgba(99, 102, 241, 0.05);
}

.nav-link svg {
  width: 20px;
  height: 20px;
  transition: var(--transition-smooth);
}

.nav-link.active svg {
  color: var(--primary);
}

.logout-btn {
  margin-top: auto;
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: hsl(0, 85%, 65%);
}

.logout-btn:hover {
  background: rgba(239, 68, 68, 0.1);
  color: hsl(0, 85%, 70%);
}

/* Main Content Area */
main.main-content {
  flex-grow: 1;
  margin-left: var(--sidebar-width);
  padding: 3rem 4rem;
  min-height: 100vh;
  transition: var(--transition-smooth);
}

/* View Headers */
header.view-header {
  margin-bottom: 3rem;
  text-align: left;
}

header.view-header h1 {
  font-family: var(--font-serif);
  font-size: 2.5rem;
  font-weight: 700;
  background: linear-gradient(to right, #fff, var(--text-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 0.5rem;
}

header.view-header p {
  color: var(--text-secondary);
  font-weight: 400;
}

/* Grid & Layout Units */
.grid-stats {
  display: grid;
  grid-template-cols: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.5rem;
  margin-bottom: 3rem;
}

/* Glassmorphic Card Widget */
.card-stat {
  background: var(--bg-surface);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-xl);
  padding: 1.5rem;
  box-shadow: var(--shadow-premium);
  display: flex;
  align-items: center;
  gap: 1.25rem;
  transition: var(--transition-smooth);
  position: relative;
  overflow: hidden;
  --glass-effect;
}

.card-stat::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--primary);
  opacity: 0.5;
}

.card-stat:hover {
  transform: translateY(-5px);
  border-color: rgba(99, 102, 241, 0.25);
  box-shadow: 0 15px 35px -10px rgba(99, 102, 241, 0.15);
}

.card-stat.stat-blue::before { background: var(--primary); }
.card-stat.stat-purple::before { background: var(--secondary); }
.card-stat.stat-orange::before { background: var(--warning); }
.card-stat.stat-emerald::before { background: var(--success); }

.stat-icon-wrapper {
  padding: 1rem;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.03);
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-stat.stat-blue .stat-icon-wrapper { color: var(--primary); background: rgba(99, 102, 241, 0.08); }
.card-stat.stat-purple .stat-icon-wrapper { color: var(--secondary); background: rgba(168, 85, 247, 0.08); }
.card-stat.stat-orange .stat-icon-wrapper { color: var(--warning); background: rgba(245, 158, 11, 0.08); }
.card-stat.stat-emerald .stat-icon-wrapper { color: var(--success); background: rgba(16, 185, 129, 0.08); }

.stat-icon-wrapper svg {
  width: 28px;
  height: 28px;
}

.stat-info {
  display: flex;
  flex-direction: column;
  text-align: left;
}

.stat-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-secondary);
  letter-spacing: 0.05em;
  margin-bottom: 0.25rem;
}

.stat-value {
  font-size: 1.85rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* Interactive tables and lists */
.section-panel {
  background: var(--bg-surface);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-premium);
  padding: 2rem;
  margin-bottom: 3rem;
  --glass-effect;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 1rem;
}

.panel-header h2 {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 600;
  text-align: left;
}

/* Forms & Inputs */
.auth-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
}

.auth-card {
  width: 100%;
  max-width: 440px;
  background: var(--bg-surface);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-xl);
  padding: 3rem;
  box-shadow: var(--shadow-premium);
  --glass-effect;
}

.form-group {
  margin-bottom: 1.5rem;
  display: flex;
  flex-direction: column;
  text-align: left;
}

.form-group label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-wrapper svg {
  position: absolute;
  left: 1rem;
  width: 18px;
  height: 18px;
  color: var(--text-muted);
}

.form-input {
  width: 100%;
  padding: 0.85rem 1rem 0.85rem 2.75rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-lg);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  outline: none;
  transition: var(--transition-smooth);
}

.form-input:focus {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--outline-glow);
}

.input-no-icon {
  padding-left: 1rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.85rem 1.5rem;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border: none;
  border-radius: var(--radius-lg);
  color: white;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-smooth);
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.25);
  outline: none;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
  background: linear-gradient(135deg, var(--primary-hover), var(--secondary));
}

.btn:active {
  transform: translateY(0);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  box-shadow: none;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: none;
}

.btn-danger {
  background: linear-gradient(135deg, var(--danger), hsl(350, 70%, 45%));
  box-shadow: 0 4px 15px rgba(239, 68, 68, 0.2);
}

.btn-danger:hover {
  background: linear-gradient(135deg, hsl(350, 85%, 60%), hsl(350, 70%, 40%));
  box-shadow: 0 6px 20px rgba(239, 68, 68, 0.35);
}

.btn-outline-danger {
  background: transparent;
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: hsl(350, 85%, 65%);
  box-shadow: none;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
}

.btn-outline-danger:hover {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.5);
  box-shadow: none;
}

.btn-sm {
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  border-radius: var(--radius-md);
}

/* Search bar control panel */
.search-controls {
  display: flex;
  gap: 1rem;
  margin-bottom: 2rem;
}

.search-controls .form-input {
  flex-grow: 1;
}

/* Beautiful custom Table design */
.table-container {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

table.premium-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.95rem;
}

table.premium-table th {
  background: rgba(255, 255, 255, 0.03);
  padding: 1rem 1.5rem;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

table.premium-table td {
  padding: 1.15rem 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
  vertical-align: middle;
}

table.premium-table tr:last-child td {
  border-bottom: none;
}

table.premium-table tr:hover td {
  background: rgba(255, 255, 255, 0.015);
}

/* Status Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  border-radius: 50px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.badge-success {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.2);
  color: hsl(142, 70%, 45%);
}

.badge-warning {
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.2);
  color: var(--warning);
}

.badge-danger {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: hsl(350, 80%, 60%);
}

.badge-info {
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.2);
  color: hsl(217, 90%, 60%);
}

/* Book Grid Layout */
.books-grid {
  display: grid;
  grid-template-cols: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
}

.book-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  transition: var(--transition-smooth);
  text-align: left;
}

.book-card:hover {
  transform: translateY(-3px);
  border-color: rgba(99, 102, 241, 0.2);
  background: rgba(255, 255, 255, 0.03);
}

.book-meta {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.book-category {
  font-size: 0.75rem;
  color: var(--primary);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.book-title {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
}

.book-author {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.book-stats {
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  padding-top: 1rem;
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.book-footer {
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

/* Admin Dashboard Elements */
.admin-row {
  display: grid;
  grid-template-cols: 1fr 340px;
  gap: 2rem;
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.view-section {
  animation: fadeIn 0.4s ease-out forwards;
}

.hidden {
  display: none !important;
}

/* Premium Toast Notification System */
.toast-container {
  position: fixed;
  top: 2rem;
  right: 2rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.toast {
  background: rgba(20, 20, 30, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 1rem 1.5rem;
  border-radius: var(--radius-lg);
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
  color: white;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 280px;
  animation: slideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  --glass-effect;
}

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

.toast-success { border-left: 4px solid var(--success); }
.toast-error { border-left: 4px solid var(--danger); }
.toast-info { border-left: 4px solid var(--primary); }

/* Responsive adjustments */
@media (max-width: 1024px) {
  .admin-row {
    grid-template-cols: 1fr;
  }
}

@media (max-width: 768px) {
  aside.sidebar {
    width: 80px;
    padding: 2rem 0.5rem;
    align-items: center;
  }
  .brand-name, .user-details, .nav-text {
    display: none;
  }
  .brand-section {
    justify-content: center;
    margin-bottom: 2rem;
  }
  .user-profile-badge {
    padding: 0.5rem;
    justify-content: center;
  }
  .nav-link {
    justify-content: center;
    padding: 0.85rem;
  }
  main.main-content {
    margin-left: 80px;
    padding: 2rem;
  }
}
