/* ============================================
   MODERN INVENTORY LOG STYLES - 1476 Stores
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --color-bg: hsl(220, 14%, 96%);
  --color-surface: hsl(0, 0%, 100%);
  --color-text: hsl(220, 13%, 18%);
  --color-text-muted: hsl(220, 10%, 46%);
  --color-border: hsl(220, 13%, 90%);
  --color-primary: hsl(217, 91%, 50%);
  --color-primary-hover: hsl(217, 91%, 42%);
  --color-danger: hsl(0, 72%, 51%);
  --color-danger-light: hsl(0, 86%, 97%);
  --color-warning-light: hsl(0, 86%, 95%);
  --color-success: hsl(142, 72%, 29%);
  --color-success-light: hsl(142, 76%, 96%);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px hsla(220, 13%, 18%, 0.05);
  --shadow-md: 0 4px 12px hsla(220, 13%, 18%, 0.08);
  --shadow-lg: 0 8px 24px hsla(220, 13%, 18%, 0.12);
  --transition: 0.2s ease;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  margin: 0;
  padding: 24px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* Container */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  background: var(--color-surface);
  padding: 32px;
  box-shadow: var(--shadow-md);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
}

.container.narrow { max-width: 600px; }

/* Headings */
h1, h2, h3 {
  margin: 0 0 16px 0;
  color: var(--color-text);
  font-weight: 600;
  letter-spacing: -0.02em;
}
h1 { font-size: 1.75rem; }
h2 { font-size: 1.375rem; margin-top: 32px; }
h3 { font-size: 1.125rem; margin-top: 24px; }
h1:first-child, h2:first-child, h3:first-child { margin-top: 0; }

/* Navigation */
.nav-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--color-border);
}
.nav-links a { font-size: 0.875rem; font-weight: 500; }

/* Tables */
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin-bottom: 24px;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--color-border);
}
table th, table td {
  padding: 14px 16px;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}
table th {
  background: var(--color-bg);
  font-weight: 600;
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  cursor: pointer;
}
table th:hover { background: hsl(220, 14%, 92%); }
table td { font-size: 0.9375rem; }
table tr:last-child td { border-bottom: none; }
table tbody tr:hover { background: hsla(217, 91%, 50%, 0.03); }

/* Row highlights */
.low-stock, .overdue {
  background-color: var(--color-danger-light) !important;
  border-left: 3px solid var(--color-danger);
}
.loaned {
  background: hsla(217, 91%, 50%, 0.06) !important;
  border-left: 3px solid var(--color-primary);
}

/* Form elements */
label {
  display: block;
  margin-bottom: 6px;
  font-weight: 500;
  font-size: 0.875rem;
}
input, select, textarea {
  margin: 0 0 16px 0;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  font-size: 0.9375rem;
  font-family: inherit;
  background: var(--color-surface);
  color: var(--color-text);
  transition: border-color var(--transition), box-shadow var(--transition);
  min-height: 44px;
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px hsla(217, 91%, 50%, 0.15);
}
input::placeholder { color: var(--color-text-muted); }
input[type="checkbox"] {
  width: auto;
  min-height: auto;
  margin-right: 8px;
}

/* Buttons */
button, .btn, .btn-small, .btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 0;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 0.9375rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  background: var(--color-primary);
  color: white;
  min-height: 44px;
  text-decoration: none;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
}
button:hover, .btn:hover, .btn-primary:hover {
  background: var(--color-primary-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
button:active, .btn:active { transform: translateY(0); }

.btn-small {
  font-size: 0.8125rem;
  padding: 8px 12px;
  min-height: 36px;
}
.btn-danger { background: var(--color-danger); }
.btn-danger:hover { background: hsl(0, 72%, 45%); }
.btn-secondary {
  background: var(--color-bg);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}
.btn-secondary:hover { background: hsl(220, 14%, 92%); }

/* Button/form groups */
.button-group { display: flex; gap: 8px; flex-wrap: wrap; }
.inline-form {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-wrap: wrap;
}
.inline-form input, .inline-form select {
  margin: 0;
  width: auto;
  min-width: 120px;
}
.inline-form label {
  font-size: 0.75rem;
  margin-bottom: 4px;
}
.form-group { margin-bottom: 20px; }
.form-group label { margin-bottom: 6px; }
.form-group input, .form-group select { margin-bottom: 0; }

/* Row layout */
.row {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.row input { flex: 1; margin: 0; }

/* Cards */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 20px;
  margin-bottom: 16px;
}
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

/* QR Cards */
.qr-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
  margin-top: 20px;
}
.qr-card {
  display: flex;
  gap: 16px;
  align-items: center;
  padding: 16px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  transition: box-shadow var(--transition), transform var(--transition);
}
.qr-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.qr-image {
  width: 140px;
  height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-bg);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}
.qr-meta { font-size: 0.875rem; color: var(--color-text-muted); }
.qr-meta strong { color: var(--color-text); display: block; margin-bottom: 4px; }
.small { font-size: 0.75rem; color: var(--color-text-muted); margin-top: 8px; }

/* Modal */
.qr-modal {
  position: fixed;
  z-index: 9999;
  inset: 0;
  background-color: hsla(220, 13%, 18%, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.qr-modal-content {
  background: var(--color-surface);
  width: 100%;
  max-width: 640px;
  padding: 24px;
  border-radius: var(--radius-lg);
  position: relative;
  box-shadow: var(--shadow-lg);
}
.close-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  padding: 8px 12px;
  min-height: auto;
}

/* Scan box */
.scan-box {
  background: var(--color-bg);
  padding: 24px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
}

/* Messages */
.flashes, .flash, .flash-message {
  list-style: none;
  padding: 14px 18px;
  margin: 0 0 20px 0;
  background: var(--color-danger-light);
  border: 1px solid hsl(0, 72%, 90%);
  border-radius: var(--radius-sm);
  color: var(--color-danger);
  font-size: 0.9375rem;
}
.success {
  background: var(--color-success-light);
  border-color: hsl(142, 76%, 80%);
  color: var(--color-success);
}
.hint {
  margin-top: 12px;
  font-size: 0.875rem;
  color: var(--color-text-muted);
}

/* Links */
a {
  text-decoration: none;
  color: var(--color-primary);
  font-weight: 500;
  transition: color var(--transition);
}
a:hover { color: var(--color-primary-hover); }

/* Status badges */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}
.badge-success { background: var(--color-success-light); color: var(--color-success); }
.badge-warning { background: hsl(45, 93%, 94%); color: hsl(45, 93%, 30%); }
.badge-danger { background: var(--color-danger-light); color: var(--color-danger); }
.badge-muted { background: var(--color-bg); color: var(--color-text-muted); }

/* Protected label */
.protected {
  font-style: italic;
  color: var(--color-text-muted);
  font-size: 0.875rem;
}

/* Footer */
.page-footer {
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--color-border);
  font-size: 0.875rem;
  color: var(--color-text-muted);
  text-align: center;
}

/* Report form */
.report-form {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}
.report-form input {
  flex: 1;
  min-width: 180px;
  margin: 0;
}
.report-form button { flex-shrink: 0; }

/* ============================================
   RESPONSIVE STYLES
   ============================================ */
@media (max-width: 768px) {
  body { padding: 16px; }
  .container { padding: 20px; }
  
  table, thead, tbody, th, td, tr { display: block; }
  table { border: none; }
  thead { display: none; }
  tr {
    margin-bottom: 16px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 12px;
    background: var(--color-surface);
    box-shadow: var(--shadow-sm);
  }
  td {
    border: none;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 8px;
    font-size: 0.9375rem;
  }
  td::before {
    content: attr(data-label);
    font-weight: 600;
    font-size: 0.8125rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
  }
  td:last-child { border-bottom: none; }
  
  .inline-form { flex-direction: column; align-items: stretch; }
  .inline-form input, .inline-form select { width: 100%; min-width: 100%; }
  
  .qr-list { grid-template-columns: 1fr; }
  .qr-card { flex-direction: column; text-align: center; }
  
  .report-form { flex-direction: column; }
  .report-form input { min-width: 100%; }
  
  .card-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .button-group { flex-direction: column; }
  .button-group button, .button-group .btn { width: 100%; }
}

/* ============================================
   CATEGORY NAVIGATION STYLES
   Added for Uniform Filtering
   ============================================ */

/* Container for the buttons */
.category-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--color-border);
}

/* Individual Category Buttons */
.cat-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  background-color: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  transition: all var(--transition);
  cursor: pointer;
  white-space: nowrap; /* Prevents text breaking inside button */
}

/* Hover State */
.cat-btn:hover {
  background-color: hsl(220, 14%, 92%); /* Slight grey for hover */
  border-color: var(--color-primary);
  color: var(--color-primary);
  transform: translateY(-1px);
}

/* Active/Selected State */
.cat-btn.active {
  background-color: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
  box-shadow: var(--shadow-sm);
}

/* --- Utility Classes to Replace Inline Styles --- */

/* Replaces <h2 style="margin-top: 0;"> */
.section-title {
  margin-top: 0;
}

/* Replaces <input style="min-width: 140px;"> */
.loan-input {
  min-width: 140px;
}