@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --bg: #f8fafc;
  --bg-card: #ffffff;
  --bg-sidebar: #1e293b;
  --text: #1e293b;
  --text-light: #64748b;
  --border: #e2e8f0;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --success: #22c55e;
  --warning: #f59e0b;
  --sidebar-w: 240px;
}

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

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* --- Admin Login --- */
.admin-login-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 1rem;
  background: #f1f5f9;
}

.admin-login-card {
  background: white;
  border-radius: 1rem;
  padding: 2.5rem;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
}

.admin-login-card h1 {
  font-size: 1.5rem;
  margin-bottom: 0.25rem;
  text-align: center;
}

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

.admin-login-card .microsoft-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: white;
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
  text-decoration: none;
  margin-bottom: 1.5rem;
}

.admin-login-card .microsoft-btn:hover { background: #f8fafc; }

.admin-login-card .divider {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  color: var(--text-light);
  font-size: 0.85rem;
}

.admin-login-card .divider::before,
.admin-login-card .divider::after {
  content: '';
  flex: 1;
  border-top: 1px solid var(--border);
}

.admin-login-card .breakglass-toggle {
  text-align: center;
  margin-bottom: 1rem;
}

.admin-login-card .breakglass-toggle button {
  background: none;
  border: none;
  color: var(--text-light);
  font-size: 0.85rem;
  cursor: pointer;
  text-decoration: underline;
}

.breakglass-form { display: none; }
.breakglass-form.visible { display: block; }

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

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
  color: var(--text-light);
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  font-size: 0.9rem;
  font-family: 'Inter', sans-serif;
  color: var(--text);
  background: white;
  transition: border-color 0.2s;
}

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

.btn {
  padding: 0.6rem 1.25rem;
  border: none;
  border-radius: 0.5rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  font-family: 'Inter', sans-serif;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: var(--danger-hover); }
.btn-success { background: var(--success); color: white; }
.btn-secondary { background: #e2e8f0; color: var(--text); }
.btn-secondary:hover { background: #cbd5e1; }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; }
.btn-full { width: 100%; }

.login-error {
  background: #fef2f2;
  color: var(--danger);
  padding: 0.75rem;
  border-radius: 0.5rem;
  text-align: center;
  margin-bottom: 1rem;
  font-weight: 500;
  font-size: 0.9rem;
  display: none;
}

.login-error.visible { display: block; }

/* --- Dashboard Layout --- */
.admin-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  color: white;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  overflow-y: auto;
  z-index: 100;
}

.sidebar-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-header h1 {
  font-size: 1.2rem;
  font-weight: 700;
}

.sidebar-header .role {
  font-size: 0.8rem;
  color: #94a3b8;
}

.sidebar-nav {
  list-style: none;
  padding: 0.5rem 0;
}

.sidebar-nav li a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 1.5rem;
  color: #94a3b8;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.2s;
}

.sidebar-nav li a:hover { color: white; background: rgba(255, 255, 255, 0.05); }
.sidebar-nav li a.active { color: white; background: rgba(59, 130, 246, 0.2); border-right: 3px solid var(--primary); }

.sidebar-footer {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 1rem 1.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-footer button {
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  font-size: 0.85rem;
  font-family: 'Inter', sans-serif;
}

.sidebar-footer button:hover { color: white; }

.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 2rem;
  min-height: 100vh;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
}

/* --- Cards --- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}

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

.card-title {
  font-size: 1rem;
  font-weight: 700;
}

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

.stat-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 1.25rem;
  text-align: center;
}

.stat-card .emoji { font-size: 2rem; margin-bottom: 0.5rem; }
.stat-card .name { font-weight: 700; font-size: 1rem; }
.stat-card .balance { color: var(--primary); font-weight: 700; font-size: 1.25rem; margin-top: 0.25rem; }
.stat-card .total { color: var(--text-light); font-size: 0.8rem; }

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

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

th {
  text-align: left;
  padding: 0.6rem 0.75rem;
  background: #f8fafc;
  border-bottom: 2px solid var(--border);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  color: var(--text-light);
  white-space: nowrap;
}

td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

tr:hover td { background: #f8fafc; }

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

/* --- Modal --- */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 200;
}

.modal {
  background: white;
  border-radius: 0.75rem;
  padding: 1.5rem;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
}

.modal h2 {
  font-size: 1.2rem;
  margin-bottom: 1rem;
}

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

/* --- Event notices --- */
.event-card {
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  margin-bottom: 0.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
}

.event-card.suspicious { background: #fef3c7; border: 1px solid #f59e0b; }
.event-card.system { background: #f0f9ff; border: 1px solid #3b82f6; }
.event-card.adjustment { background: #f0fdf4; border: 1px solid #22c55e; }

.event-card .event-time { font-size: 0.75rem; color: var(--text-light); }
.event-card .dismiss-btn {
  background: none;
  border: none;
  color: var(--text-light);
  cursor: pointer;
  font-size: 1.2rem;
}

/* --- Toggle switch --- */
.toggle {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 24px;
}

.toggle input { opacity: 0; width: 0; height: 0; }

.toggle .slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: #cbd5e1;
  border-radius: 24px;
  transition: 0.3s;
}

.toggle .slider::before {
  content: '';
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: 0.3s;
}

.toggle input:checked + .slider { background: var(--primary); }
.toggle input:checked + .slider::before { transform: translateX(18px); }

/* --- Pagination --- */
.pagination {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1rem;
}

.pagination button {
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.35rem;
  background: white;
  cursor: pointer;
  font-size: 0.85rem;
}

.pagination button.active { background: var(--primary); color: white; border-color: var(--primary); }
.pagination button:disabled { opacity: 0.5; cursor: not-allowed; }

/* --- Responsive --- */
@media (max-width: 768px) {
  .sidebar { width: 100%; position: relative; }
  .main-content { margin-left: 0; }
  .admin-layout { flex-direction: column; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}

/* --- Misc --- */
.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 1rem;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-active { background: #dcfce7; color: #166534; }
.badge-inactive { background: #fee2e2; color: #991b1b; }

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

.flex-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }

/* --- Emoji Picker --- */
.emoji-picker-wrapper {
  position: relative;
}

.emoji-selected-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.emoji-preview {
  font-size: 1.75rem;
  width: 2.5rem;
  height: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: #f8fafc;
  flex-shrink: 0;
}

.emoji-search {
  flex: 1;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  font-size: 0.9rem;
  font-family: 'Inter', sans-serif;
  color: var(--text);
  background: white;
  transition: border-color 0.2s;
}

.emoji-search:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  max-height: 180px;
  overflow-y: auto;
  margin-top: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 0.35rem;
  background: #f8fafc;
}

.emoji-btn {
  font-size: 1.35rem;
  padding: 0.3rem;
  border: none;
  background: transparent;
  border-radius: 0.35rem;
  cursor: pointer;
  text-align: center;
  line-height: 1;
  transition: background 0.15s;
}

.emoji-btn:hover {
  background: #e2e8f0;
}

/* --- Checkbox Group (Assignees) --- */
.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  font-size: 0.85rem;
  cursor: pointer;
  background: #f8fafc;
  transition: background 0.15s, border-color 0.15s;
}

.checkbox-label:has(input:checked) {
  background: #eff6ff;
  border-color: var(--primary);
}

.checkbox-label input[type="checkbox"] {
  margin: 0;
}

/* --- Day-of-Week Picker --- */
.day-picker {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.day-chip {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  padding: 0.4rem 0;
  border: 2px solid var(--border);
  border-radius: 0.5rem;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  background: #f8fafc;
  transition: all 0.15s;
  text-align: center;
}

.day-chip input[type="checkbox"] {
  display: none;
}

.day-chip.selected {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

/* --- Custom Date Rows --- */
.custom-date-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.custom-date-row input[type="date"] {
  flex: 1;
}

/* --- Searchable Multi-Select --- */
.searchable-multi-select {
  position: relative;
  border: 2px solid var(--border);
  border-radius: 0.5rem;
  padding: 0.35rem;
  background: white;
}

.sms-selected {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-bottom: 0.25rem;
}

.sms-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background: var(--primary-light, #e8f0fe);
  color: var(--primary);
  border-radius: 1rem;
  padding: 0.15rem 0.5rem;
  font-size: 0.82rem;
  font-weight: 500;
}

.sms-tag button {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 1rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.sms-search {
  width: 100%;
  border: none;
  outline: none;
  padding: 0.3rem 0.25rem;
  font-size: 0.9rem;
  background: transparent;
}

.sms-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  max-height: 180px;
  overflow-y: auto;
  background: white;
  border: 2px solid var(--border);
  border-top: none;
  border-radius: 0 0 0.5rem 0.5rem;
  z-index: 20;
}

.sms-option {
  padding: 0.4rem 0.6rem;
  cursor: pointer;
  font-size: 0.88rem;
}

.sms-option:hover {
  background: var(--bg);
}

.sms-option-selected {
  background: var(--primary-light, #e8f0fe);
  font-weight: 500;
}

/* --- Points Buttons --- */
.points-btn-group {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
}

.points-btn {
  flex: 1;
  padding: 0.5rem 0.25rem;
  border: 2px solid var(--border);
  border-radius: 0.5rem;
  background: white;
  font-size: 0.9rem;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s;
}

.points-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

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

.points-custom-input {
  display: none;
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  font-size: 0.9rem;
  font-family: 'Inter', sans-serif;
  color: var(--text);
  background: white;
}

.points-custom-input.visible {
  display: block;
}

.points-custom-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}
