/* ===== Google Fonts & Modern Variables ===== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  --primary-color: #4f46e5;
  --primary-hover: #4338ca;
  --secondary-color: #64748b;
  --bg-color: #f8fafc;
  --surface-color: #ffffff;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --border-color: #e2e8f0;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --radius-md: 10px;
  --radius-lg: 16px;
}

/* ===== Reset & Base ===== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  color: var(--text-primary);
  background-color: var(--bg-color);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--primary-color);
  text-decoration: none;
  transition: color 0.2s;
}

a:hover {
  color: var(--primary-hover);
}

/* ===== Header & Navigation ===== */
header {
  background: linear-gradient(135deg, #1e1b4b 0%, #312e81 100%);
  color: #fff;
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 0;
  z-index: 100;
}

header h1 {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

header nav ul {
  list-style: none;
  display: flex;
  gap: 0.5rem;
}

header nav a {
  color: #cbd5e1;
  font-weight: 500;
  font-size: 0.9rem;
  padding: 0.5rem 0.85rem;
  border-radius: 6px;
  transition: all 0.2s ease;
}

header nav a:hover, header nav a.active {
  color: #fff;
  background-color: rgba(255, 255, 255, 0.1);
}

.nav-toggle-label {
  display: none;
  font-size: 1.5rem;
  color: #fff;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.25rem;
}

/* ===== Main Layout ===== */
main {
  max-width: 1100px;
  width: 100%;
  margin: 2.5rem auto;
  padding: 0 1.5rem;
  flex: 1;
}

section {
  background-color: var(--surface-color);
  border-radius: var(--radius-lg);
  padding: 2rem;
  margin-bottom: 2rem;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s;
}

section h2 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 1.25rem;
  letter-spacing: -0.02em;
}

/* ===== Dashboard Summary Cards (CSS Grid) ===== */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-top: 1rem;
}

.card-stat {
  background: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  text-align: left;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  position: relative;
  overflow: hidden;
}

.card-stat::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--primary-color);
}

.card-stat:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.card-stat h3 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.card-stat p {
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
}

/* ===== Search Box ===== */
.search-box {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 1.25rem;
  max-width: 360px;
}

.search-box label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.search-box input {
  padding: 0.6rem 0.9rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  background-color: #f8fafc;
}

.search-box input:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
  background-color: #fff;
}

/* ===== Tables ===== */
.table-responsive {
  overflow-x: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.95rem;
}

thead {
  background-color: #f1f5f9;
  color: var(--text-secondary);
  font-weight: 600;
}

th {
  padding: 0.85rem 1rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border-color);
}

td {
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover {
  background-color: #f8fafc;
}

/* Action Buttons inside Table */
td button {
  padding: 0.4rem 0.8rem;
  font-size: 0.8rem;
  font-weight: 500;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-right: 0.3rem;
}

td button:not(.btn-hapus) {
  background-color: #e0e7ff;
  color: #3730a3;
}

td button:not(.btn-hapus):hover {
  background-color: #c7d2fe;
}

.btn-hapus {
  background-color: #fee2e2;
  color: #991b1b;
}

.btn-hapus:hover {
  background-color: #fca5a5;
}

/* ===== Form Styling ===== */
form {
  max-width: 520px;
}

form p {
  margin-bottom: 1.25rem;
}

form label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.4rem;
}

form input[type="text"],
form input[type="number"],
form select {
  width: 100%;
  padding: 0.65rem 0.9rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--text-primary);
  background-color: #f8fafc;
  transition: all 0.2s ease;
}

form input:focus,
form select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
  background-color: #fff;
}

form button[type="submit"] {
  background-color: var(--primary-color);
  color: #fff;
  font-weight: 600;
  border: none;
  padding: 0.75rem 1.75rem;
  border-radius: 8px;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.1s ease;
  box-shadow: var(--shadow-sm);
}

form button[type="submit"]:hover {
  background-color: var(--primary-hover);
}

form button[type="submit"]:active {
  transform: scale(0.98);
}

.error {
  display: block;
  color: #dc2626;
  font-size: 0.8rem;
  margin-top: 0.35rem;
  font-weight: 500;
}

/* =====================================================================
   [FLASH MESSAGE — ada di referensi] Class .flash/.flash-success/
   .flash-error memang terdapat di style.css referensi; ditambahkan di
   sini mengikuti nama class tersebut, dengan warna yang selaras palet
   project. Dipakai halaman list.php & tambah.php (barang & peminjam).
   ===================================================================== */
.flash {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-weight: 500;
}

.flash-success {
  background-color: #dcfce7;
  color: #14532d;
}

.flash-error {
  background-color: #fee2e2;
  color: #7f1d1d;
}

/* Loading Indicator */
#loading-indicator {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
  font-style: italic;
}

/* ===== Footer ===== */
footer {
  text-align: center;
  padding: 1.5rem;
  color: var(--text-secondary);
  font-size: 0.85rem;
  border-top: 1px solid var(--border-color);
  background-color: var(--surface-color);
  margin-top: auto;
}

/* ===== Responsive Mobile Navigation ===== */
@media (max-width: 768px) {
  header {
    flex-wrap: wrap;
    padding: 1rem 1.25rem;
  }

  .nav-toggle-label {
    display: block;
  }

  header nav {
    width: 100%;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: all 0.3s ease-in-out;
  }

  header nav.nav-open {
    max-height: 300px;
    opacity: 1;
    margin-top: 1rem;
    padding-top: 0.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
  }

  header nav ul {
    flex-direction: column;
    gap: 0.25rem;
  }

  header nav a {
    display: block;
    padding: 0.6rem 0.75rem;
  }

  main {
    padding: 0 1rem;
    margin: 1.5rem auto;
  }

  section {
    padding: 1.25rem;
  }
}