/* ==========================================================================
   TEMPLE HERITAGE PERMANENT QR MANAGEMENT SYSTEM
   Modern, Rich Dark & Gold Heritage Design System
   ========================================================================== */

:root {
  --bg-main: #0a0e17;
  --bg-sidebar: #0f172a;
  --bg-card: #161f32;
  --bg-card-hover: #1c273e;
  --bg-card-subtle: #111827;
  --border-color: rgba(255, 255, 255, 0.08);
  --border-gold: rgba(245, 158, 11, 0.3);
  --border-focus: #f59e0b;

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --gold-500: #f59e0b;
  --gold-600: #d97706;
  --gold-400: #fbbf24;
  --gold-glow: rgba(245, 158, 11, 0.25);

  --emerald-500: #10b981;
  --emerald-glow: rgba(16, 185, 129, 0.25);
  --rose-500: #f43f5e;
  --rose-glow: rgba(244, 63, 94, 0.25);
  --blue-500: #3b82f6;
  --purple-500: #8b5cf6;

  --font-main: "Outfit", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", monospace;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --shadow-card: 0 10px 25px -5px rgba(0, 0, 0, 0.4), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
  --shadow-gold: 0 0 20px rgba(245, 158, 11, 0.2);
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: var(--font-main);
  background-color: var(--bg-main);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

a:hover {
  color: var(--gold-500);
}

/* ==========================================================================
   LAYOUT: SIDEBAR & MAIN CONTAINER
   ========================================================================== */

.app-wrapper {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 270px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  transition: transform var(--transition-normal);
}

.sidebar-header {
  padding: 24px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--gold-500), var(--gold-600));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #000;
  font-size: 20px;
  box-shadow: var(--shadow-gold);
}

.brand-info h2 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text-primary);
}

.brand-info span {
  font-size: 11px;
  color: var(--gold-400);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-weight: 600;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  padding: 12px 12px 6px 12px;
  font-weight: 600;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  transition: all var(--transition-fast);
}

.nav-link:hover {
  background-color: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  transform: translateX(3px);
}

.nav-link.active {
  background: linear-gradient(90deg, rgba(245, 158, 11, 0.15), rgba(245, 158, 11, 0.02));
  color: var(--gold-400);
  border-left: 3px solid var(--gold-500);
  font-weight: 600;
}

.nav-link svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border-color);
  background-color: rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background-color: var(--bg-card);
  border: 1px solid var(--gold-500);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--gold-400);
}

.user-details {
  display: flex;
  flex-direction: column;
}

.user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  max-width: 130px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 11px;
  color: var(--emerald-500);
  display: flex;
  align-items: center;
  gap: 4px;
}

.main-content {
  margin-left: 270px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background-color: var(--bg-main);
}

/* ==========================================================================
   TOPBAR
   ========================================================================== */

.topbar {
  height: 70px;
  background-color: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 90;
}

.page-title h1 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 9999px;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: var(--emerald-500);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--emerald-500);
  box-shadow: 0 0 10px var(--emerald-500);
  animation: pulse-dot 1.5s infinite;
}

.live-badge.lost {
  background: rgba(244, 63, 94, 0.12);
  border-color: rgba(244, 63, 94, 0.3);
  color: var(--rose-500);
}

.live-badge.lost .live-dot {
  background-color: var(--rose-500);
  box-shadow: 0 0 10px var(--rose-500);
  animation: none;
}

@keyframes pulse-dot {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.3); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

/* ==========================================================================
   PAGE CONTAINER & CARDS
   ========================================================================== */

.content-container {
  padding: 32px;
  flex: 1;
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
}

.grid-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
  transition: transform var(--transition-fast), border-color var(--transition-fast);
}

.card:hover {
  border-color: var(--border-gold);
}

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

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.card-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgba(255, 255, 255, 0.04);
  color: var(--gold-400);
}

.metric-value {
  font-size: 32px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.5px;
  line-height: 1.1;
  margin-bottom: 6px;
}

.metric-meta {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.metric-trend-up {
  color: var(--emerald-500);
  font-weight: 600;
}

/* ==========================================================================
   BUTTONS & CONTROLS
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition-fast);
  text-decoration: none;
  font-family: inherit;
}

.btn-gold {
  background: linear-gradient(135deg, var(--gold-500), var(--gold-600));
  color: #000;
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.3);
}

.btn-gold:hover {
  background: linear-gradient(135deg, var(--gold-400), var(--gold-500));
  color: #000;
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(245, 158, 11, 0.4);
}

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

.btn-secondary:hover {
  background-color: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.15);
  color: #fff;
}

.btn-danger {
  background-color: rgba(244, 63, 94, 0.15);
  border-color: rgba(244, 63, 94, 0.3);
  color: var(--rose-500);
}

.btn-danger:hover {
  background-color: var(--rose-500);
  color: #fff;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
  border-radius: var(--radius-sm);
}

.btn-icon {
  padding: 8px;
  border-radius: var(--radius-md);
}

/* ==========================================================================
   TABLES & DATA LISTS
   ========================================================================== */

.table-responsive {
  width: 100%;
  overflow-x: auto;
}

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

.data-table th {
  background-color: rgba(0, 0, 0, 0.2);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
}

.data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
  font-size: 13px;
  color: var(--text-primary);
  vertical-align: middle;
}

.data-table tr:hover td {
  background-color: rgba(255, 255, 255, 0.02);
}

.qr-thumb {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background-color: #fff;
  padding: 2px;
  border: 1px solid var(--border-color);
}

.qr-badge-num {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--gold-400);
  background: rgba(245, 158, 11, 0.1);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(245, 158, 11, 0.25);
  display: inline-block;
}

.badge-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-status.active {
  background: rgba(16, 185, 129, 0.12);
  color: var(--emerald-500);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-status.inactive {
  background: rgba(244, 63, 94, 0.12);
  color: var(--rose-500);
  border: 1px solid rgba(244, 63, 94, 0.3);
}

.badge-status.pass {
  background: rgba(16, 185, 129, 0.12);
  color: var(--emerald-500);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-status.fail {
  background: rgba(244, 63, 94, 0.12);
  color: var(--rose-500);
  border: 1px solid rgba(244, 63, 94, 0.3);
}

.url-code {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-secondary);
  background: rgba(0, 0, 0, 0.25);
  padding: 3px 6px;
  border-radius: var(--radius-sm);
  max-width: 280px;
  display: inline-block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ==========================================================================
   FORMS & INPUTS
   ========================================================================== */

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

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

.form-input, .form-select, .form-textarea {
  width: 100%;
  background-color: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 14px;
  color: var(--text-primary);
  font-family: inherit;
  transition: border-color var(--transition-fast);
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--gold-500);
  box-shadow: 0 0 0 3px var(--gold-glow);
}

.form-input:disabled, .form-input[readonly] {
  background-color: rgba(255, 255, 255, 0.03);
  color: var(--text-muted);
  cursor: not-allowed;
}

.search-bar-container {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

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

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.search-input-wrapper .form-input {
  padding-left: 38px;
}

.modal-backdrop, .modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(8px);
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop.show, .modal-overlay.active {
  display: flex !important;
}

.modal-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 550px;
  width: 100%;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
  animation: modal-enter 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

@keyframes modal-enter {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

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

.modal-header h3 {
  font-size: 16px;
  font-weight: 700;
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast), background-color var(--transition-fast);
}

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

.modal-body {
  padding: 24px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  background-color: rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

/* ==========================================================================
   TOAST NOTIFICATIONS
   ========================================================================== */

.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  box-shadow: var(--shadow-card);
  color: var(--text-primary);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 12px;
  animation: toast-slide 0.25s ease forwards;
  min-width: 280px;
}

.toast.toast-success {
  border-left: 4px solid var(--emerald-500);
}

.toast.toast-danger {
  border-left: 4px solid var(--rose-500);
}

@keyframes toast-slide {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ==========================================================================
   AUTHENTICATION & ERROR SCREENS
   ========================================================================== */

.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: radial-gradient(circle at 50% 30%, #161f32 0%, #0a0e17 70%);
}

.auth-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-xl);
  padding: 40px;
  max-width: 440px;
  width: 100%;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6), var(--shadow-gold);
}

.auth-header {
  text-align: center;
  margin-bottom: 30px;
}

.auth-header .brand-icon {
  margin: 0 auto 16px auto;
  width: 54px;
  height: 54px;
  font-size: 26px;
}

.auth-header h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
}

.auth-header p {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 6px;
}

.alert {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.alert-danger {
  background-color: rgba(244, 63, 94, 0.15);
  border: 1px solid rgba(244, 63, 94, 0.3);
  color: #fecdd3;
}

.alert-info {
  background-color: rgba(59, 130, 246, 0.15);
  border: 1px solid rgba(59, 130, 246, 0.3);
  color: #bfdbfe;
}

/* ==========================================================================
   RESPONSIVE BREAKPOINTS
   ========================================================================== */

@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.mobile-open {
    transform: translateX(0);
  }
  .main-content {
    margin-left: 0;
  }
  .topbar {
    padding: 0 16px;
  }
  .content-container {
    padding: 16px;
  }
}

.card-border-pass {
  border-left: 6px solid var(--emerald-500) !important;
}

.card-border-gold {
  border-left: 6px solid var(--gold-400) !important;
}

.text-danger-color {
  color: var(--rose-500) !important;
}

.text-success-color {
  color: var(--emerald-500) !important;
}

.text-gold {
  color: var(--gold-400) !important;
}

/* ==========================================================================
   SPINNER ANIMATIONS & LOADING STATES
   ========================================================================== */

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

@-webkit-keyframes spin {
  0% {
    -webkit-transform: rotate(0deg);
  }
  100% {
    -webkit-transform: rotate(360deg);
  }
}

.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  -webkit-animation: spin 0.75s linear infinite;
  vertical-align: middle;
  margin-right: 8px;
  flex-shrink: 0;
  box-sizing: border-box;
}

.spinner-dark {
  border: 2px solid rgba(0, 0, 0, 0.25);
  border-top-color: #000000;
}

.spinner-gold {
  border: 2px solid rgba(245, 158, 11, 0.25);
  border-top-color: var(--gold-400);
}

.spinner-lg {
  width: 22px;
  height: 22px;
  border-width: 2.5px;
}
