/* Design System & Global Styles for Perpustakaan SMGKKK (Model SMGKKK) */
:root {
  /* Font Family */
  --font-title: 'Outfit', 'Inter', sans-serif;
  --font-body: 'Inter', sans-serif;

  /* Theme Tokens - Light Mode Default */
  --bg-primary: #f8fafc;
  --bg-secondary: #f1f5f9;
  --bg-card: #ffffff;
  --bg-card-hover: #fafafa;
  --border-color: #e2e8f0;
  
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  
  --primary: #4f46e5; /* Indigo 600 */
  --primary-hover: #4338ca;
  --primary-light: #e0e7ff;
  --primary-light-hover: #c7d2fe;
  
  --secondary: #8b5cf6;
  --secondary-light: #f5f3ff;
  
  /* Status Colors */
  --color-hadir: #10b981;
  --color-hadir-light: #d1fae5;
  --color-absen: #ef4444;
  --color-absen-light: #fee2e2;
  --color-izin: #f59e0b;
  --color-izin-light: #fef3c7;
  --color-sakit: #3b82f6;
  --color-sakit-light: #dbeafe;

  --accent-rose: #f43f5e;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-premium: 0 20px 25px -5px rgba(79, 70, 229, 0.1), 0 10px 10px -5px rgba(79, 70, 229, 0.04);
  
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme='dark'] {
  /* Theme Tokens - Dark Mode */
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-card: #1e293b;
  --bg-card-hover: #334155;
  --border-color: #334155;
  
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #64748b;
  
  --primary: #6366f1; /* Indigo 500 */
  --primary-hover: #4f46e5;
  --primary-light: #312e81;
  --primary-light-hover: #3730a3;
  
  --secondary: #a78bfa;
  --secondary-light: #2e1065;
  
  --color-hadir: #34d399;
  --color-hadir-light: #064e3b;
  --color-absen: #f87171;
  --color-absen-light: #7f1d1d;
  --color-izin: #fbbf24;
  --color-izin-light: #78350f;
  --color-sakit: #60a5fa;
  --color-sakit-light: #1e3a8a;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.5);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -2px rgba(0, 0, 0, 0.3);
  --shadow-premium: 0 20px 25px -5px rgba(99, 102, 241, 0.15), 0 10px 10px -5px rgba(99, 102, 241, 0.05);
}

/* CSS Resets & Base Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-body);
  background-color: #0b0f19; /* Latar belakang luar shell */
  color: var(--text-primary);
  line-height: 1.5;
  overflow-x: hidden;
  transition: background-color var(--transition-normal), color var(--transition-normal);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-title);
  font-weight: 700;
  letter-spacing: -0.02em;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  outline: none;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  transition: all var(--transition-fast);
}

a {
  color: inherit;
  text-decoration: none;
}

/* Toast/Notification Bar */
.toast {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  font-weight: 500;
  width: 90%;
  max-width: 400px;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.toast.hidden {
  transform: translate(-50%, -100px);
  opacity: 0;
  pointer-events: none;
}
.toast.success { border-left: 4px solid var(--color-hadir); }
.toast.success i { color: var(--color-hadir); }
.toast.error { border-left: 4px solid var(--color-absen); }
.toast.error i { color: var(--color-absen); }
.toast.info { border-left: 4px solid var(--primary); }
.toast.info i { color: var(--primary); }

/* Shell Container (Model SMGKKK) */
.container {
  max-width: 500px; /* Mobile focused shell */
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-primary);
  position: relative;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.35);
  padding-bottom: 74px; /* bottom-nav clearance */
  transition: background-color var(--transition-normal);
}

/* Login Screen Layout */
.login-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 16px;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 30px 24px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
  text-align: center;
  transition: background-color var(--transition-normal), border-color var(--transition-normal);
}

.login-logo {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  width: 56px;
  height: 56px;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  font-size: 24px;
  margin-bottom: 16px;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25);
}

.login-header h1 {
  font-size: 26px;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.login-header p {
  color: var(--text-secondary);
  font-size: 13px;
  margin-bottom: 24px;
}

.login-footer {
  margin-top: 20px;
  font-size: 11px;
  color: var(--text-muted);
}

/* App Header Bar */
.app-header {
  padding: 14px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
  transition: background-color var(--transition-normal), border-color var(--transition-normal);
}

.app-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-header-left .user-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background-color: var(--primary-light);
  color: var(--primary);
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 16px;
  border: 1px solid var(--border-color);
}

.app-title-group h1 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.app-title-group span {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: capitalize;
}

.header-actions {
  display: flex;
  gap: 8px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  color: var(--text-secondary);
  background-color: var(--bg-secondary);
  transition: all var(--transition-fast);
}

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

/* Simulated Date Subbar */
.sim-date-subbar {
  background-color: var(--primary-light);
  color: var(--primary);
  padding: 8px 20px;
  font-size: 11px;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
}
.sim-date-subbar .day-status {
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 10px;
  text-transform: uppercase;
}
.sim-date-subbar .day-status.sunday {
  background-color: var(--color-hadir);
  color: white;
}
.sim-date-subbar .day-status.not-sunday {
  background-color: var(--color-izin);
  color: white;
}

/* App Content Wrapper */
.app-content {
  flex-grow: 1;
  padding: 16px;
  overflow-y: auto;
}

.content-section {
  animation: fadeIn 0.25s ease-out;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.section-header h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}

/* Cards */
.card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
  transition: background-color var(--transition-normal), border-color var(--transition-normal);
}

.card h3 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text-primary);
}

/* Form Controls */
.form-group {
  margin-bottom: 14px;
  text-align: left;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

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

.input-wrapper i {
  position: absolute;
  left: 14px;
  color: var(--text-muted);
}

.input-wrapper input {
  padding-left: 36px;
}

input, select, textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  transition: all var(--transition-fast);
}

input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  background: var(--bg-card);
  box-shadow: 0 0 0 2px var(--primary-light);
}

.input-hint {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  border: none;
  transition: all var(--transition-fast);
}

.btn-sm {
  padding: 6px 10px;
  font-size: 11px;
}

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

.btn-secondary {
  background-color: var(--bg-secondary);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}
.btn-secondary:hover {
  background-color: var(--border-color);
}

.btn-success {
  background-color: var(--color-hadir);
  color: white;
}
.btn-success:hover {
  background-color: #0d9488;
}

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

.btn-block {
  display: flex;
  width: 100%;
}

.py-3 {
  padding-top: 12px;
  padding-bottom: 12px;
}

/* Divider */
.divider {
  display: flex;
  align-items: center;
  text-align: center;
  margin: 16px 0;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
}
.divider::before, .divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid var(--border-color);
}
.divider:not(:empty)::before { margin-right: 10px; }
.divider:not(:empty)::after { margin-left: 10px; }

.input-group {
  display: flex;
  gap: 8px;
}
.input-group input {
  flex-grow: 1;
}

/* QR Scanner */
.qr-scanner-box {
  width: 100%;
  aspect-ratio: 1;
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-secondary);
}
.qr-scanner-box video {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
}

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 10px;
  text-align: center;
  color: var(--text-muted);
}
.empty-state i {
  font-size: 44px;
  color: var(--primary);
  margin-bottom: 12px;
  opacity: 0.8;
}
.empty-state p {
  font-size: 12px;
  max-width: 250px;
}

/* Child Card profile */
.child-profile-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px;
  background-color: var(--bg-secondary);
  border-radius: var(--radius-md);
  margin-bottom: 14px;
}
.child-profile-card .profile-avatar {
  width: 48px;
  height: 48px;
  background-color: var(--primary);
  border-radius: var(--radius-sm);
  display: flex;
  justify-content: center;
  align-items: center;
  color: white;
  font-size: 20px;
}
.child-profile-card h2 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}
.profile-badge-row {
  display: flex;
  gap: 6px;
  margin-top: 2px;
  margin-bottom: 2px;
}
.thn-ajaran-label {
  font-size: 11px;
  color: var(--text-muted);
}

/* Borrow alert */
.borrow-status-alert {
  padding: 12px;
  border-radius: var(--radius-md);
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
  font-size: 12px;
}
.borrow-status-alert.allowed {
  background-color: var(--color-hadir-light);
  color: var(--color-hadir);
  border: 1px solid rgba(16, 185, 129, 0.1);
}
.borrow-status-alert.blocked {
  background-color: var(--color-absen-light);
  color: var(--color-absen);
  border: 1px solid rgba(239, 68, 68, 0.1);
}
.borrow-status-alert h4 {
  font-size: 13px;
  font-weight: 700;
}

.book-scanner-buttons {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.inline-manual-form {
  display: flex;
  gap: 6px;
  flex-grow: 1;
}

/* Active Book Loan Card */
.loan-item-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px;
  margin-bottom: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: all var(--transition-fast);
}
.loan-item-info h5 {
  font-size: 13px;
  font-weight: 600;
}
.loan-item-meta {
  font-size: 11px;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin-top: 4px;
}
.loan-item-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
}
.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-accent { background: var(--secondary-light); color: var(--secondary); }
.badge-success { background: var(--color-hadir-light); color: var(--color-hadir); }
.badge-warning { background: var(--color-izin-light); color: var(--color-izin); }
.badge-danger { background: var(--color-absen-light); color: var(--color-absen); }

/* Table design (optimized for mobile shell) */
.table-toolbar {
  margin-bottom: 12px;
}
.search-box {
  position: relative;
}
.search-box i {
  position: absolute;
  left: 12px;
  top: 12px;
  color: var(--text-muted);
}
.search-box input {
  padding-left: 32px;
  font-size: 12px;
}

.table-container {
  overflow-x: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.table th, .table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-color);
}
.table th {
  font-family: var(--font-title);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-weight: 600;
  text-align: left;
}
.table tbody tr:last-child td {
  border-bottom: none;
}
.table tbody tr:hover {
  background-color: var(--bg-card-hover);
}

/* Bottom Tab Navigation Bar (Model SMGKKK) */
.bottom-nav {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 64px;
  background-color: var(--bg-card);
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 100;
  padding: 0 4px;
  border-bottom-left-radius: inherit;
  border-bottom-right-radius: inherit;
  box-shadow: 0 -4px 10px rgba(0,0,0,0.05);
}

.bottom-nav .nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 20%;
  height: 100%;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 600;
  position: relative;
  transition: all var(--transition-fast);
}

.bottom-nav .nav-item i {
  font-size: 16px;
  margin-bottom: 4px;
}

.bottom-nav .nav-item.active {
  color: var(--primary);
}

.nav-icon-container {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 22px;
}

.nav-indicator {
  position: absolute;
  top: 0;
  width: 28px;
  height: 3px;
  background-color: var(--primary);
  border-radius: var(--radius-full);
  opacity: 0;
  transition: all var(--transition-fast);
}
.nav-item.active .nav-indicator {
  opacity: 1;
}

/* Laporan Tab Bar */
.laporan-tabs {
  display: flex;
  background-color: var(--bg-secondary);
  padding: 4px;
  border-radius: var(--radius-md);
  margin-bottom: 14px;
}
.report-tab {
  flex: 1;
  padding: 8px 4px;
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.report-tab i {
  font-size: 14px;
}
.report-tab.active {
  background-color: var(--bg-card);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.report-sub-view {
  animation: fadeIn 0.2s ease-out;
}
.report-actions-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.report-actions-row h3 {
  font-size: 13px;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.stat-icon {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 14px;
}
.stat-info h4 {
  font-size: 13px;
  font-weight: 700;
}
.stat-info p {
  font-size: 9px;
  color: var(--text-muted);
}

.filter-controls {
  display: flex;
  align-items: center;
}

/* Modals */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1000;
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(4px);
  padding: 16px;
}
.modal.hidden {
  display: none !important;
}
.modal-content {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 400px;
  padding: 20px;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.2);
}
.modal-small {
  max-width: 320px;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.modal-header h3 {
  font-size: 15px;
}
.btn-close-modal {
  font-size: 20px;
  color: var(--text-muted);
}
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

.qr-print-preview-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px;
  background: white;
  color: black;
  border-radius: var(--radius-md);
  border: 1px solid #e2e8f0;
}
#qr-code-print-canvas {
  width: 160px !important;
  height: 160px !important;
}

/* Utilities */
.hidden { display: none !important; }
.text-center { text-align: center; }
.text-warning { color: var(--color-izin); }
.text-primary-color { color: var(--primary); }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.ml-1 { margin-left: 4px; }
.mx-2 { margin-left: 8px; margin-right: 8px; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

/* PRINT OUT STYLING */
@media print {
  body {
    background: white !important;
    color: black !important;
  }
  .container {
    max-width: 100% !important;
    width: 100% !important;
    box-shadow: none !important;
    padding-bottom: 0 !important;
    background: white !important;
  }
  .app-header, .bottom-nav, .sim-date-subbar, .toast, .modal, .section-header button, .report-actions-row button {
    display: none !important;
  }
  .app-content {
    padding: 0 !important;
  }
  .content-section {
    display: none !important;
  }
  #view-laporan, #view-laporan .report-sub-view:not(.hidden) {
    display: block !important;
  }
  .card {
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    padding: 0 !important;
  }
  .table th {
    background: #f1f5f9 !important;
    color: black !important;
    border-bottom: 2px solid black !important;
  }
  .table td {
    color: black !important;
    border-bottom: 1px solid #e2e8f0 !important;
  }
  
  /* Print QR */
  #modal-print-qr {
    display: flex !important;
    position: relative !important;
    background: white !important;
    width: 100% !important;
    border: none !important;
    padding-top: 40px !important;
  }
  #modal-print-qr .modal-content {
    box-shadow: none !important;
    border: none !important;
    max-width: 100% !important;
    background: white !important;
  }
  #modal-print-qr .modal-header, #modal-print-qr .modal-footer {
    display: none !important;
  }
}
