/* ============================================================
   HotelClockIn - Main Stylesheet
   ============================================================ */

:root {
  --primary: #4f46e5;
  --primary-dark: #3730a3;
  --primary-light: #e0e7ff;
  --surface: #ffffff;
  --bg: #f8fafc;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --sidebar-w: 240px;
}

* { box-sizing: border-box; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
}

/* ---- Toast ---- */
#toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  transition: all 0.3s ease;
}
#toast.show { display: block !important; }

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

.sidebar {
  width: var(--sidebar-w);
  background: #1e1b4b;
  color: #c7d2fe;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 100;
  transition: transform 0.3s ease;
  overflow-y: auto;
}

.sidebar-logo {
  padding: 20px 16px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-logo .logo-text {
  font-size: 1.2rem;
  font-weight: 700;
  color: white;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-logo .logo-icon {
  width: 32px;
  height: 32px;
  background: var(--primary);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.sidebar-nav {
  padding: 12px 8px;
  flex: 1;
}

.sidebar-section-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #818cf8;
  padding: 8px 8px 4px;
  font-weight: 600;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  color: #c7d2fe;
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.15s;
  margin-bottom: 2px;
}

.sidebar-link:hover {
  background: rgba(255,255,255,0.1);
  color: white;
}

.sidebar-link.active {
  background: var(--primary);
  color: white;
}

.sidebar-link .badge {
  margin-left: auto;
  background: #ef4444;
  color: white;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  min-width: 18px;
  text-align: center;
}

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

.sidebar-user .user-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: white;
  line-height: 1.2;
}

.sidebar-user .user-role {
  font-size: 0.7rem;
  color: #a5b4fc;
}

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

.top-bar {
  background: white;
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.page-content {
  padding: 24px;
  flex: 1;
}

/* ---- Cards ---- */
.card {
  background: white;
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 20px;
}

.stat-card {
  background: white;
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stat-card .stat-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

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

.stat-card .stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* ---- Shift badges ---- */
.shift-cell {
  padding: 4px 6px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  text-align: center;
  min-width: 58px;
  cursor: pointer;
  transition: opacity 0.15s;
  border: 1px solid transparent;
}

.shift-cell:hover { opacity: 0.8; }

.shift-work   { background: #dbeafe; color: #1d4ed8; border-color: #bfdbfe; }
.shift-off    { background: #fef3c7; color: #b45309; border-color: #fde68a; }
.shift-oncall { background: #f3e8ff; color: #7c3aed; border-color: #e9d5ff; }
.shift-open   { background: #dcfce7; color: #15803d; border-color: #bbf7d0; }

/* ---- Schedule table ---- */
.schedule-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.82rem;
}

.schedule-table th {
  background: #f8fafc;
  padding: 10px 8px;
  text-align: center;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.schedule-table th:first-child { text-align: left; }

.schedule-table td {
  padding: 8px;
  border-bottom: 1px solid #f1f5f9;
  text-align: center;
  vertical-align: middle;
}

.schedule-table td:first-child { text-align: left; }

.schedule-table tr:hover td { background: #f8fafc; }

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

.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.875rem;
  color: var(--text);
  background: white;
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}

.form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

.form-select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.875rem;
  color: var(--text);
  background: white;
  outline: none;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%236b7280'%3E%3Cpath d='M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px;
  padding-right: 36px;
}

.form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  border: none;
  text-decoration: none;
}

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

.btn-secondary {
  background: white;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: #f8fafc; }

.btn-danger {
  background: #ef4444;
  color: white;
}
.btn-danger:hover { background: #dc2626; }

.btn-success {
  background: #22c55e;
  color: white;
}
.btn-success:hover { background: #16a34a; }

.btn-sm {
  padding: 5px 12px;
  font-size: 0.8rem;
}

.btn-xs {
  padding: 3px 10px;
  font-size: 0.75rem;
  border-radius: 6px;
}

/* ---- Modal ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal {
  background: white;
  border-radius: 14px;
  padding: 24px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}

.modal-close {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: none;
  background: #f1f5f9;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  color: var(--text-muted);
}
.modal-close:hover { background: #e2e8f0; }

/* ---- Avatar ---- */
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.avatar-sm {
  width: 28px;
  height: 28px;
  font-size: 0.7rem;
}

/* ---- Table ---- */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.data-table th {
  text-align: left;
  padding: 10px 16px;
  background: #f8fafc;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid #f1f5f9;
  color: var(--text);
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: #f8fafc; }

/* ---- Mobile sidebar toggle ---- */
.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  color: var(--text);
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
}

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

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

  .sidebar-overlay.open {
    display: block;
  }

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

  .sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .page-content {
    padding: 16px;
  }

  .hide-mobile { display: none !important; }

  .schedule-table {
    font-size: 0.7rem;
  }

  .shift-cell {
    min-width: 44px;
    padding: 3px 4px;
    font-size: 0.65rem;
  }
}

/* ---- Notification dot ---- */
.notif-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: #ef4444;
  border-radius: 50%;
  margin-left: 6px;
  vertical-align: middle;
}

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

.page-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}

.page-subtitle {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin: 2px 0 0;
}

/* ---- Empty state ---- */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state .empty-icon {
  font-size: 3rem;
  margin-bottom: 12px;
  opacity: 0.4;
}

.empty-state p {
  margin: 4px 0 0;
  font-size: 0.875rem;
}

/* ---- Loading ---- */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(79,70,229,0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* ---- Tabs ---- */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
  gap: 0;
}

.tab {
  padding: 10px 20px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.15s;
}

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

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

/* ---- Chip / Filter ---- */
.chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border);
  background: white;
  color: var(--text-muted);
  transition: all 0.15s;
}

.chip:hover { border-color: var(--primary); color: var(--primary); }
.chip.active { background: var(--primary-light); border-color: var(--primary); color: var(--primary); }

/* ---- Week navigation ---- */
.week-nav {
  display: flex;
  align-items: center;
  gap: 12px;
  background: white;
  border: 1px solid var(--border);
  padding: 8px 16px;
  border-radius: 10px;
}

.week-nav .week-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  min-width: 180px;
  text-align: center;
}

.week-nav button {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: var(--text-muted);
  border-radius: 4px;
}

.week-nav button:hover {
  background: #f1f5f9;
  color: var(--text);
}

/* ---- Room tracking grid ---- */
.room-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.room-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
}

.room-card .room-name {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text);
}

.room-card .room-count {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1;
  margin: 6px 0 2px;
}

.room-card .room-pay {
  font-size: 0.8rem;
  color: #22c55e;
  font-weight: 600;
}
