/* ── Reset & Base ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #1a73e8;
  --primary-dark: #1558b0;
  --success: #28a745;
  --success-dark: #1e7e34;
  --danger: #dc3545;
  --danger-dark: #b02a37;
  --warning: #fd7e14;
  --bg: #f0f2f5;
  --card: #ffffff;
  --text: #1a1a2e;
  --muted: #6c757d;
  --border: #dee2e6;
  --radius: 12px;
  --shadow: 0 2px 12px rgba(0,0,0,0.10);
}

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

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

/* ── Layout ───────────────────────────────────────────────────── */
.page { display: none; min-height: 100vh; flex-direction: column; }
.page.active { display: flex; }

.container { max-width: 480px; margin: 0 auto; padding: 0 16px; width: 100%; }

/* ── Header / Nav ─────────────────────────────────────────────── */
.app-header {
  background: var(--primary);
  color: #fff;
  padding: 14px 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.app-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.app-header h1 { font-size: 1.1rem; font-weight: 700; letter-spacing: 0.3px; }
.header-sub { font-size: 0.75rem; opacity: 0.85; margin-top: 1px; }

.btn-logout {
  background: rgba(255,255,255,0.18);
  border: none;
  color: #fff;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.85rem;
  cursor: pointer;
  font-weight: 600;
  white-space: nowrap;
}
.btn-logout:hover { background: rgba(255,255,255,0.28); }

/* ── Tabs ─────────────────────────────────────────────────────── */
.tab-bar {
  display: flex;
  background: var(--card);
  border-bottom: 2px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}
.tab-bar::-webkit-scrollbar { display: none; }
.tab-btn {
  flex: 1;
  min-width: 80px;
  padding: 12px 8px;
  border: none;
  background: none;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  border-bottom: 3px solid transparent;
  transition: all 0.2s;
}
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ── Cards ────────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}

/* ── Forms ────────────────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.form-control {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: 10px;
  font-size: 1rem;
  background: #fff;
  color: var(--text);
  appearance: none;
  transition: border-color 0.2s;
}
.form-control:focus {
  outline: none;
  border-color: var(--primary);
}
select.form-control {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236c757d' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 40px;
}

/* ── Buttons ──────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 16px;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s, opacity 0.2s;
  letter-spacing: 0.3px;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.55; pointer-events: none; }

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

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: var(--success-dark); }

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

.btn-warning { background: var(--warning); color: #fff; }
.btn-outline {
  background: transparent;
  border: 2px solid var(--primary);
  color: var(--primary);
}
.btn-sm {
  padding: 8px 14px;
  font-size: 0.82rem;
  width: auto;
  border-radius: 8px;
}
.btn-icon { font-size: 1.2rem; }

/* ── Login Page ───────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary) 0%, #0d47a1 100%);
  padding: 24px;
}
.login-logo {
  text-align: center;
  margin-bottom: 32px;
}
.login-logo .logo-icon {
  font-size: 56px;
  display: block;
  margin-bottom: 10px;
}
.login-logo h1 {
  color: #fff;
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: 0.5px;
}
.login-logo p { color: rgba(255,255,255,0.8); font-size: 0.9rem; margin-top: 4px; }
.login-card {
  background: #fff;
  border-radius: 18px;
  padding: 28px 24px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}
.login-card h2 { font-size: 1.2rem; margin-bottom: 20px; text-align: center; color: var(--text); }

/* ── Section Header ───────────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.section-header h2 { font-size: 1rem; font-weight: 700; }

/* ── Status Badge ─────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.badge-success { background: #d4edda; color: #155724; }
.badge-warning { background: #fff3cd; color: #856404; }
.badge-info    { background: #cce5ff; color: #004085; }
.badge-muted   { background: #e9ecef; color: #495057; }

/* ── Employee Shift Card ──────────────────────────────────────── */
.shift-status {
  background: linear-gradient(135deg, #1a73e8, #0d47a1);
  border-radius: var(--radius);
  padding: 24px 20px;
  color: #fff;
  text-align: center;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.shift-status .status-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  opacity: 0.8;
  margin-bottom: 4px;
}
.shift-status .store-name { font-size: 1.3rem; font-weight: 800; margin-bottom: 4px; }
.shift-status .clock-time { font-size: 2rem; font-weight: 800; letter-spacing: 1px; }
.shift-status .time-label { font-size: 0.8rem; opacity: 0.8; }
.shift-status.inactive { background: linear-gradient(135deg, #6c757d, #495057); }

/* ── File Upload ──────────────────────────────────────────────── */
.upload-area {
  border: 3px dashed var(--border);
  border-radius: 12px;
  padding: 28px 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: #fafbfc;
}
.upload-area:hover, .upload-area.drag-over {
  border-color: var(--primary);
  background: #e8f0fe;
}
.upload-area .upload-icon { font-size: 2.5rem; margin-bottom: 8px; }
.upload-area p { color: var(--muted); font-size: 0.9rem; }
.upload-area strong { display: block; color: var(--primary); font-size: 1rem; margin-bottom: 4px; }
.upload-area input[type="file"] { display: none; }

.preview-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 12px;
}
.preview-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  background: #000;
}
.preview-item img, .preview-item video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.preview-item .remove-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(220,53,69,0.85);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* ── Table ────────────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; min-width: 500px; }
thead th {
  background: #f8f9fa;
  padding: 12px 10px;
  text-align: left;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 0.5px;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
tbody td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f8f9fa; }

/* ── List Items ───────────────────────────────────────────────── */
.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.list-item:last-child { border-bottom: none; }
.list-item-info { flex: 1; }
.list-item-name { font-weight: 600; font-size: 0.95rem; }
.list-item-sub { font-size: 0.8rem; color: var(--muted); margin-top: 2px; }
.list-item-actions { display: flex; gap: 8px; flex-shrink: 0; margin-left: 12px; }

/* ── Media Gallery ────────────────────────────────────────────── */
.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
  margin-top: 10px;
}
.media-thumb {
  position: relative;
  aspect-ratio: 1;
  border-radius: 10px;
  overflow: hidden;
  background: #000;
  cursor: pointer;
}
.media-thumb img, .media-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.media-thumb .media-label {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 4px 6px;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  text-align: center;
}
.media-label.clock-in { background: rgba(40,167,69,0.85); color: #fff; }
.media-label.clock-out { background: rgba(220,53,69,0.85); color: #fff; }

/* ── Modal ────────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 1000;
  padding: 16px;
  overflow-y: auto;
}
.modal-overlay.open { display: flex; align-items: flex-start; justify-content: center; }
.modal {
  background: var(--card);
  border-radius: var(--radius);
  width: 100%;
  max-width: 480px;
  margin: auto;
  overflow: hidden;
  box-shadow: 0 8px 40px rgba(0,0,0,0.3);
}
.modal-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h3 { font-size: 1rem; font-weight: 700; }
.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--muted);
  line-height: 1;
  padding: 0 4px;
}
.modal-body { padding: 20px; }

/* ── Alert ────────────────────────────────────────────────────── */
.alert {
  padding: 14px 16px;
  border-radius: 10px;
  margin-bottom: 14px;
  font-size: 0.9rem;
  font-weight: 500;
  display: none;
}
.alert.show { display: block; }
.alert-error { background: #f8d7da; color: #842029; border: 1px solid #f5c2c7; }
.alert-success { background: #d1e7dd; color: #0f5132; border: 1px solid #badbcc; }

/* ── Spinner ──────────────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 20px; height: 20px;
  border: 3px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Empty State ──────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 12px; display: block; }
.empty-state p { font-size: 0.95rem; }

/* ── Content Area ─────────────────────────────────────────────── */
.content { flex: 1; padding: 16px 0 80px; overflow-y: auto; }

/* ── Filters ──────────────────────────────────────────────────── */
.filter-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.filter-row .form-control {
  flex: 1;
  min-width: 120px;
  padding: 10px 12px;
  font-size: 0.88rem;
}
.filter-row select.form-control {
  padding-right: 40px;
}

/* ── Clock Display ────────────────────────────────────────────── */
.live-clock {
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--primary);
  text-align: center;
  margin: 8px 0;
}

/* ── Responsive tweaks ────────────────────────────────────────── */
@media (min-width: 600px) {
  .preview-grid { grid-template-columns: repeat(4, 1fr); }
}
