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

:root {
  --ink: #0a0f1a;
  --paper: #f8f6f1;
  --accent: #e85d26;
  --accent-hover: #d14d1a;
  --accent-light: #fff0ea;
  --muted: #6b7280;
  --border: #e5e2db;
  --card-bg: #ffffff;
  --danger: #dc2626;
  --danger-light: #fef2f2;
  --success: #16a34a;
  --success-light: #f0fdf4;
  --warning: #d97706;
  --warning-light: #fffbeb;
  --sidebar-width: 240px;
}

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--paper);
  color: var(--ink);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* ============ AUTH PAGES ============ */

.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: var(--paper);
}

.auth-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 3rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.04);
}

.auth-logo {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 1.6rem;
  letter-spacing: -0.5px;
  margin-bottom: 0.25rem;
}

.auth-logo span { color: var(--accent); }

.auth-subtitle {
  color: var(--muted);
  font-size: 0.95rem;
  margin-bottom: 2rem;
}

.auth-card h2 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

/* ============ FORMS ============ */

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

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

.form-input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
  background: var(--paper);
  color: var(--ink);
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}

.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.form-input::placeholder {
  color: #b0b0b0;
}

textarea.form-input {
  resize: vertical;
  min-height: 80px;
}

select.form-input {
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%236b7280' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  padding-right: 2.5rem;
}

/* ============ BUTTONS ============ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 10px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

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

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

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

.btn-secondary {
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--border);
}

.btn-secondary:hover { background: #f0ede8; }

.btn-ghost {
  background: transparent;
  color: var(--accent);
  padding: 0.5rem 0.75rem;
}

.btn-ghost:hover { background: var(--accent-light); }

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

.btn-danger:hover { background: #fde8e8; }

.btn-sm {
  padding: 0.45rem 0.85rem;
  font-size: 0.85rem;
  border-radius: 8px;
}

.btn-block {
  width: 100%;
}

/* ============ APP LAYOUT ============ */

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

.sidebar {
  width: var(--sidebar-width);
  background: var(--ink);
  color: #fff;
  padding: 1.5rem 0;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: transform 0.3s;
}

.sidebar-logo {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 1.35rem;
  padding: 0 1.5rem;
  margin-bottom: 0.25rem;
  letter-spacing: -0.5px;
}

.sidebar-logo span { color: var(--accent); }

.sidebar-restaurant {
  font-size: 0.8rem;
  color: rgba(255,255,255,0.5);
  padding: 0 1.5rem;
  margin-bottom: 2rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0 0.75rem;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0.75rem;
  border-radius: 10px;
  color: rgba(255,255,255,0.65);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.15s;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.sidebar-link:hover {
  background: rgba(255,255,255,0.08);
  color: #fff;
}

.sidebar-link.active {
  background: rgba(232, 93, 38, 0.15);
  color: var(--accent);
}

.sidebar-link .icon {
  font-size: 1.15rem;
  width: 24px;
  text-align: center;
}

.sidebar-divider {
  height: 1px;
  background: rgba(255,255,255,0.1);
  margin: 0.75rem 0.75rem;
}

.sidebar-user {
  padding: 1rem 1.25rem;
  border-top: 1px solid rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.sidebar-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
  flex-shrink: 0;
}

.sidebar-user-info {
  flex: 1;
  min-width: 0;
}

.sidebar-user-name {
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.45);
  text-transform: capitalize;
}

.main-wrapper {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 2rem;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
}

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

.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.25rem;
  color: var(--ink);
}

.main-content {
  padding: 2rem;
  max-width: 1100px;
}

/* ============ CARDS ============ */

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.75rem;
}

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

.card-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
}

/* ============ STATS ============ */

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

.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.5rem;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
  margin-bottom: 0.4rem;
}

.stat-value {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.2;
}

.stat-value.accent { color: var(--accent); }
.stat-value.success { color: var(--success); }

/* ============ BADGES ============ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.65rem;
  border-radius: 100px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-opening { background: var(--warning-light); color: var(--warning); }
.badge-closing { background: #f0f0ff; color: #5b21b6; }
.badge-admin { background: var(--accent-light); color: var(--accent); }
.badge-employee { background: #f0f4ff; color: #3b82f6; }
.badge-announcement { background: var(--accent-light); color: var(--accent); }
.badge-shift_swap { background: #ecfdf5; color: #059669; }
.badge-general { background: #f0f4ff; color: #3b82f6; }
.badge-pinned { background: var(--warning-light); color: var(--warning); }

/* ============ CHECKLISTS ============ */

.checklist-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.25rem;
}

.checklist-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.75rem;
  transition: transform 0.15s, box-shadow 0.15s;
  cursor: pointer;
}

.checklist-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.06);
}

.checklist-card.completed {
  border-color: var(--success);
  background: var(--success-light);
}

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

.checklist-card h3 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
}

.checklist-card .item-count {
  font-size: 0.85rem;
  color: var(--muted);
}

.checklist-items {
  list-style: none;
  padding: 0;
}

.checklist-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: opacity 0.15s;
}

.checklist-item:last-child { border-bottom: none; }

.checklist-item.checked .item-text {
  text-decoration: line-through;
  color: var(--muted);
}

.check-circle {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s;
  font-size: 0.8rem;
}

.checklist-item.checked .check-circle {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}

.item-text {
  font-size: 0.95rem;
  transition: all 0.15s;
}

.progress-bar-wrapper {
  background: var(--border);
  border-radius: 100px;
  height: 8px;
  margin: 1.25rem 0;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  border-radius: 100px;
  background: var(--accent);
  transition: width 0.4s ease;
}

.progress-bar.complete { background: var(--success); }

.progress-text {
  font-size: 0.85rem;
  color: var(--muted);
  text-align: center;
  margin-bottom: 1rem;
}

.completion-success {
  text-align: center;
  padding: 2rem 0;
}

.completion-success .check-big {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--success);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  color: #fff;
  margin-bottom: 1rem;
}

.completion-success h3 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.completion-success p {
  color: var(--muted);
  font-size: 0.95rem;
}

/* ============ MESSAGES ============ */

.message-compose {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.compose-row {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.compose-row:last-child { margin-bottom: 0; }

.message-feed {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.message-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.25rem 1.5rem;
  transition: box-shadow 0.15s;
}

.message-card.pinned {
  border-color: var(--warning);
  background: var(--warning-light);
}

.message-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}

.message-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.65rem;
  color: #fff;
  flex-shrink: 0;
}

.message-author {
  font-weight: 600;
  font-size: 0.9rem;
}

.message-meta {
  font-size: 0.75rem;
  color: var(--muted);
  margin-left: auto;
}

.message-title {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 0.35rem;
}

.message-content {
  font-size: 0.92rem;
  color: #374151;
  line-height: 1.6;
  white-space: pre-wrap;
}

.message-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

/* ============ TEAM ============ */

.team-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.team-member {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.team-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  color: #fff;
  flex-shrink: 0;
}

.team-info h4 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
}

.team-info p {
  font-size: 0.8rem;
  color: var(--muted);
}

/* ============ JOIN CODE CARD ============ */

.join-code-card {
  background: var(--ink);
  color: #fff;
  border-radius: 16px;
  padding: 1.75rem;
  margin-bottom: 1.5rem;
}

.join-code-card h3 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.join-code-card p {
  color: rgba(255,255,255,0.6);
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

.join-code-display {
  font-family: 'Space Grotesk', monospace;
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 4px;
  color: var(--accent);
  background: rgba(255,255,255,0.08);
  padding: 0.75rem 1.5rem;
  border-radius: 10px;
  display: inline-block;
}

/* ============ ACTIVITY FEED ============ */

.activity-item {
  display: flex;
  gap: 0.75rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.activity-item:last-child { border-bottom: none; }

.activity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 0.5rem;
  flex-shrink: 0;
}

.activity-dot.checklist { background: var(--success); }
.activity-dot.message { background: #3b82f6; }

.activity-time {
  font-size: 0.75rem;
  color: var(--muted);
}

/* ============ EMPTY STATE ============ */

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--muted);
}

.empty-state .icon {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
  opacity: 0.5;
}

.empty-state h3 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 0.35rem;
}

.empty-state p {
  font-size: 0.9rem;
}

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

#toast-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  padding: 0.85rem 1.25rem;
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 500;
  transform: translateX(120%);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  max-width: 350px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}

.toast.show { transform: translateX(0); opacity: 1; }
.toast-success { background: var(--success); color: #fff; }
.toast-error { background: var(--danger); color: #fff; }
.toast-info { background: var(--ink); color: #fff; }

/* ============ LOADING ============ */

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  color: var(--muted);
  gap: 0.5rem;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2.5px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ============ TABS ============ */

.tabs {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
}

.tab {
  padding: 0.6rem 1.25rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted);
  border: none;
  background: none;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all 0.15s;
  font-family: 'DM Sans', sans-serif;
}

.tab:hover { color: var(--ink); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ============ MISC ============ */

.auth-links {
  text-align: center;
  margin-top: 1.5rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.auth-links a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.auth-links a:hover { text-decoration: underline; }

.error-text {
  color: var(--danger);
  font-size: 0.85rem;
  margin-top: 0.35rem;
}

.section-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

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

.text-muted { color: var(--muted); }
.text-sm { font-size: 0.85rem; }
.text-center { text-align: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }

/* ============ TEMPLATE EDITOR (Admin) ============ */

.template-items-editor {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.template-item-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.template-item-row input {
  flex: 1;
}

.template-item-row .remove-item {
  background: none;
  border: none;
  color: var(--danger);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.25rem;
  line-height: 1;
}

/* ============ MODAL ============ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 1rem;
}

.modal {
  background: var(--card-bg);
  border-radius: 20px;
  padding: 2rem;
  max-width: 520px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}

.modal h2 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
}

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

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

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-wrapper {
    margin-left: 0;
  }

  .mobile-menu-btn {
    display: block;
  }

  .main-content {
    padding: 1.25rem;
  }

  .topbar {
    padding: 1rem 1.25rem;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }

  .grid-2 {
    grid-template-columns: 1fr;
  }

  .checklist-grid {
    grid-template-columns: 1fr;
  }

  .team-grid {
    grid-template-columns: 1fr;
  }

  .auth-card {
    padding: 2rem;
  }

  .compose-row {
    flex-direction: column;
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }
}
