/* ======================================================
   Attendance Portal — Corporate Blue/White Theme
   ====================================================== */

:root {
  --brand: #1e5fbf;
  --brand-dark: #134694;
  --brand-light: #e8f0fc;
  --brand-soft: #f4f8ff;
  --accent: #00b894;
  --warn: #f0a31c;
  --danger: #e23d3d;
  --text: #1f2a44;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --bg: #f6f8fb;
  --card: #ffffff;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow:    0 4px 16px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.12);
  --radius: 10px;
  --radius-lg: 14px;
}

* { box-sizing: border-box; }

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

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-dark); text-decoration: underline; }

h1,h2,h3,h4,h5,h6 { color: var(--text); margin: 0 0 .6rem; font-weight: 600; letter-spacing: -.01em; }

/* ============= AUTH (blank) layout ============= */
.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--bg);
}
.auth-aside {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
  color: #fff;
  padding: 4rem 3.5rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}
.auth-aside::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 20% 20%, rgba(255,255,255,.08), transparent 40%),
    radial-gradient(circle at 80% 80%, rgba(255,255,255,.06), transparent 40%);
}
.auth-aside .brand { font-size: 1.4rem; font-weight: 700; position: relative; }
.auth-aside .pitch { position: relative; }
.auth-aside .pitch h2 { color: #fff; font-size: 2rem; line-height: 1.2; margin-bottom: 1rem; }
.auth-aside .pitch p { opacity: .85; font-size: 1.05rem; line-height: 1.55; }
.auth-aside .feat-list { list-style: none; padding: 0; margin: 1.5rem 0 0; position: relative; }
.auth-aside .feat-list li { padding: .35rem 0; opacity: .92; }
.auth-aside .feat-list li::before { content: '✓'; display: inline-block; width: 1.2rem; color: #b8d4ff; }

.auth-main {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  box-shadow: var(--shadow);
}
.auth-card h1 { font-size: 1.6rem; margin-bottom: .25rem; }
.auth-card .sub { color: var(--text-muted); margin-bottom: 1.5rem; }

@media (max-width: 900px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-aside { padding: 2.5rem 2rem; min-height: 220px; }
  .auth-aside .pitch h2 { font-size: 1.4rem; }
}

/* ============= APP layout ============= */
.app-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}
.sidebar {
  background: #fff;
  border-right: 1px solid var(--border);
  padding: 1.5rem 0;
  position: sticky; top: 0; height: 100vh;
  overflow-y: auto;
}
.sidebar .brand {
  padding: 0 1.5rem 1.5rem;
  font-weight: 700;
  color: var(--brand-dark);
  font-size: 1.05rem;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: .5rem;
}
.sidebar .brand .logo {
  width: 32px; height: 32px; border-radius: 8px;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: #fff;
  display: grid; place-items: center;
  font-weight: 700;
  box-shadow: 0 4px 10px rgba(30,95,191,.3);
}
.sidebar .nav { padding: .75rem; display: flex; flex-direction: column; gap: 2px; }
.sidebar .nav a {
  padding: .65rem .85rem;
  border-radius: 8px;
  display: flex; align-items: center; gap: .65rem;
  color: var(--text-muted);
  font-weight: 500;
  text-decoration: none;
  transition: background .15s, color .15s;
}
.sidebar .nav a:hover { background: var(--brand-soft); color: var(--brand-dark); }
.sidebar .nav a.active {
  background: var(--brand-light);
  color: var(--brand-dark);
}
.sidebar .nav .label { font-size: .73rem; text-transform: uppercase; letter-spacing: .08em; color: #94a3b8; padding: 1rem .85rem .25rem; }

.topbar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
  display: flex; align-items: center; justify-content: space-between;
  height: 64px;
  position: sticky; top: 0; z-index: 5;
}
.topbar h2 { margin: 0; font-size: 1.05rem; font-weight: 600; }
.topbar .user-chip {
  display: flex; align-items: center; gap: .65rem;
  padding: .35rem .35rem .35rem .85rem;
  border: 1px solid var(--border);
  border-radius: 100px;
  background: var(--card);
}
.topbar .user-chip .avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: #fff; display: grid; place-items: center; font-weight: 600; font-size: .8rem;
}
.topbar .user-chip .meta { font-size: .82rem; line-height: 1.2; }
.topbar .user-chip .meta strong { display: block; font-weight: 600; }
.topbar .user-chip .meta span { color: var(--text-muted); font-size: .72rem; }
.topbar .user-chip .logout { padding: .35rem .65rem; border-radius: 100px; color: var(--text-muted); }
.topbar .user-chip .logout:hover { background: var(--bg); color: var(--danger); }

main { padding: 1.75rem 2rem 3rem; }

/* ============= COMPONENTS ============= */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}
.card h3 { font-size: 1rem; margin-bottom: 1rem; }
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.25rem;
}
.card-header h3 { margin: 0; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  display: flex; align-items: center; gap: 1rem;
  box-shadow: var(--shadow-sm);
  transition: transform .15s, box-shadow .15s;
}
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat .icon {
  width: 48px; height: 48px; border-radius: 12px;
  display: grid; place-items: center;
  font-size: 1.3rem;
}
.stat .icon.blue   { background: var(--brand-light); color: var(--brand-dark); }
.stat .icon.green  { background: #e7f8f1; color: var(--accent); }
.stat .icon.amber  { background: #fef3e0; color: var(--warn); }
.stat .icon.red    { background: #fde8e8; color: var(--danger); }
.stat .icon.purple { background: #f0e8fc; color: #7c3aed; }
.stat .num { font-size: 1.6rem; font-weight: 700; line-height: 1.1; }
.stat .lbl { font-size: .8rem; color: var(--text-muted); margin-top: .15rem; }

.row { display: grid; gap: 1rem; }
.row.two { grid-template-columns: 1.4fr 1fr; }
@media (max-width: 1100px) { .row.two { grid-template-columns: 1fr; } }

/* ============= FORMS ============= */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: .8rem; font-weight: 600; margin-bottom: .35rem; color: var(--text); }
.form-group .hint { font-size: .75rem; color: var(--text-muted); margin-top: .25rem; }
.form-control, select, textarea, input[type="text"], input[type="email"], input[type="password"], input[type="date"], input[type="tel"], input[type="number"] {
  width: 100%;
  padding: .65rem .85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  background: #fff;
  color: var(--text);
  transition: border .15s, box-shadow .15s;
}
.form-control:focus, select:focus, textarea:focus, input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(30,95,191,.15);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 720px) { .form-row { grid-template-columns: 1fr; } }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .65rem 1.2rem;
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 600; font-size: .9rem;
  cursor: pointer;
  transition: all .15s;
  text-decoration: none;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); color: #fff; text-decoration: none; }
.btn-secondary { background: #fff; color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b9302f; color: #fff; text-decoration: none; }
.btn-sm { padding: .4rem .8rem; font-size: .8rem; }
.btn-block { width: 100%; }

/* ============= TABLES ============= */
.table-wrap { overflow-x: auto; border-radius: var(--radius-lg); border: 1px solid var(--border); background: var(--card); }
table.data {
  width: 100%; border-collapse: collapse; font-size: .87rem;
}
table.data th, table.data td {
  padding: .85rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
table.data th {
  background: var(--brand-soft);
  color: var(--text);
  font-weight: 600;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .03em;
}
table.data tbody tr:hover { background: var(--brand-soft); }
table.data tbody tr:last-child td { border-bottom: none; }

.badge {
  display: inline-block;
  padding: .2rem .55rem;
  border-radius: 100px;
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .02em;
}
.badge-blue   { background: var(--brand-light); color: var(--brand-dark); }
.badge-green  { background: #e7f8f1; color: #0d8c6c; }
.badge-amber  { background: #fef3e0; color: #9a6c12; }
.badge-red    { background: #fde8e8; color: #a4302f; }
.badge-gray   { background: #eef1f6; color: #475569; }

/* ============= ALERTS / FLASH ============= */
.alert {
  padding: .8rem 1rem;
  border-radius: 10px;
  margin-bottom: 1.25rem;
  border: 1px solid transparent;
  font-size: .9rem;
}
.alert-success { background: #e7f8f1; border-color: #b8e8d6; color: #0a6a52; }
.alert-error   { background: #fde8e8; border-color: #f3bdbd; color: #8a2727; }
.alert-info    { background: var(--brand-light); border-color: #c5dafc; color: var(--brand-dark); }

/* ============= DEVICE REGISTRATION ============= */
.device-card {
  border: 2px dashed var(--brand-light);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  background: var(--brand-soft);
}
.device-card .props { margin: 1rem 0 0; font-size: .82rem; color: var(--text-muted); }
.device-card .props div { padding: .25rem 0; }
.device-card .props strong { color: var(--text); display: inline-block; min-width: 120px; }

/* ============= MISC ============= */
.muted { color: var(--text-muted); }
.text-center { text-align: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.gap-1 { display: flex; gap: .5rem; }
.mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: 1rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
hr.soft { border: none; border-top: 1px solid var(--border); margin: 1.25rem 0; }

.dialog-trigger { cursor: pointer; }
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15,23,42,.5);
  display: none; align-items: center; justify-content: center;
  z-index: 100;
}
.modal-backdrop.show { display: flex; }
.modal {
  background: #fff; border-radius: var(--radius-lg); padding: 1.75rem;
  width: 100%; max-width: 460px; box-shadow: var(--shadow-lg);
}
.modal h3 { margin-bottom: .5rem; }
.modal .actions { display: flex; gap: .5rem; justify-content: flex-end; margin-top: 1.5rem; }

@media (max-width: 800px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; border-right: none; border-bottom: 1px solid var(--border); }
  main { padding: 1rem; }
  .topbar { padding: 0 1rem; }
}
