/* =========================================
   ShopClock — Mobile-First CSS
   ========================================= */

:root {
  --primary: #1A7A3D;
  --primary-dark: #15632F;
  --primary-light: #e8f5ed;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --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;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.15);
}

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

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

/* ---- Container ---- */
.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 16px;
}

/* ---- Navbar ---- */
.navbar {
  background: var(--gray-900);
  color: white;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 3px solid var(--primary);
}

.navbar-brand a {
  color: white;
  text-decoration: none;
  font-weight: 700;
  font-size: 1.125rem;
}

.navbar-links {
  display: none;
  width: 100%;
  flex-direction: column;
  gap: 8px;
  padding-top: 12px;
}

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

.nav-link {
  color: var(--gray-300);
  text-decoration: none;
  padding: 8px 0;
}

.nav-link:hover {
  color: white;
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: 8px;
  border-top: 1px solid var(--gray-700);
  margin-top: 4px;
}

.nav-username {
  color: var(--gray-400);
  font-size: 0.875rem;
}

.nav-logout-form {
  display: inline;
}

.navbar-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.navbar-toggle span {
  display: block;
  width: 24px;
  height: 2px;
  background: white;
  border-radius: 1px;
}

@media (min-width: 768px) {
  .navbar-links {
    display: flex;
    width: auto;
    flex-direction: row;
    align-items: center;
    gap: 16px;
    padding-top: 0;
  }

  .nav-user {
    padding-top: 0;
    border-top: none;
    margin-top: 0;
    margin-left: auto;
  }

  .navbar-toggle {
    display: none;
  }
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
  text-decoration: none;
  line-height: 1.4;
}

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

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

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

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

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

.btn-secondary {
  background: var(--gray-600);
  color: white;
}

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

.btn-block {
  width: 100%;
}

.btn-lg {
  padding: 14px 24px;
  font-size: 1.125rem;
  min-height: 48px;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.875rem;
}

.btn-microsoft {
  background: #2f2f2f;
  color: white;
}

.btn-clock {
  min-height: 56px;
  font-size: 1.125rem;
}

/* ---- Forms ---- */
.form-group {
  margin-bottom: 16px;
}

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

.form-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 1rem;
  background: white;
  transition: border-color 0.15s;
  -webkit-appearance: none;
}

.form-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26, 122, 61, 0.15);
}

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

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

/* ---- Alerts ---- */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 0.9375rem;
}

.alert-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: var(--danger);
}

.alert-success {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: var(--success);
}

/* ---- Login Page ---- */
.login-page {
  background: var(--gray-100);
  display: flex;
  min-height: 100vh;
}

.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 16px;
}

.login-card {
  background: white;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  padding: 32px 24px;
  width: 100%;
  max-width: 400px;
  border-top: 4px solid var(--primary);
}

.login-header {
  text-align: center;
  margin-bottom: 24px;
}

.login-header h1 {
  font-size: 1.75rem;
  color: var(--primary);
  font-weight: 800;
}

.login-header p {
  color: var(--gray-500);
  font-size: 0.9375rem;
  margin-top: 4px;
}

.login-form {
  margin-top: 16px;
}

.login-footer {
  text-align: center;
  margin-top: 16px;
}

.login-divider {
  display: flex;
  align-items: center;
  margin: 20px 0;
  color: var(--gray-400);
  font-size: 0.875rem;
}

.login-divider::before,
.login-divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid var(--gray-200);
}

.login-divider span {
  padding: 0 12px;
}

.link-muted {
  color: var(--gray-500);
  text-decoration: none;
  font-size: 0.875rem;
}

.link-muted:hover {
  color: var(--primary);
}

/* ---- Dashboard ---- */
.dashboard {
  max-width: 480px;
  margin: 0 auto;
}

.dashboard-header {
  text-align: center;
  margin-bottom: 24px;
}

.dashboard-header h1 {
  font-size: 1.5rem;
}

.dashboard-date {
  color: var(--gray-500);
  font-size: 0.9375rem;
}

.clock-widget {
  background: white;
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 24px;
}

.clock-display {
  text-align: center;
  padding: 20px 0;
}

.clock-time {
  font-size: 3rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--gray-900);
  letter-spacing: -1px;
}

.clock-status {
  font-size: 1.125rem;
  font-weight: 500;
  margin-top: 4px;
}

.clock-since {
  color: var(--gray-500);
  font-size: 0.875rem;
  margin-top: 4px;
}

.current-activity {
  background: var(--gray-50);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.activity-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--gray-500);
  font-weight: 600;
}

.activity-name {
  font-weight: 600;
  color: var(--gray-800);
}

.activity-job {
  font-size: 0.875rem;
  color: var(--gray-600);
}

.clock-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ---- Page Header ---- */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-header h1 {
  font-size: 1.5rem;
}

/* ---- Tables ---- */
.table-responsive {
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.table th,
.table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--gray-200);
  font-size: 0.9375rem;
}

.table th {
  background: var(--gray-50);
  font-weight: 600;
  color: var(--gray-600);
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.table tr:last-child td {
  border-bottom: none;
}

.row-inactive {
  opacity: 0.5;
}

/* ---- Badges ---- */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: capitalize;
}

.badge-employee {
  background: #dbeafe;
  color: #1e40af;
}

.badge-supervisor {
  background: #fef3c7;
  color: #92400e;
}

.badge-ops_manager {
  background: #ede9fe;
  color: #5b21b6;
}

.badge-active {
  background: #d1fae5;
  color: #065f46;
}

.badge-inactive {
  background: var(--gray-200);
  color: var(--gray-600);
}

.badge-pending {
  background: #fef3c7;
  color: #92400e;
}

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

@media (min-width: 768px) {
  .modal {
    align-items: center;
  }
}

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

.modal-content {
  position: relative;
  background: white;
  border-radius: 16px 16px 0 0;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

@media (min-width: 768px) {
  .modal-content {
    border-radius: 12px;
  }
}

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

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

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--gray-500);
  padding: 4px;
  line-height: 1;
}

.modal-body {
  padding: 20px;
}

.modal-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--gray-200);
}

/* ---- Timesheet ---- */
.timesheet-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 20px;
}

.timesheet-range {
  font-weight: 600;
  font-size: 1rem;
  min-width: 180px;
  text-align: center;
}

.timesheet-summary {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.summary-card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 20px;
  display: flex;
  flex-direction: column;
  min-width: 120px;
}

.summary-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--gray-500);
  font-weight: 600;
}

.summary-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--gray-900);
  font-variant-numeric: tabular-nums;
}

.timesheet-day {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 12px;
  overflow: hidden;
}

.timesheet-day-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
}

.day-name {
  font-weight: 600;
  font-size: 0.9375rem;
}

.day-hours {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--primary);
}

.timesheet-punch {
  padding: 12px 16px;
  border-bottom: 1px solid var(--gray-100);
}

.timesheet-punch:last-child {
  border-bottom: none;
}

.timesheet-punch.punch-flagged {
  border-left: 3px solid var(--warning);
}

.timesheet-punch.punch-edited {
  border-left: 3px solid var(--primary);
}

.punch-times {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 0.9375rem;
}

.punch-lunch {
  font-size: 0.8125rem;
  color: var(--gray-500);
  margin-top: 4px;
}

.punch-allocations {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--gray-100);
}

.allocation-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  font-size: 0.875rem;
}

.alloc-activity {
  font-weight: 500;
}

.alloc-job {
  color: var(--gray-500);
  font-size: 0.8125rem;
}

.alloc-hours {
  margin-left: auto;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ---- Team Controls ---- */
.team-controls {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 20px;
}

/* ---- Reports ---- */
.reports-controls {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 20px;
}

.report-section {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 16px;
}

.report-section h3 {
  font-size: 1.125rem;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.report-section h4 {
  font-size: 0.9375rem;
  margin-bottom: 6px;
  color: var(--gray-600);
}

.report-total {
  font-size: 0.875rem;
  font-weight: 400;
  color: var(--gray-500);
}

/* ---- Settings ---- */
.settings-card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  max-width: 600px;
}

textarea.form-input {
  resize: vertical;
  font-family: inherit;
}

/* ---- Utilities ---- */
.text-center { text-align: center; }
.text-muted { color: var(--gray-500); }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }

/* Drag handle for reorderable rows */
.drag-handle {
  cursor: grab;
  color: var(--gray-400);
  font-size: 1.1rem;
  vertical-align: middle;
  user-select: none;
}

.drag-handle:hover {
  color: var(--gray-600);
}

tr.dragging {
  opacity: 0.4;
}

tr.drag-over {
  box-shadow: 0 -2px 0 0 var(--primary) inset;
}

/* Mode toggle (General / Job selector) */
.mode-toggle {
  display: flex;
  gap: 0;
  margin-bottom: 16px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--gray-300);
}

.mode-btn {
  flex: 1;
  padding: 10px 16px;
  border: none;
  background: white;
  color: var(--gray-600);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.mode-btn + .mode-btn {
  border-left: 1px solid var(--gray-300);
}

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

.mode-btn:not(.active):hover {
  background: var(--gray-100);
}

/* ---- Overview ---- */
.overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.overview-card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  text-align: center;
}

.overview-card-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--gray-500);
  font-weight: 600;
  margin-bottom: 4px;
}

.overview-card-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--gray-900);
  font-variant-numeric: tabular-nums;
}

/* ---- Admin Tabs ---- */
.admin-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 24px;
  border-bottom: 2px solid var(--gray-200);
}

.admin-tab {
  padding: 10px 20px;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--gray-500);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s;
}

.admin-tab:hover {
  color: var(--gray-700);
}

.admin-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

@media (max-width: 767px) {
  .form-row {
    grid-template-columns: 1fr;
  }
  .admin-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .admin-tab {
    padding: 8px 14px;
    font-size: 0.875rem;
    white-space: nowrap;
  }
}
