/* =================================================================
   Aivirinchi Employee Portal — styles
   Theme: navy #0a263e · gold #e4a218 · green #15663c · cream #f8f3ed
   ================================================================= */

:root {
  --bg:         #f8f3ed;
  --bg-soft:    #efe7d8;
  --surface:    #ffffff;
  --surface-2:  #faf6ee;
  --border:     #e7decd;
  --text:       #1c3247;
  --ink:        #0a263e;
  --muted:      #5d6b78;
  --navy:       #0a263e;
  --navy-2:     #15486f;
  --gold:       #e4a218;
  --gold-deep:  #c4881a;
  --green:      #15663c;
  --danger:     #b91c1c;
  --radius:     16px;
  --radius-sm:  10px;
  --shadow:     0 16px 40px rgba(10, 38, 62, 0.10);
  --shadow-sm:  0 6px 16px rgba(10, 38, 62, 0.08);
  --grad:       linear-gradient(120deg, #0a263e, #15486f);
  --maxw:       960px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background:
    radial-gradient(1100px 520px at 85% -8%, rgba(228, 162, 24, 0.12), transparent 60%),
    radial-gradient(900px 480px at -8% 8%,  rgba(21, 102, 60, 0.10),  transparent 55%),
    var(--bg);
  color: var(--text);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--green); text-decoration: none; }
h1, h2, h3 { color: var(--ink); margin: 0 0 12px; line-height: 1.2; }
h1 { font-size: 1.6rem; font-weight: 800; }
h2 { font-size: 1.2rem; font-weight: 700; }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 22px; }

/* ── Top bar ─────────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(248, 243, 237, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 68px;
}

/* ── Brand / logo ────────────────────────────────────────────── */
.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  font-weight: 800;
  font-size: 1.2rem;
  color: var(--navy);
  text-decoration: none;
}
.brand b { color: var(--green); }
.brand .logo-mark {
  width: 42px; height: 42px;
  border-radius: 11px;
  object-fit: contain;
  background: #fff;
  border: 1px solid var(--border);
  padding: 3px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.brand:hover .logo-mark {
  transform: scale(1.12);
  box-shadow: 0 8px 20px rgba(10, 38, 62, 0.18);
}

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: none;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
  font-family: inherit;
  padding: 10px 20px;
  border-radius: 999px;
  background: var(--grad);
  color: #fff;
  box-shadow: 0 10px 22px rgba(10, 38, 62, 0.22);
  transition: transform 0.15s ease, box-shadow 0.2s ease;
  text-decoration: none;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 14px 28px rgba(10, 38, 62, 0.30); color: #fff; }
.btn.full  { width: 100%; justify-content: center; margin-top: 20px; }
.btn.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--border);
  box-shadow: none;
}
.btn.ghost:hover { border-color: var(--navy); background: var(--surface-2); }

/* ── Alerts ──────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  font-weight: 500;
  margin-bottom: 18px;
}
.alert.err { background: rgba(185,28,28,0.08); color: var(--danger); border: 1px solid rgba(185,28,28,0.22); }
.alert.ok  { background: rgba(21,102,60,0.10); color: var(--green);  border: 1px solid rgba(21,102,60,0.28); }

/* ── Auth / login card ───────────────────────────────────────── */
.auth {
  min-height: calc(100vh - 68px);
  display: grid;
  place-items: center;
  padding: 48px 22px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 38px;
  width: 100%;
  max-width: 440px;
}
.card h1 { font-size: 1.5rem; margin-bottom: 4px; }
.sub { color: var(--muted); margin: 0 0 24px; font-size: 0.97rem; }

/* ── Form fields ─────────────────────────────────────────────── */
label {
  display: block;
  font-size: 0.88rem;
  color: var(--muted);
  font-weight: 500;
  margin: 16px 0 6px;
}
input, select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font: inherit;
  color: var(--ink);
  transition: border-color 0.2s, box-shadow 0.2s;
}
input:focus, select:focus {
  outline: none;
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(10, 38, 62, 0.10);
}

/* ── Dashboard layout ────────────────────────────────────────── */
.page { padding: 36px 0 60px; }
.row  { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 28px; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 28px;
  margin-bottom: 24px;
}
.panel h2 {
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
  color: var(--navy);
}

.meta { color: var(--muted); font-size: 0.88rem; }

/* ── Table ───────────────────────────────────────────────────── */
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.93rem; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--border); }
th {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  background: var(--surface-2);
}
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }

/* ── Badges ──────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 3px 11px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
}
.badge.active   { background: rgba(21,102,60,0.12);  color: var(--green); }
.badge.disabled { background: rgba(185,28,28,0.10);  color: var(--danger); }
.badge.admin    { background: rgba(228,162,24,0.16); color: var(--gold-deep); }

/* ── Add-employee form grid ──────────────────────────────────── */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 4px; }

/* ── Portal label in topbar ─────────────────────────────────────── */
.portal-label { color: var(--muted); font-weight: 500; font-size: 0.9rem; margin-left: 2px; }

/* ── User info + avatar (top-right) ─────────────────────────────── */
.user-info { text-align: right; line-height: 1.3; }
.user-name  { display: block; font-weight: 700; font-size: 0.92rem; color: var(--ink); }
.user-sub   { display: block; font-size: 0.75rem; color: var(--muted); }
.role-tag {
  display: inline-block; font-size: 0.68rem; font-weight: 700;
  background: rgba(228,162,24,0.16); color: var(--gold-deep);
  border-radius: 999px; padding: 1px 7px; vertical-align: middle; margin-left: 4px;
}
.avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--grad); color: #fff;
  display: grid; place-items: center;
  font-weight: 800; font-size: 1rem; flex-shrink: 0;
  box-shadow: var(--shadow-sm);
  border: 2px solid rgba(255,255,255,0.5);
  cursor: default; user-select: none;
}

/* ── Attendance rules info box ───────────────────────────────────── */
.att-rules {
  display: flex; flex-wrap: wrap; gap: 10px;
  background: rgba(10,38,62,0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px; margin-bottom: 16px;
}
.att-rule {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.82rem; color: var(--muted); flex: 1; min-width: 200px;
}
.rule-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.rule-dot.auto  { background: var(--green); }
.rule-dot.force { background: var(--gold); }
.rule-dot.rule  { background: var(--navy); }

/* ── Attendance card ─────────────────────────────────────────────── */
.date-chip {
  font-size: 0.8rem; font-weight: 500; color: var(--muted);
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 999px; padding: 3px 12px; margin-left: 10px;
  vertical-align: middle;
}
.att-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  overflow: hidden; margin-bottom: 20px;
}
.att-col:first-child { border-right: 1px solid var(--border); }
.att-col-head {
  font-size: 0.78rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.8px; color: var(--muted);
  background: var(--surface-2); padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}
.att-row {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
}
.att-row:last-child { border-bottom: none; }
.att-type {
  font-size: 0.75rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.5px; color: var(--muted); min-width: 38px;
}
.att-type.force { color: var(--gold-deep); }
.att-time { font-size: 0.9rem; font-weight: 600; color: var(--ink); min-width: 72px; }

.btn-sm {
  display: inline-flex; align-items: center;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--ink);
  font: 600 0.78rem/1 "Inter", sans-serif;
  padding: 6px 12px; border-radius: 999px; cursor: pointer; white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, transform 0.15s;
}
.btn-sm:hover:not(:disabled) { border-color: var(--navy); background: var(--bg-soft); transform: translateY(-1px); }
.btn-sm.primary { background: var(--grad); color: #fff; border-color: transparent; box-shadow: 0 4px 10px rgba(10,38,62,.2); }
.btn-sm.primary:hover:not(:disabled) { box-shadow: 0 6px 14px rgba(10,38,62,.28); }
.btn-sm:disabled { opacity: 0.45; cursor: not-allowed; }

.force-form { display: flex; align-items: center; gap: 6px; }
.force-form input[type="datetime-local"] {
  width: auto; padding: 6px 10px; font-size: 0.78rem;
  border-radius: var(--radius-sm); border: 1px solid var(--border);
}

.att-summary {
  display: flex; align-items: center;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); overflow: hidden;
}
.att-stat { flex: 1; padding: 14px 20px; text-align: center; }
.att-stat-divider { width: 1px; background: var(--border); align-self: stretch; }
.att-stat-label {
  display: block; font-size: 0.72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.6px; color: var(--muted); margin-bottom: 4px;
}
.att-stat-val { display: block; font-size: 1.05rem; font-weight: 700; color: var(--ink); }
.att-stat-val.hours { color: var(--green); }
.empty-row { text-align: center; padding: 28px 0 !important; color: var(--muted); font-size: 0.9rem; }

/* ── 3-column dashboard grid ─────────────────────────────────────── */
.dash-grid {
  display: grid;
  grid-template-columns: 0.9fr 1.4fr 0.7fr;
  gap: 22px;
  align-items: start;
  margin-bottom: 24px;
}
.dash-grid .panel { margin-bottom: 0; }

/* Stack att-grid vertically inside the narrower attendance column */
.dash-grid .att-grid { grid-template-columns: 1fr; }
.dash-grid .att-col:first-child {
  border-right: none;
  border-bottom: 1px solid var(--border);
}

/* Wrap force-form inputs when space is tight */
.dash-grid .force-form { flex-wrap: wrap; }
.dash-grid .force-form input[type="datetime-local"] {
  width: 100%; min-width: 0;
}

/* ── Employee photo ──────────────────────────────────────────────── */
.record-photo-wrap {
  display: flex; flex-direction: column; align-items: center;
  gap: 10px; padding-bottom: 16px; margin-bottom: 4px;
  border-bottom: 1px solid var(--border);
}
.record-photo {
  display: block;
  width: 80px; height: 80px;
  min-width: 80px; min-height: 80px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--border);
  box-shadow: var(--shadow-sm);
  cursor: zoom-in;
}
.record-photo-initials {
  width: 80px; height: 80px;
  min-width: 80px; min-height: 80px;
  border-radius: 50%;
  background: var(--grad); color: #fff;
  display: grid; place-items: center;
  font-size: 1.8rem; font-weight: 800;
  box-shadow: var(--shadow-sm);
  border: 3px solid rgba(255,255,255,0.3);
  flex-shrink: 0;
}
.photo-upload-btn {
  display: inline-block; cursor: pointer;
}
/* Topbar avatar when showing a real photo */
img.avatar-photo {
  display: block;
  width: 40px; height: 40px;
  min-width: 40px; min-height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255,255,255,0.5);
  box-shadow: var(--shadow-sm);
}

/* My Record table — compact label column */
.record-table th {
  white-space: nowrap;
  font-size: 0.75rem;
  width: 1%;
  color: var(--muted);
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
  background: transparent;
  padding: 9px 12px;
}
.record-table td { padding: 9px 12px; font-size: 0.88rem; }

/* ── Clean check-in / check-out cards ───────────────────────────── */
.att-simple {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px;
}
.att-card {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 18px 16px; text-align: center; background: var(--surface-2);
}
.att-card-label {
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.6px; color: var(--muted); margin-bottom: 8px;
}
.att-card-time {
  font-size: 1.45rem; font-weight: 800; color: var(--ink); margin-bottom: 14px;
}
.att-card-time.empty { color: rgba(93,107,120,0.35); }

/* ── Manual toggle ───────────────────────────────────────────────── */
.manual-toggle {
  display: flex; align-items: center; gap: 8px;
  cursor: pointer; margin-bottom: 10px;
  font-size: 0.88rem; color: var(--ink); font-weight: 500;
  user-select: none;
}
.manual-toggle input[type="checkbox"] {
  width: 16px; height: 16px; cursor: pointer; accent-color: var(--navy);
}

/* ── Manual force fields ─────────────────────────────────────────── */
.manual-fields {
  display: none; margin-bottom: 14px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 16px; background: var(--surface-2);
}
.manual-fields.visible { display: block; }
.manual-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.manual-col-label {
  font-size: 0.75rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.5px; color: var(--muted); margin-bottom: 8px;
}
.force-form-v { display: flex; flex-direction: column; gap: 8px; }
.force-form-v input[type="datetime-local"] {
  width: 100%; padding: 8px 10px; font-size: 0.83rem;
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface);
}
.manual-recorded { display: flex; align-items: center; gap: 10px; font-size: 0.9rem; }

/* ── Task log ────────────────────────────────────────────────────── */
.task-log-section { margin-bottom: 14px; }
.task-log-label {
  display: block; font-size: 0.85rem; font-weight: 600;
  color: var(--ink); margin: 0 0 8px;
}
.task-textarea {
  width: 100%; min-height: 90px;
  padding: 12px 14px; font: 0.9rem/1.65 inherit;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--ink);
  resize: vertical; display: block;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.task-textarea:focus {
  outline: none; border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(10,38,62,0.10);
}
.task-log-foot {
  display: flex; align-items: center; justify-content: space-between; margin-top: 6px;
}
.char-count      { font-size: 0.78rem; color: var(--muted); }
.char-count.warn { color: var(--gold-deep); }
.char-count.over { color: var(--danger); }
.task-log-cell {
  max-width: 260px; font-size: 0.83rem; color: var(--text);
  white-space: pre-wrap; word-break: break-word; line-height: 1.45;
}
/* 7-day history — date cell */
.day-rel {
  display: block; font-size: 0.78rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted);
}
.day-rel.day-today { color: var(--green); }
.day-rel.day-yest  { color: var(--navy-2); }
.day-full { display: block; font-size: 0.82rem; color: var(--text); margin-top: 2px; }

/* ── Lightbox modal ──────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed; inset: 0; z-index: 200;
  background: rgba(10, 38, 62, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  align-items: center; justify-content: center;
  cursor: zoom-out;
}
.modal-overlay.open { display: flex; }
.modal-img {
  max-width: min(480px, 90vw);
  max-height: 90vh;
  border-radius: 24px;
  box-shadow: 0 32px 80px rgba(10,38,62,0.5);
  object-fit: contain;
  background: #fff;
  padding: 24px;
  cursor: default;
  animation: popIn 0.2s ease;
}
.modal-img-photo {
  border-radius: 50%;
  padding: 0;
  width: min(360px, 90vw);
  height: min(360px, 90vw);
  object-fit: cover;
}
@keyframes popIn {
  from { transform: scale(0.82); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}

/* Logo / brand panel (col 3) */
.logo-panel { display: flex; align-items: center; justify-content: center; }
.logo-panel-inner {
  display: flex; flex-direction: column; align-items: center;
  gap: 12px; padding: 20px 8px; width: 100%;
}
.logo-panel-img {
  width: 92px; height: 92px;
  border-radius: 18px; object-fit: contain;
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 10px;
  box-shadow: var(--shadow);
}
.logo-panel-name {
  font-size: 1.1rem; font-weight: 800;
  color: var(--navy); text-align: center;
}
.logo-panel-name b { color: var(--green); }
.logo-panel-tagline {
  font-size: 0.8rem; color: var(--muted);
  text-align: center; line-height: 1.5; margin: 0;
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 860px) {
  .dash-grid { grid-template-columns: 1fr; }
  .dash-grid .att-grid { grid-template-columns: 1fr 1fr; }
  .dash-grid .att-col:first-child {
    border-right: 1px solid var(--border);
    border-bottom: none;
  }
}
@media (max-width: 640px) {
  .grid2 { grid-template-columns: 1fr; }
  .dash-grid .att-grid { grid-template-columns: 1fr; }
  .dash-grid .att-col:first-child {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .table-scroll { overflow-x: auto; }
  .card { padding: 26px 20px; }
}
