/* ============================================================
   Library Management System - Main Stylesheet
   ============================================================ */

:root {
  --primary:        #2563eb;
  --primary-dark:   #1d4ed8;
  --primary-light:  #eff6ff;
  --secondary:      #475569;
  --success:        #16a34a;
  --warning:        #d97706;
  --danger:         #dc2626;
  --sidebar-bg:     #0f172a;
  --sidebar-text:   #94a3b8;
  --sidebar-active: #2563eb;
  --topbar-bg:      #1e3a5f;
  --body-bg:        #f1f5f9;
  --card-bg:        #ffffff;
  --border:         #e2e8f0;
  --text:           #1e293b;
  --text-muted:     #64748b;
  --sidebar-w:      260px;
  --topbar-h:       64px;
  --radius:         12px;
  --shadow:         0 1px 3px rgba(0,0,0,.07), 0 4px 16px rgba(0,0,0,.05);
}

/* ---- Base ---- */
*, *::before, *::after { box-sizing: border-box; }

html { font-size: 15px; }

body {
  font-family: 'Vazirmatn', Tahoma, sans-serif;
  background: var(--body-bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }

/* ============================================================
   LAYOUT
   ============================================================ */
.wrapper {
  min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  right: 0;
  z-index: 100;
  transition: transform .3s ease;
}

.sidebar-header {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}

.logo-icon {
  width: 40px;
  height: 40px;
  background: var(--primary);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 20px;
  flex-shrink: 0;
}

.sidebar-brand {
  font-size: 1rem;
  font-weight: 700;
  color: #f8fafc;
  line-height: 1.2;
}
.sidebar-brand-sub {
  font-size: .72rem;
  color: var(--sidebar-text);
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 0;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 4px; }

.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 20px;
  color: var(--sidebar-text);
  font-size: .9rem;
  font-weight: 400;
  border-radius: 0;
  transition: all .2s;
  white-space: nowrap;
  border-right: 3px solid transparent;
}

.sidebar-nav .nav-link i {
  font-size: 1.1rem;
  width: 22px;
  flex-shrink: 0;
}

.sidebar-nav .nav-link:hover {
  color: #f8fafc;
  background: rgba(255,255,255,.06);
}

.sidebar-nav .nav-link.active {
  color: #fff;
  background: rgba(37,99,235,.2);
  border-right-color: var(--primary);
  font-weight: 600;
}

.nav-section-title {
  font-size: .7rem;
  font-weight: 700;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: .08em;
  padding: 16px 20px 6px;
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,.07);
}

.sidebar-footer .nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: .88rem;
  transition: background .2s;
}

.sidebar-footer .nav-link:hover {
  background: rgba(220,38,38,.15);
}

/* ---- Main Content ---- */
.main-content {
  margin-right: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---- Topbar ---- */
.topbar {
  height: var(--topbar-h);
  background: var(--topbar-bg);
  position: sticky;
  top: 0;
  z-index: 90;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}

.topbar .dropdown-menu {
  min-width: 200px;
  border: none;
  box-shadow: 0 8px 30px rgba(0,0,0,.12);
  border-radius: 10px;
  padding: 8px;
}

.topbar .dropdown-item {
  border-radius: 6px;
  font-size: .88rem;
  padding: 8px 12px;
}

/* ---- Content Area ---- */
.content-area {
  flex: 1;
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-header {
  background: transparent;
  border-bottom: 1px solid var(--border);
  padding: 16px 20px;
}

.card-header h6 {
  font-weight: 600;
  color: var(--text);
}

/* ============================================================
   STAT CARDS (Dashboard)
   ============================================================ */
.stat-card {
  display: flex;
  align-items: center;
  gap: 16px;
  background: #fff;
  border-radius: var(--radius);
  padding: 20px 24px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  transition: transform .2s, box-shadow .2s;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,.1);
}

.stat-icon {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  flex-shrink: 0;
}

.stat-card-blue  .stat-icon { background: #eff6ff; color: #2563eb; }
.stat-card-green .stat-icon { background: #f0fdf4; color: #16a34a; }
.stat-card-orange .stat-icon { background: #fffbeb; color: #d97706; }
.stat-card-red   .stat-icon { background: #fef2f2; color: #dc2626; }

.stat-number {
  font-size: 1.8rem;
  font-weight: 700;
  line-height: 1;
  color: var(--text);
}

.stat-label {
  font-size: .82rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ============================================================
   TOP BOOK ITEMS
   ============================================================ */
.top-book-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.top-book-item:last-child { border-bottom: none; }

.top-book-rank {
  width: 28px;
  height: 28px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .8rem;
  font-weight: 700;
  flex-shrink: 0;
}

.top-book-title {
  font-size: .88rem;
  font-weight: 500;
  color: var(--text);
}

.top-book-count {
  font-size: .75rem;
  color: var(--text-muted);
}

/* ============================================================
   TABLES
   ============================================================ */
.table {
  font-size: .88rem;
}

.table thead th {
  font-weight: 600;
  font-size: .8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  border-bottom: 2px solid var(--border);
  background: #f8fafc;
  padding: 12px 16px;
}

.table tbody td {
  padding: 12px 16px;
  vertical-align: middle;
  border-color: var(--border);
}

.table-hover tbody tr:hover {
  background: #f8fafc;
}

.table-danger-soft {
  background: #fef2f2 !important;
}

/* ============================================================
   FORMS
   ============================================================ */
.form-label {
  font-weight: 500;
  font-size: .88rem;
  color: var(--text);
  margin-bottom: 6px;
}

.form-label.required::after {
  content: ' *';
  color: var(--danger);
}

.form-control, .form-select {
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-family: 'Vazirmatn', Tahoma, sans-serif;
  font-size: .9rem;
  padding: 10px 14px;
  transition: border-color .2s, box-shadow .2s;
}

.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
  outline: none;
}

.input-group-text {
  background: #f8fafc;
  border: 1.5px solid var(--border);
  color: var(--text-muted);
  font-size: .9rem;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  font-family: 'Vazirmatn', Tahoma, sans-serif;
  font-weight: 500;
  border-radius: 8px;
  transition: all .2s;
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
}

.btn-primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(37,99,235,.35);
}

.btn-sm { padding: 5px 10px; font-size: .82rem; }

/* ============================================================
   BADGES
   ============================================================ */
.badge {
  font-family: 'Vazirmatn', Tahoma, sans-serif;
  font-weight: 500;
  font-size: .75rem;
  padding: 4px 10px;
  border-radius: 6px;
}

/* ============================================================
   REPORT STAT CARDS
   ============================================================ */
.report-stat-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  box-shadow: var(--shadow);
}

.rs-label {
  font-size: .78rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 8px;
}

.rs-value {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 4px;
}

.rs-sub {
  font-size: .78rem;
  color: var(--text-muted);
}

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-body {
  background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 50%, #0f172a 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-container {
  width: 100%;
  max-width: 440px;
}

.login-card {
  background: #fff;
  border-radius: 20px;
  padding: 40px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-icon {
  width: 70px;
  height: 70px;
  background: linear-gradient(135deg, var(--primary), #1e40af);
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 2rem;
  margin: 0 auto 16px;
  box-shadow: 0 8px 24px rgba(37,99,235,.35);
}

.login-logo h2 {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}

.login-hint {
  text-align: center;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.toggle-password {
  cursor: pointer;
}

/* ============================================================
   ALERTS
   ============================================================ */
.alert {
  border-radius: 10px;
  border: none;
  font-size: .9rem;
}

.alert-success {
  background: #f0fdf4;
  color: #166534;
  border-right: 4px solid #16a34a;
}

.alert-danger {
  background: #fef2f2;
  color: #991b1b;
  border-right: 4px solid #dc2626;
}

.alert-warning {
  background: #fffbeb;
  color: #92400e;
  border-right: 4px solid #d97706;
}

.alert-info {
  background: #eff6ff;
  color: #1e40af;
  border-right: 4px solid #2563eb;
}

/* ============================================================
   MODAL
   ============================================================ */
.modal-content {
  border-radius: 16px;
  border: none;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
}

/* ============================================================
   CODE
   ============================================================ */
code {
  background: #f1f5f9;
  color: var(--primary);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: .85em;
}

/* ============================================================
   PRINT
   ============================================================ */
@media print {
  .sidebar, .topbar, .btn, .no-print { display: none !important; }
  .main-content { margin: 0 !important; }
  .card { box-shadow: none; border: 1px solid #ccc; }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-content {
    margin-right: 0;
  }

  .stat-card {
    padding: 16px;
  }

  .stat-number {
    font-size: 1.4rem;
  }

  .content-area {
    padding: 16px !important;
  }
}

/* Overlay for mobile sidebar */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 99;
}

.sidebar-overlay.active {
  display: block;
}
