/* Lume Sensor Inventory Tracker - Virridy Brand Styles */

:root {
  --primary: #004C45;
  --primary-light: #006B5F;
  --primary-dark: #003830;
  --accent: #A0C814;
  --accent-dark: #8AB010;
  --bg: #F5F7FA;
  --white: #FFFFFF;
  --gray-50: #F9FAFB;
  --gray-100: #F3F4F6;
  --gray-200: #E5E7EB;
  --gray-300: #D1D5DB;
  --gray-400: #9CA3AF;
  --gray-500: #6B7280;
  --gray-600: #4B5563;
  --gray-700: #374151;
  --gray-800: #1F2937;
  --gray-900: #111827;
  --red: #DC2626;
  --red-light: #FEE2E2;
  --green: #16A34A;
  --green-light: #DCFCE7;
  --yellow: #CA8A04;
  --yellow-light: #FEF9C3;
  --blue: #2563EB;
  --blue-light: #DBEAFE;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
  --radius: 8px;
  --radius-lg: 12px;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--gray-800);
  line-height: 1.6;
  min-height: 100vh;
}

/* ---- HEADER / NAV ---- */
.app-header {
  background: var(--primary);
  color: var(--white);
  padding: 0 1.5rem;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-md);
}

.app-header .logo {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--white);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.app-header .logo span {
  color: var(--accent);
}

.nav-links {
  display: flex;
  gap: 0.25rem;
  list-style: none;
}

.nav-links a {
  color: rgba(255,255,255,0.8);
  text-decoration: none;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.15s;
}

.nav-links a:hover, .nav-links a.active {
  color: var(--white);
  background: rgba(255,255,255,0.15);
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.user-info {
  font-size: 0.875rem;
  color: rgba(255,255,255,0.8);
}

.btn-logout {
  background: rgba(255,255,255,0.15);
  color: var(--white);
  border: none;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.8rem;
}

.btn-logout:hover { background: rgba(255,255,255,0.25); }

.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  color: var(--white);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.25rem;
}

/* ---- MAIN CONTENT ---- */
.main-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.page-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--gray-900);
}

/* ---- CARDS ---- */
.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--gray-700);
}

/* ---- STAT CARDS ---- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  text-align: center;
}

.stat-card .stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
}

.stat-card .stat-label {
  font-size: 0.8rem;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 0.25rem;
}

.stat-card.accent .stat-value { color: var(--accent-dark); }
.stat-card.green .stat-value { color: var(--green); }
.stat-card.yellow .stat-value { color: var(--yellow); }
.stat-card.red .stat-value { color: var(--red); }

/* ---- BUTTONS ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

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

.btn-accent {
  background: var(--accent);
  color: var(--primary-dark);
  font-weight: 600;
}
.btn-accent:hover { background: var(--accent-dark); }

.btn-secondary {
  background: var(--gray-100);
  color: var(--gray-700);
  border: 1px solid var(--gray-200);
}
.btn-secondary:hover { background: var(--gray-200); }

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

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
}

.btn-group {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* ---- FORMS ---- */
.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--gray-700);
  margin-bottom: 0.35rem;
}

.form-control {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-family: inherit;
  transition: border-color 0.15s;
  background: var(--white);
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 76, 69, 0.1);
}

select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.form-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.form-check input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

/* ---- TABLES ---- */
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

thead th {
  background: var(--gray-50);
  padding: 0.75rem;
  text-align: left;
  font-weight: 600;
  color: var(--gray-600);
  border-bottom: 2px solid var(--gray-200);
  white-space: nowrap;
}

tbody td {
  padding: 0.75rem;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-700);
}

tbody tr:hover { background: var(--gray-50); }

tbody tr { cursor: pointer; }

/* ---- STATUS BADGES ---- */
.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-in-stock { background: var(--blue-light); color: var(--blue); }
.badge-deployed { background: var(--green-light); color: var(--green); }
.badge-planned { background: #E0E7FF; color: #4F46E5; }
.badge-maintenance { background: var(--yellow-light); color: var(--yellow); }
.badge-decommissioned { background: var(--gray-200); color: var(--gray-600); }
.badge-lost-damaged { background: var(--red-light); color: var(--red); }
.badge-confirmed { background: var(--green-light); color: var(--green); }
.badge-pending { background: var(--yellow-light); color: var(--yellow); }

/* ---- SEARCH & FILTERS ---- */
.filters-bar {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  align-items: center;
}

.search-input {
  flex: 1;
  min-width: 200px;
  position: relative;
}

.search-input input {
  width: 100%;
  padding: 0.5rem 0.75rem 0.5rem 2.25rem;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 0.875rem;
  background: var(--white);
}

.search-input::before {
  content: '\1F50D';
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.85rem;
  opacity: 0.4;
}

.search-input input:focus {
  outline: none;
  border-color: var(--primary);
}

.filter-select {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 0.875rem;
  background: var(--white);
  cursor: pointer;
  min-width: 140px;
}

/* ---- PAGINATION ---- */
.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--gray-200);
  font-size: 0.85rem;
  color: var(--gray-500);
}

.pagination-btns {
  display: flex;
  gap: 0.5rem;
}

/* ---- LOGIN PAGE ---- */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1.5rem;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
}

.login-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 2.5rem;
  width: 100%;
  max-width: 400px;
}

.login-card h1 {
  text-align: center;
  color: var(--primary);
  margin-bottom: 0.5rem;
  font-size: 1.5rem;
}

.login-card .subtitle {
  text-align: center;
  color: var(--gray-500);
  margin-bottom: 2rem;
  font-size: 0.9rem;
}

.login-card .btn-primary {
  width: 100%;
  padding: 0.75rem;
  font-size: 1rem;
  justify-content: center;
}

.login-error {
  background: var(--red-light);
  color: var(--red);
  padding: 0.75rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
  margin-bottom: 1rem;
  display: none;
}

/* ---- SCANNER ---- */
.scanner-page {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 60px);
}

.scanner-container {
  flex: 1;
  position: relative;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}

#scanner-viewport {
  width: 100%;
  max-width: 500px;
}

.scanner-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0,0,0,0.7);
  color: var(--white);
  padding: 1.5rem;
  text-align: center;
}

.scanner-result {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin: 1rem;
  text-align: center;
}

.scanner-fallback {
  padding: 1.5rem;
  background: var(--white);
}

.scanner-fallback .form-group {
  display: flex;
  gap: 0.5rem;
}

.scanner-fallback input {
  flex: 1;
}

/* ---- ACTIVITY LOG ---- */
.activity-item {
  display: flex;
  gap: 1rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--gray-100);
  font-size: 0.85rem;
}

.activity-item:last-child { border-bottom: none; }

.activity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
  margin-top: 0.5rem;
  flex-shrink: 0;
}

.activity-dot.created { background: var(--green); }
.activity-dot.status_change { background: var(--blue); }
.activity-dot.updated { background: var(--yellow); }
.activity-dot.deleted { background: var(--red); }

.activity-content { flex: 1; }
.activity-time { color: var(--gray-400); font-size: 0.8rem; }

/* ---- QUICK ACTIONS ---- */
.quick-actions {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.quick-action-card {
  flex: 1;
  min-width: 140px;
  background: var(--white);
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  text-align: center;
  text-decoration: none;
  color: var(--gray-700);
  transition: all 0.15s;
  cursor: pointer;
}

.quick-action-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
}

.quick-action-card .icon {
  font-size: 1.75rem;
  margin-bottom: 0.5rem;
}

.quick-action-card .label {
  font-weight: 600;
  font-size: 0.85rem;
}

/* ---- CHART ---- */
.chart-container {
  max-width: 300px;
  margin: 0 auto;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

/* ---- DETAIL PAGE ---- */
.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
}

.detail-barcode {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
  font-family: 'Courier New', monospace;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.detail-field label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-500);
  font-weight: 600;
}

.detail-field .value {
  font-size: 0.95rem;
  color: var(--gray-800);
  margin-top: 0.25rem;
}

/* ---- LOADING ---- */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  color: var(--gray-400);
}

.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-right: 0.75rem;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---- TOAST ---- */
.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: var(--gray-800);
  color: var(--white);
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  box-shadow: var(--shadow-md);
  z-index: 1000;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.toast.error { background: var(--red); }
.toast.success { background: var(--green); }

/* ---- MODAL ---- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 1.5rem;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.modal-header h2 {
  font-size: 1.15rem;
  color: var(--gray-900);
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--gray-400);
  cursor: pointer;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1.5rem;
}

/* ---- EMPTY STATE ---- */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--gray-400);
}

.empty-state .icon { font-size: 2.5rem; margin-bottom: 0.75rem; }
.empty-state p { font-size: 0.95rem; }

/* ---- RESPONSIVE ---- */
@media (max-width: 768px) {
  .app-header { padding: 0 1rem; }

  .nav-links {
    display: none;
    position: absolute;
    top: 60px;
    left: 0;
    right: 0;
    background: var(--primary);
    flex-direction: column;
    padding: 0.5rem;
    box-shadow: var(--shadow-md);
  }

  .nav-links.open { display: flex; }

  .nav-links a {
    padding: 0.75rem 1rem;
  }

  .mobile-menu-btn { display: block; }

  .user-info { display: none; }

  .main-content { padding: 1rem; }

  .page-header { flex-direction: column; align-items: flex-start; }

  .form-row { grid-template-columns: 1fr; }

  .dashboard-grid { grid-template-columns: 1fr; }

  .stats-grid { grid-template-columns: 1fr 1fr; }

  .filters-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .search-input { min-width: auto; }

  .pagination { flex-direction: column; gap: 0.5rem; text-align: center; }

  .detail-header { flex-direction: column; }

  .quick-actions { flex-direction: column; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
}
