/**
 * ===========================================
 * QRTRACK ADMIN DASHBOARD STYLES
 * ===========================================
 */

:root {
  --color-bg: #ffffff;
  --color-bg-elevated: #f8f9fa;
  --color-bg-card: #ffffff;
  --color-sidebar: #ffffff;
  --color-primary: #3b82f6;
  --color-primary-dark: #1e40af;
  --color-success: #10b981;
  --color-warning: #f59e0b;
  --color-error: #ef4444;
  --color-text: #1e293b;
  --color-text-muted: #64748b;
  --color-border: #e2e8f0;
  
  --sidebar-width: 240px;
  --header-height: 64px;
}

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

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  min-height: 100vh;
}

/* Screens */
.screen {
  display: none;
  min-height: 100vh;
}

.screen.active {
  display: flex;
}

/* Login Screen */
#login-screen {
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
}

.login-container {
  width: 100%;
  max-width: 400px;
  padding: 2rem;
}

.login-header {
  text-align: center;
  margin-bottom: 2rem;
}

.login-header .logo {
  width: 80px;
  height: 80px;
  display: block;
  margin: 0 auto 1rem;
  object-fit: contain;
}

.login-header h1 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

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

.login-form {
  background: white;
  padding: 2rem;
  border-radius: 1rem;
  border: 1px solid var(--color-border);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text-muted);
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: 0.5rem;
  color: var(--color-text);
  font-size: 1rem;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

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

.error-text {
  color: var(--color-error);
  font-size: 0.875rem;
  margin-top: 1rem;
  text-align: center;
}

/* Dashboard Layout */
#dashboard-screen {
  display: none;
}

#dashboard-screen.active {
  display: flex;
}

.sidebar {
  width: var(--sidebar-width);
  background: var(--color-sidebar);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  box-shadow: 2px 0 4px rgba(0, 0, 0, 0.05);
  position: fixed;
  height: 100vh;
  left: 0;
  top: 0;
  z-index: 100;
}

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

.sidebar-header .logo {
  width: 32px;
  height: 32px;
  object-fit: contain;
  display: inline-block;
  vertical-align: middle;
  margin-right: 0.5rem;
}

.sidebar-header .brand {
  font-weight: 700;
  font-size: 1.25rem;
}

.nav-menu {
  list-style: none;
  flex: 1;
  padding: 1rem 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1.5rem;
  cursor: pointer;
  transition: background 0.2s;
  position: relative;
}

.nav-item:hover {
  background: rgba(59, 130, 246, 0.1);
}

.nav-item.active {
  background: rgba(59, 130, 246, 0.15);
  border-left: 3px solid var(--color-primary);
  color: var(--color-primary);
  font-weight: 600;
}

.nav-icon {
  font-size: 1.25rem;
}

.nav-label {
  font-weight: 500;
}

.nav-item .badge {
  position: absolute;
  right: 1rem;
  background: var(--color-error);
  color: white;
  font-size: 0.75rem;
  padding: 0.125rem 0.5rem;
  border-radius: 999px;
  font-weight: 600;
}

.sidebar-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--color-border);
}

/* Main Content */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.content-header {
  height: var(--header-height);
  padding: 0 2rem;
  background: var(--color-bg-card);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-left h1 {
  font-size: 1.25rem;
  font-weight: 600;
}

.header-left span {
  font-size: 0.875rem;
  color: var(--color-text-muted);
  margin-left: 1rem;
}

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

#admin-name {
  font-weight: 500;
}

/* Views */
.view {
  display: none;
  padding: 2rem;
  flex: 1;
}

.view.active {
  display: block;
}

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

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

.stat-card {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: 0.75rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  padding: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.stat-card.large {
  flex-direction: column;
  text-align: center;
  padding: 2rem;
}

.stat-card.large h3 {
  color: var(--color-text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

.stat-icon.present { background: rgba(16, 185, 129, 0.2); }
.stat-icon.absent { background: rgba(239, 68, 68, 0.2); }
.stat-icon.late { background: rgba(245, 158, 11, 0.2); }
.stat-icon.alert { background: rgba(239, 68, 68, 0.2); }

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

.stat-value.large {
  font-size: 3rem;
}

.stat-label {
  font-size: 0.875rem;
  color: var(--color-text-muted);
}

/* Dashboard Grid */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 1.5rem;
}

/* Cards */
.card {
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: 0.75rem;
  overflow: hidden;
}

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

.card-header h2 {
  font-size: 1rem;
  font-weight: 600;
}

.card-body {
  padding: 1rem;
}

/* Tables */
.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 0.875rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}

.data-table th {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  background: #f8f9fa;
}

.data-table tbody tr:hover {
  background: rgba(59, 130, 246, 0.05);
}

.empty-state {
  text-align: center;
  color: var(--color-text-muted);
  padding: 2rem !important;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge.success {
  background: rgba(16, 185, 129, 0.2);
  color: var(--color-success);
}

.badge.warning {
  background: rgba(245, 158, 11, 0.2);
  color: var(--color-warning);
}

.badge.error {
  background: rgba(239, 68, 68, 0.2);
  color: var(--color-error);
}

.badge.info {
  background: rgba(59, 130, 246, 0.2);
  color: var(--color-primary);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  border: none;
  border-radius: 0.5rem;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

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

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

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

.btn-secondary:hover {
  background: var(--color-border);
}

.btn-ghost {
  background: transparent;
  color: var(--color-text-muted);
}

.btn-ghost:hover {
  background: rgba(59, 130, 246, 0.1);
  color: var(--color-primary);
}

.btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: 0.5rem;
}

.btn-large {
  width: 100%;
  padding: 1rem;
  font-size: 1rem;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Filter Group */
.filter-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.filter-group input,
.filter-group select {
  padding: 0.5rem 0.75rem;
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: 0.375rem;
  color: var(--color-text);
  font-size: 0.875rem;
}

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

/* Search Box */
.search-box input {
  width: 300px;
  padding: 0.625rem 1rem;
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: 0.5rem;
  color: var(--color-text);
}

/* Chart Placeholder */
.chart-placeholder {
  height: 300px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 0.5rem;
  color: var(--color-text-muted);
}

/* Modals */
.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal.hidden {
  display: none;
}

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
}

.modal-content {
  position: relative;
  background: white;
  border: 1px solid var(--color-border);
  border-radius: 1rem;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  margin: 1rem;
}

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

.modal-header h2 {
  font-size: 1.125rem;
}

.modal-close {
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.modal-close:hover {
  color: var(--color-text);
}

.modal-body {
  padding: 1.5rem;
}

.modal-body p {
  margin-bottom: 1rem;
  color: var(--color-text-muted);
}

.modal-body .note {
  font-size: 0.875rem;
  color: var(--color-warning);
}

#add-staff-form {
  padding: 1.5rem;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--color-border);
}

/* Copy Box */
.copy-box {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.copy-box input {
  flex: 1;
  padding: 0.75rem;
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: 0.5rem;
  color: var(--color-text);
  font-size: 0.875rem;
}

/* Status Tags */
.status-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.625rem;
  border-radius: 0.375rem;
  font-size: 0.75rem;
  font-weight: 500;
}

.status-tag.late {
  background: rgba(245, 158, 11, 0.2);
  color: var(--color-warning);
}

.status-tag.early {
  background: rgba(239, 68, 68, 0.2);
  color: var(--color-error);
}

.status-tag.ontime {
  background: rgba(16, 185, 129, 0.2);
  color: var(--color-success);
}

/* Action Buttons */
.action-btn {
  padding: 0.375rem 0.625rem;
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: 0.375rem;
  color: var(--color-text-muted);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
}

.action-btn:hover {
  background: var(--color-bg-card);
  color: var(--color-text);
}

.action-btn.danger:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: var(--color-error);
  color: var(--color-error);
}

/* Utilities */
.hidden {
  display: none !important;
}

/* Settings Page */
.settings-grid {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: 1fr;
}

.settings-description {
  color: var(--color-text-muted);
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
}

.checkbox-group {
  margin-top: 1rem;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  font-weight: 500;
}

.checkbox-label input[type="checkbox"] {
  width: 1.25rem;
  height: 1.25rem;
  accent-color: var(--color-primary);
}

.checkbox-group small {
  display: block;
  margin-top: 0.5rem;
  margin-left: 2rem;
  color: var(--color-text-muted);
  font-size: 0.8rem;
}

.location-actions {
  display: flex;
  gap: 1rem;
  margin-top: 1.5rem;
  flex-wrap: wrap;
}

.location-info {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--color-border);
  color: var(--color-text-muted);
}

.status-message {
  padding: 1rem;
  border-radius: 0.5rem;
  margin-top: 1rem;
  font-weight: 500;
}

.status-message.success {
  background: rgba(16, 185, 129, 0.15);
  color: var(--color-success);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.status-message.error {
  background: rgba(239, 68, 68, 0.15);
  color: var(--color-error);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.status-message.info {
  background: rgba(59, 130, 246, 0.15);
  color: var(--color-primary);
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.qr-preview {
  text-align: center;
  padding: 1rem;
}

/* Responsive */
@media (max-width: 1024px) {
  .sidebar {
    width: 64px;
  }
  
  .sidebar-header .brand,
  .nav-label,
  .sidebar-footer button span:last-child {
    display: none;
  }
  
  .nav-item {
    justify-content: center;
    padding: 1rem;
  }
  
  .nav-item .badge {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    padding: 0.125rem 0.375rem;
  }
  
  .main-content {
    margin-left: 64px;
  }
  
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .sidebar {
    display: none;
  }
  
  .main-content {
    margin-left: 0;
  }
  
  .view {
    padding: 1rem;
  }
  
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .form-row {
    grid-template-columns: 1fr;
  }
}

/* ===========================================
 * QR CODE DISPLAY
 * =========================================== */

.qr-code-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 1.5rem 0;
  gap: 1rem;
}

.qr-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 1.5rem;
  background: white;
  border-radius: 1rem;
  border: 1px solid var(--color-border);
}

.qr-container img {
  width: 200px;
  height: 200px;
  object-fit: contain;
  border: 2px solid var(--color-border);
  border-radius: 0.5rem;
  padding: 0.5rem;
  background: white;
}

.qr-url {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  word-break: break-all;
  text-align: center;
  max-width: 300px;
}

.qr-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 2rem;
  color: var(--color-text-muted);
}

.qr-loading .spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* QR container styles defined above */

.qr-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 1.5rem;
}

.qr-warning {
  margin-top: 1.5rem;
  padding: 1rem;
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: 0.5rem;
  font-size: 0.875rem;
  color: var(--color-warning);
}

.qr-warning strong {
  display: block;
  margin-bottom: 0.25rem;
}

@media print {
  body * {
    visibility: hidden;
  }
  
  .qr-container, .qr-container * {
    visibility: visible;
  }
  
  .qr-container {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    box-shadow: none;
    border: 2px solid #ccc;
  }
  
  .qr-container canvas {
    width: 300px !important;
    height: 300px !important;
  }
}
