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

:root {
  --primary: #e8590c;
  --primary-dark: #c94a08;
  --primary-light: #fff1e8;
  --success: #2f9e44;
  --success-light: #ebfbee;
  --danger: #e03131;
  --danger-light: #fff5f5;
  --bg: #faf7f4;
  --card: #ffffff;
  --text: #2b2420;
  --muted: #8a7d73;
  --border: #ece3db;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 4px 20px rgba(60, 40, 20, 0.06);
  --shadow-lg: 0 10px 40px rgba(60, 40, 20, 0.12);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Cairo', system-ui, sans-serif;
  direction: rtl;
}

body { min-height: 100vh; }

a { color: inherit; text-decoration: none; }

button, input, select, textarea {
  font-family: inherit;
  font-size: 1rem;
}

.hidden { display: none !important; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 22px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, opacity .12s ease;
  box-shadow: 0 2px 10px rgba(232, 89, 12, .25);
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(232, 89, 12, .3); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn.secondary { background: #fff; color: var(--text); border: 1.5px solid var(--border); box-shadow: none; }
.btn.secondary:hover { border-color: var(--primary); color: var(--primary); }
.btn.danger { background: var(--danger); box-shadow: 0 2px 10px rgba(224,49,49,.25); }
.btn.success { background: var(--success); box-shadow: 0 2px 10px rgba(47,158,68,.25); }
.btn.block { width: 100%; }
.btn.sm { padding: 8px 14px; font-size: .88rem; }
.btn.icon { padding: 10px; border-radius: 50%; }

/* Cards */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  border: 1px solid var(--border);
}

/* Forms */
.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 600; font-size: .88rem; margin-bottom: 6px; color: var(--muted); }
.field input, .field select, .field textarea {
  width: 100%;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: #fff;
  color: var(--text);
  outline: none;
  transition: border-color .12s ease;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary); }
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }

.error-msg {
  background: var(--danger-light);
  color: var(--danger);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: .9rem;
  font-weight: 600;
  margin-bottom: 14px;
}
.success-msg {
  background: var(--success-light);
  color: var(--success);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: .9rem;
  font-weight: 600;
  margin-bottom: 14px;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 700;
}
.badge.on { background: var(--success-light); color: var(--success); }
.badge.off { background: #f1efec; color: var(--muted); }

/* Avatar */
.avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: 1rem;
  flex-shrink: 0;
}
.avatar.lg { width: 72px; height: 72px; font-size: 1.6rem; }

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #e0d5ca; border-radius: 10px; }

/* ===== Login page ===== */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: radial-gradient(circle at 30% 20%, #fff1e8 0%, var(--bg) 55%);
}
.login-box { width: 100%; max-width: 420px; }
.login-logo { text-align: center; margin-bottom: 24px; }
.login-logo .emoji { font-size: 3rem; }
.login-logo h1 { margin: 6px 0 2px; font-size: 1.5rem; }
.login-logo p { color: var(--muted); margin: 0; font-size: .92rem; }

.tabs { display: flex; gap: 8px; margin-bottom: 20px; background: #f1ece5; padding: 5px; border-radius: 12px; }
.tabs button {
  flex: 1; padding: 10px; border: none; background: transparent; border-radius: 9px;
  font-weight: 700; color: var(--muted); cursor: pointer; transition: all .15s ease;
}
.tabs button.active { background: #fff; color: var(--primary); box-shadow: var(--shadow); }

.pin-display {
  display: flex; justify-content: center; gap: 12px; margin: 20px 0 26px;
}
.pin-dot {
  width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--border); transition: all .12s ease;
}
.pin-dot.filled { background: var(--primary); border-color: var(--primary); }

.pin-pad {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px;
}
.pin-pad button {
  aspect-ratio: 1; border-radius: 50%; border: 1.5px solid var(--border); background: #fff;
  font-size: 1.4rem; font-weight: 700; cursor: pointer; transition: all .1s ease;
}
.pin-pad button:hover { background: var(--primary-light); border-color: var(--primary); color: var(--primary); }
.pin-pad button:active { transform: scale(.94); }
.pin-pad button.wide { grid-column: span 1; font-size: 1rem; color: var(--muted); border: none; background: none; box-shadow: none; }

/* ===== App shell (admin/employee) ===== */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px; background: #211a15; color: #fff; flex-shrink: 0;
  display: flex; flex-direction: column; padding: 22px 16px;
}
.sidebar .brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 22px; }
.sidebar .brand .emoji { font-size: 1.6rem; }
.sidebar .brand strong { font-size: 1.05rem; }
.sidebar nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.sidebar nav button {
  display: flex; align-items: center; gap: 10px; text-align: right;
  padding: 12px 14px; border-radius: 10px; border: none; background: none;
  color: #cfc3b8; font-weight: 600; cursor: pointer; transition: all .12s ease; font-size: .95rem;
}
.sidebar nav button:hover { background: #2e251e; color: #fff; }
.sidebar nav button.active { background: var(--primary); color: #fff; }
.sidebar nav button .count {
  margin-inline-start: auto; background: var(--danger); color: #fff; font-size: .72rem;
  min-width: 18px; height: 18px; border-radius: 9px; display: flex; align-items: center; justify-content: center; padding: 0 5px;
}
.sidebar .logout-btn { margin-top: 10px; }

.main { flex: 1; padding: 28px 34px; max-width: 1200px; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.topbar h2 { margin: 0; font-size: 1.5rem; }
.topbar .sub { color: var(--muted); font-size: .9rem; margin-top: 2px; }

.grid { display: grid; gap: 18px; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }

.stat-card { padding: 20px; }
.stat-card .label { color: var(--muted); font-size: .85rem; font-weight: 600; }
.stat-card .value { font-size: 1.8rem; font-weight: 800; margin-top: 6px; }
.stat-card .value.small { font-size: 1.3rem; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: right; padding: 12px 10px; border-bottom: 1px solid var(--border); font-size: .92rem; }
th { color: var(--muted); font-weight: 700; font-size: .82rem; text-transform: uppercase; letter-spacing: .3px; }
tr:last-child td { border-bottom: none; }

.pill-list { display: flex; flex-wrap: wrap; gap: 10px; }

/* Employee PIN board */
.pin-board-card {
  display: flex; align-items: center; gap: 14px; padding: 16px 18px;
}
.pin-board-card .pin-number {
  margin-inline-start: auto; font-size: 1.6rem; font-weight: 800; letter-spacing: 3px; color: var(--primary);
  background: var(--primary-light); padding: 6px 16px; border-radius: 10px;
}

/* Chat */
.chat-wrap { display: flex; gap: 18px; height: calc(100vh - 150px); }
.chat-threads { width: 280px; flex-shrink: 0; overflow-y: auto; }
.thread-item {
  display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: 12px; cursor: pointer; margin-bottom: 6px;
}
.thread-item:hover, .thread-item.active { background: var(--primary-light); }
.thread-item .info { flex: 1; min-width: 0; }
.thread-item .info .name { font-weight: 700; font-size: .92rem; }
.thread-item .info .preview { font-size: .8rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread-item .unread { background: var(--primary); color: #fff; font-size: .72rem; min-width: 20px; height: 20px; border-radius: 10px; display: flex; align-items: center; justify-content: center; }

.chat-panel { flex: 1; display: flex; flex-direction: column; }
.chat-messages { flex: 1; overflow-y: auto; padding: 10px 6px; display: flex; flex-direction: column; gap: 10px; }
.msg-bubble { max-width: 65%; padding: 10px 15px; border-radius: 16px; font-size: .92rem; line-height: 1.5; }
.msg-bubble.mine { align-self: flex-end; background: var(--primary); color: #fff; border-bottom-left-radius: 4px; }
.msg-bubble.theirs { align-self: flex-start; background: #f1ece5; color: var(--text); border-bottom-right-radius: 4px; }
.msg-bubble .time { display: block; font-size: .68rem; opacity: .7; margin-top: 4px; }
.chat-input-row { display: flex; gap: 10px; margin-top: 12px; }
.chat-input-row input { flex: 1; }

/* Employee dashboard clock */
.clock-card { text-align: center; padding: 32px; }
.clock-time { font-size: 2.6rem; font-weight: 800; margin: 6px 0; font-variant-numeric: tabular-nums; }
.clock-status { color: var(--muted); font-weight: 600; margin-bottom: 20px; }
.clock-earn { font-size: 2.2rem; font-weight: 800; color: var(--success); margin: 4px 0; }

.shift-item, .coworker-item {
  display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 12px; background: #faf7f4; margin-bottom: 8px;
}
.shift-item .date-badge, .coworker-item .time-badge {
  background: var(--primary-light); color: var(--primary); font-weight: 700; font-size: .8rem;
  padding: 6px 10px; border-radius: 8px; white-space: nowrap;
}

.modal-overlay {
  position: fixed; inset: 0; background: rgba(30,20,10,.45); display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 20px;
}
.modal-box { background: #fff; border-radius: var(--radius); padding: 26px; width: 100%; max-width: 460px; box-shadow: var(--shadow-lg); }
.modal-box h3 { margin-top: 0; }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; }

.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty-state .emoji { font-size: 2.4rem; display: block; margin-bottom: 8px; }

.color-swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.color-swatch { width: 30px; height: 30px; border-radius: 50%; cursor: pointer; border: 2px solid transparent; }
.color-swatch.selected { border-color: var(--text); }

@media (max-width: 860px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; align-items: center; padding: 12px 16px; overflow-x: auto; }
  .sidebar .brand { padding: 0 12px 0 0; }
  .sidebar nav { flex-direction: row; }
  .sidebar .logout-btn { margin-top: 0; }
  .main { padding: 18px; }
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
  .chat-wrap { flex-direction: column; height: auto; }
  .chat-threads { width: 100%; max-height: 200px; }
}
