/* ============================================
   Sistem Inventaris SMP Fatahillah
   Design System v1.0
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');

/* ---- CSS Variables ---- */
:root {
  /* Primary Palette - Deep Indigo/Purple */
  --primary-50: #eef2ff;
  --primary-100: #e0e7ff;
  --primary-200: #c7d2fe;
  --primary-300: #a5b4fc;
  --primary-400: #818cf8;
  --primary-500: #6366f1;
  --primary-600: #4f46e5;
  --primary-700: #4338ca;
  --primary-800: #3730a3;
  --primary-900: #312e81;

  /* Accent Palette - Cyan */
  --accent-400: #22d3ee;
  --accent-500: #06b6d4;
  --accent-600: #0891b2;

  /* Neutral */
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;
  --gray-950: #020617;

  /* Status Colors */
  --status-baik: #10b981;
  --status-baik-bg: rgba(16, 185, 129, 0.12);
  --status-rusak-ringan: #f59e0b;
  --status-rusak-ringan-bg: rgba(245, 158, 11, 0.12);
  --status-rusak-berat: #ef4444;
  --status-rusak-berat-bg: rgba(239, 68, 68, 0.12);
  --status-hilang: #8b5cf6;
  --status-hilang-bg: rgba(139, 92, 246, 0.12);
  --status-dipinjam: #06b6d4;
  --status-dipinjam-bg: rgba(6, 182, 212, 0.12);

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.08);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.15), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  --shadow-glass: 0 8px 32px rgba(0, 0, 0, 0.12);

  /* Glass */
  --glass-bg: rgba(255, 255, 255, 0.08);
  --glass-border: rgba(255, 255, 255, 0.12);
  --glass-bg-light: rgba(255, 255, 255, 0.75);
  --glass-border-light: rgba(255, 255, 255, 0.6);

  /* Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-2xl: 24px;
  --radius-full: 9999px;

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Dark theme vars (Default) */
  --bg-primary: var(--gray-950);
  --bg-secondary: var(--gray-900);
  --bg-card: var(--gray-800);
  --bg-card-hover: var(--gray-700);
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --border-color: rgba(255, 255, 255, 0.08);
  --input-bg: rgba(255, 255, 255, 0.06);
  --input-border: rgba(255, 255, 255, 0.12);
  --input-focus: var(--primary-500);
  --glass-bg: rgba(255, 255, 255, 0.08);
  --glass-border: rgba(255, 255, 255, 0.12);
  --gradient-bg-1: var(--gray-950);
  --gradient-bg-2: #1a1033;
  --glow-1: rgba(99, 102, 241, 0.12);
  --glow-2: rgba(6, 182, 212, 0.08);
}

/* ---- Light Theme Variables ---- */
[data-theme='light'] {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f5f9;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --border-color: rgba(0, 0, 0, 0.08);
  --input-bg: #ffffff;
  --input-border: #cbd5e1;
  --input-focus: var(--primary-500);
  --glass-bg: rgba(255, 255, 255, 0.8);
  --glass-border: rgba(0, 0, 0, 0.08);
  --gradient-bg-1: #f8fafc;
  --gradient-bg-2: #e0e7ff;
  --glow-1: rgba(99, 102, 241, 0.08);
  --glow-2: rgba(6, 182, 212, 0.06);
}

/* ---- Reset ---- */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color var(--transition-base), color var(--transition-base);
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: var(--primary-400);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--primary-300);
}

/* ---- Background Gradient ---- */
.bg-gradient {
  background: linear-gradient(135deg, var(--gradient-bg-1) 0%, var(--gradient-bg-2) 50%, var(--gradient-bg-1) 100%);
  position: relative;
}

.bg-gradient::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background:
    radial-gradient(ellipse 600px 400px at 15% 20%, var(--glow-1) 0%, transparent 70%),
    radial-gradient(ellipse 500px 300px at 85% 75%, var(--glow-2) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* ---- Theme Toggle Switch ---- */
.theme-switch-wrap {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 2000;
}

.theme-switch {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  box-shadow: var(--shadow-md);
  transition: all var(--transition-base);
}

.theme-switch:hover {
  transform: rotate(15deg) scale(1.1);
  background: var(--bg-card-hover);
}

.theme-switch .fa-sun {
  display: none;
}

.theme-switch .fa-moon {
  display: block;
}

[data-theme='light'] .theme-switch .fa-sun {
  display: block;
  color: #f59e0b;
}

[data-theme='light'] .theme-switch .fa-moon {
  display: none;
}

/* Photo Deletion State */
.photo-preview-item.marked-for-delete {
  border: 2px solid #ef4444 !important;
  position: relative;
}

.photo-preview-item.marked-for-delete img {
  opacity: 0.3;
  filter: grayscale(1);
}

.photo-preview-item.marked-for-delete::after {
  content: 'Dihapus';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #ef4444;
  color: #fff;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  z-index: 2;
  pointer-events: none;
}

.photo-preview-item.marked-for-delete .remove-photo {
  background: #10b981 !important;
}

.photo-preview-item.marked-for-delete .remove-photo i::before {
  content: "\f0e2";
  /* undo icon */
}


/* ---- Glass Card ---- */
.glass-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--shadow-glass);
  transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.glass-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-xl);
}

.glass-card-static {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--shadow-glass);
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  text-decoration: none;
  line-height: 1.4;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary-600), var(--primary-500));
  color: #fff;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.35);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--primary-500), var(--primary-400));
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.45);
  color: #fff;
}

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

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

.btn-success {
  background: linear-gradient(135deg, #059669, #10b981);
  color: #fff;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.35);
}

.btn-success:hover {
  box-shadow: 0 4px 16px rgba(16, 185, 129, 0.45);
  color: #fff;
}

.btn-danger {
  background: linear-gradient(135deg, #dc2626, #ef4444);
  color: #fff;
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.35);
}

.btn-danger:hover {
  box-shadow: 0 4px 16px rgba(239, 68, 68, 0.45);
  color: #fff;
}

.btn-warning {
  background: linear-gradient(135deg, #d97706, #f59e0b);
  color: #fff;
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.8rem;
}

.btn-lg {
  padding: 14px 28px;
  font-size: 1rem;
}

.btn-icon {
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: var(--radius-sm);
}

/* ---- Inputs ---- */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  letter-spacing: 0.02em;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 11px 16px;
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--text-primary);
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-sm);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  outline: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--primary-500);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.form-input::placeholder {
  color: var(--text-muted);
}

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 40px;
}

.form-select option {
  background: var(--gray-800);
  color: var(--text-primary);
}

.form-textarea {
  min-height: 100px;
  resize: vertical;
}

/* ---- Status Badge ---- */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.status-badge::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-baik {
  background: var(--status-baik-bg);
  color: var(--status-baik);
}

.status-baik::before {
  background: var(--status-baik);
}

.status-rusak-ringan {
  background: var(--status-rusak-ringan-bg);
  color: var(--status-rusak-ringan);
}

.status-rusak-ringan::before {
  background: var(--status-rusak-ringan);
}

.status-rusak-berat {
  background: var(--status-rusak-berat-bg);
  color: var(--status-rusak-berat);
}

.status-rusak-berat::before {
  background: var(--status-rusak-berat);
}

.status-hilang {
  background: var(--status-hilang-bg);
  color: var(--status-hilang);
}

.status-hilang::before {
  background: var(--status-hilang);
}

.status-dipinjam {
  background: var(--status-dipinjam-bg);
  color: var(--status-dipinjam);
}

.status-dipinjam::before {
  background: var(--status-dipinjam);
}

/* ---- Table ---- */
.data-table-container {
  overflow-x: auto;
  border-radius: var(--radius-lg);
}

.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.data-table thead th {
  background: rgba(255, 255, 255, 0.04);
  padding: 14px 16px;
  text-align: left;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.data-table tbody tr {
  transition: background var(--transition-fast);
}

.data-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.04);
}

.data-table tbody td {
  padding: 12px 16px;
  font-size: 0.875rem;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

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

/* ---- Page Header ---- */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 28px;
}

.page-title {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--text-primary), var(--primary-300));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ---- Container ---- */
.container {
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ---- Alerts ---- */
.alert {
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideDown 0.3s ease;
}

.alert-success {
  background: var(--status-baik-bg);
  color: var(--status-baik);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.alert-error {
  background: var(--status-rusak-berat-bg);
  color: var(--status-rusak-berat);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.alert-info {
  background: rgba(99, 102, 241, 0.12);
  color: var(--primary-400);
  border: 1px solid rgba(99, 102, 241, 0.2);
}

/* ---- Modal ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-base);
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  background: var(--gray-800);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 520px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  transform: translateY(20px) scale(0.95);
  transition: transform var(--transition-base);
}

.modal-overlay.active .modal-content {
  transform: translateY(0) scale(1);
}

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

.modal-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  transition: all var(--transition-fast);
}

.modal-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

/* ---- Pagination ---- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 20px 0;
}

.pagination a,
.pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  transition: all var(--transition-fast);
}

.pagination a {
  color: var(--text-secondary);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
}

.pagination a:hover {
  background: rgba(99, 102, 241, 0.15);
  color: var(--primary-400);
}

.pagination .active {
  background: var(--primary-600);
  color: #fff;
  border: none;
}

/* ---- Checkbox Custom ---- */
.custom-checkbox {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.custom-checkbox input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.custom-checkbox .checkmark {
  width: 20px;
  height: 20px;
  border: 2px solid var(--input-border);
  border-radius: 5px;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
}

.custom-checkbox input:checked~.checkmark {
  background: var(--primary-500);
  border-color: var(--primary-500);
}

.custom-checkbox input:checked~.checkmark::after {
  content: '✓';
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
}

/* ---- Empty State ---- */
.empty-state {
  text-align: center;
  padding: 60px 20px;
}

.empty-state i {
  font-size: 3rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.empty-state h3 {
  font-size: 1.1rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.empty-state p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ---- Loading Spinner ---- */
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--glass-border);
  border-top-color: var(--primary-500);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* ---- Animations ---- */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.5;
  }
}

.fade-in {
  animation: fadeIn 0.5s ease both;
}

.slide-up {
  animation: slideUp 0.5s ease both;
}

/* ---- Utility ---- */
.text-center {
  text-align: center;
}

.text-right {
  text-align: right;
}

.text-muted {
  color: var(--text-muted);
}

.text-secondary {
  color: var(--text-secondary);
}

.text-small {
  font-size: 0.8rem;
}

.mt-1 {
  margin-top: 8px;
}

.mt-2 {
  margin-top: 16px;
}

.mt-3 {
  margin-top: 24px;
}

.mb-1 {
  margin-bottom: 8px;
}

.mb-2 {
  margin-bottom: 16px;
}

.mb-3 {
  margin-bottom: 24px;
}

.flex {
  display: flex;
}

.flex-wrap {
  flex-wrap: wrap;
}

.items-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.gap-1 {
  gap: 8px;
}

.gap-2 {
  gap: 16px;
}

.gap-3 {
  gap: 24px;
}

.w-full {
  width: 100%;
}

.hidden {
  display: none !important;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .page-title {
    font-size: 1.4rem;
  }

  .container {
    padding: 0 16px;
  }

  .data-table thead th,
  .data-table tbody td {
    padding: 10px 12px;
    font-size: 0.8rem;
  }
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}