/* ============================================================
   Control de Asistencias — Main Stylesheet
   ============================================================ */

/* ── Reset & base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --sidebar-w: 240px;
  --topbar-h: 56px;
  --bg:       #f1f5f9;
  --card-bg:  #ffffff;
  --border:   #e2e8f0;
  --text:     #1e293b;
  --text-2:   #64748b;
  --primary:  #2563eb;
  --primary-h:#1d4ed8;
  --success:  #16a34a;
  --danger:   #dc2626;
  --warning:  #d97706;
  --sidebar-bg: #0f172a;
  --sidebar-text: #94a3b8;
  --sidebar-active: #3b82f6;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow-md: 0 4px 16px rgba(0,0,0,.12);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
}

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

/* ── Login ────────────────────────────────────────────────── */
.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 100%);
  padding: 20px;
}

.login-card {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 40px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-md);
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
}

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: 200;
  transition: transform .25s ease;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}

.sidebar-title {
  color: #f1f5f9;
  font-weight: 700;
  font-size: 13px;
  line-height: 1.3;
}

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 6px;
  color: var(--sidebar-text);
  font-size: 13.5px;
  font-weight: 500;
  transition: background .15s, color .15s;
  margin-bottom: 2px;
}

.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }

.nav-item:hover {
  background: rgba(255,255,255,.07);
  color: #f1f5f9;
  text-decoration: none;
}

.nav-item.active {
  background: var(--sidebar-active);
  color: #ffffff;
}

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

.user-info { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--sidebar-active);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; flex-shrink: 0;
}
.user-name { color: #f1f5f9; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { color: var(--sidebar-text); font-size: 11px; }

.logout-btn {
  color: var(--sidebar-text);
  padding: 6px;
  border-radius: 4px;
  transition: color .15s;
  cursor: pointer;
}
.logout-btn:hover { color: #f87171; }

/* Mobile sidebar */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 199;
}
.sidebar-overlay.visible { display: block; }

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

.topbar {
  height: var(--topbar-h);
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-2);
  padding: 4px;
}

.page-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  flex: 1;
}

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

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13.5px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: background .15s, color .15s, opacity .15s;
  white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary  { background: var(--primary); color: #fff; }
.btn-primary:hover  { background: var(--primary-h); }
.btn-success  { background: var(--success); color: #fff; }
.btn-ghost    { background: transparent; color: var(--text-2); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-danger   { background: var(--danger); color: #fff; }
.btn-sm  { padding: 5px 12px; font-size: 12.5px; }
.btn-xs  { padding: 3px 8px; font-size: 11.5px; }
.btn-icon{ padding: 6px; }
.btn-full{ width: 100%; justify-content: center; }

/* ── Forms ────────────────────────────────────────────────── */
.form-group {
  margin-bottom: 16px;
}
.form-group label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.form-group label small {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text-2);
  font-size: 11px;
}
.form-group input[type=text],
.form-group input[type=date],
.form-group input[type=password],
.form-group input[type=time],
.form-group input[type=number],
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13.5px;
  color: var(--text);
  background: #fff;
  transition: border .15s;
}
.form-group input:focus, .form-group select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ── Alerts ───────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: 6px;
  font-size: 13.5px;
  margin-bottom: 20px;
  font-weight: 500;
}
.alert-error   { background: #fee2e2; color: #991b1b; }
.alert-success { background: #d1fae5; color: #065f46; }

/* ── Cards ────────────────────────────────────────────────── */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 20px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.card-title { font-size: 15px; font-weight: 700; color: var(--text); }
.card-subtitle { font-size: 12.5px; color: var(--text-2); margin-bottom: 16px; margin-top: -8px; }

/* ── Modal ────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal {
  background: var(--card-bg);
  border-radius: 10px;
  width: 100%;
  max-width: 460px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-md);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px 0;
  margin-bottom: 16px;
}
.modal-header h3 { font-size: 16px; font-weight: 700; }
.modal-close {
  background: none; border: none; cursor: pointer;
  font-size: 22px; color: var(--text-2); line-height: 1;
}
.modal-close:hover { color: var(--text); }
.modal form { padding: 0 20px 20px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* ── Calendar ─────────────────────────────────────────────── */
.cal-controls {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.cal-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cal-month-label {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  min-width: 180px;
  text-align: center;
}

.cal-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.legend-item {
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 99px;
  border: 1px solid rgba(0,0,0,.1);
}

.cal-grid-wrapper {
  overflow-x: auto;
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.cal-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 700px;
}

.cal-table thead th {
  padding: 10px 8px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-2);
  border-bottom: 1px solid var(--border);
  text-align: center;
  background: #f8fafc;
}
.cal-table thead th.cal-weekend { color: #94a3b8; }

.cal-day {
  vertical-align: top;
  padding: 8px;
  border: 1px solid var(--border);
  min-width: 130px;
  min-height: 100px;
}
.cal-empty { border: 1px solid var(--border); background: #f8fafc; }
.cal-weekend-bg { background: #f8fafc !important; }
.cal-today { background: #eff6ff !important; }

.cal-day-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.cal-day-num {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-2);
}
.today-num {
  background: var(--primary);
  color: #fff;
  width: 24px; height: 24px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px;
}

.add-exc-btn {
  background: none; border: 1px dashed #cbd5e1;
  border-radius: 4px; width: 20px; height: 20px;
  font-size: 14px; cursor: pointer; color: #94a3b8;
  display: flex; align-items: center; justify-content: center;
  transition: border-color .15s, color .15s;
}
.add-exc-btn:hover { border-color: var(--primary); color: var(--primary); }

.cal-names {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.cal-exceptions {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px dashed var(--border);
}

.emp-tag {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 99px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.emp-normal { background: #f1f5f9; color: var(--text); }
.emp-absent { background: transparent; padding-left: 2px; }

.del-exc-btn {
  background: none; border: none; cursor: pointer;
  color: inherit; font-size: 13px; line-height: 1;
  margin-left: 2px; opacity: .6;
}
.del-exc-btn:hover { opacity: 1; }

/* ── Attendance ───────────────────────────────────────────── */
.att-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.att-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.att-date-wrap { text-align: center; }
.att-day-name { display: block; font-size: 11px; color: var(--text-2); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.date-picker-input {
  border: none;
  background: none;
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
  padding: 2px;
  text-align: center;
}
.date-picker-input:focus { outline: none; }

.att-actions { display: flex; gap: 8px; }

.att-table {
  width: 100%;
  border-collapse: collapse;
}
.att-table th {
  padding: 10px 12px;
  text-align: left;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-2);
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.att-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.att-table tr:last-child td { border-bottom: none; }
.att-table tr:hover td { background: #f8fafc; }

.emp-cell { display: flex; align-items: center; gap: 8px; }
.emp-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: #dbeafe;
  color: #1e40af;
  font-size: 11px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.emp-avatar.sm { width: 22px; height: 22px; font-size: 10px; }

.time-input {
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 5px 8px;
  font-size: 13px;
  width: 100px;
  color: var(--text);
}
.time-input:focus { outline: none; border-color: var(--primary); }

.location-select {
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 5px 8px;
  font-size: 12.5px;
  background: #fff;
}

.notes-input {
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 5px 8px;
  font-size: 12.5px;
  width: 160px;
}

.hours-cell { font-weight: 700; color: var(--primary); font-size: 13px; }

/* ── Weekly table ─────────────────────────────────────────── */
.week-table {
  width: 100%;
  border-collapse: collapse;
}
.week-table th, .week-table td {
  padding: 8px 10px;
  border: 1px solid var(--border);
  font-size: 12.5px;
  text-align: center;
}
.week-table th { background: #f8fafc; font-weight: 700; font-size: 11.5px; }
.week-table td:first-child { text-align: left; }
.week-table th.wknd, .week-table td.wknd { background: #f8fafc; color: #94a3b8; }

.week-times { display: flex; flex-direction: column; gap: 1px; }
.t-entry { color: var(--success); font-weight: 700; font-size: 12px; }
.t-exit  { color: var(--danger);  font-size: 11.5px; }
.no-record { color: #cbd5e1; }
.total-hours { font-weight: 700; color: var(--primary); }

/* ── Employees page ───────────────────────────────────────── */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
}

.simple-table { width: 100%; border-collapse: collapse; }
.simple-table th {
  padding: 9px 12px;
  text-align: left;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-2);
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
}
.simple-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.simple-table tr:last-child td { border-bottom: none; }
.action-cell { display: flex; gap: 6px; }
.row-inactive td { opacity: .5; }
.empty-cell { color: var(--text-2); font-size: 13px; text-align: center; padding: 24px !important; }

.status-badge { padding: 2px 8px; border-radius: 99px; font-size: 11.5px; font-weight: 700; }
.status-badge.active   { background: #d1fae5; color: #065f46; }
.status-badge.inactive { background: #f3f4f6; color: #6b7280; }

.day-badge { display: inline-flex; width: 22px; height: 22px; align-items: center; justify-content: center;
  border-radius: 4px; background: #dbeafe; color: #1e40af; font-size: 11px; font-weight: 700; margin: 1px; }
.day-badge.wknd { background: #f3f4f6; color: #9ca3af; }

/* Days picker in modal */
.days-picker { display: flex; gap: 6px; flex-wrap: wrap; }
.day-toggle {
  cursor: pointer;
}
.day-toggle input { display: none; }
.day-toggle span {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px; height: 40px;
  border-radius: 8px;
  border: 2px solid var(--border);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-2);
  transition: all .15s;
  user-select: none;
}
.day-toggle input:checked + span {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.day-toggle.day-wknd span { color: #94a3b8; }
.day-toggle.day-wknd input:checked + span { background: #64748b; border-color: #64748b; }

.role-badge { padding: 2px 8px; border-radius: 99px; font-size: 11.5px; font-weight: 700; margin-bottom: 12px; display: inline-block; }
.role-badge.admin     { background: #dbeafe; color: #1e40af; }
.role-badge.assistant { background: #ede9fe; color: #5b21b6; }

.user-form { border: 1px solid var(--border); border-radius: 8px; padding: 16px; margin-bottom: 16px; }
.user-form-header { margin-bottom: 12px; }

/* ── Table responsive ─────────────────────────────────────── */
.table-responsive { overflow-x: auto; }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-wrapper { margin-left: 0; }
  .hamburger { display: flex; }
  .main-content { padding: 16px; }
  .two-col { grid-template-columns: 1fr; }
  .cal-month-label { font-size: 15px; min-width: 140px; }
  .form-row { grid-template-columns: 1fr; }
  .att-controls { flex-direction: column; align-items: flex-start; }
}

/* ── HR Employees additions ───────────────────────────────── */
.alert-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.alert-card {
  border-radius: var(--radius);
  padding: 16px;
  border: 1px solid;
}

.birthday-card {
  background: #fef9c3;
  border-color: #fde047;
}

.contract-card {
  background: #fff7ed;
  border-color: #fdba74;
}

.alert-card-title {
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 10px;
  color: var(--text);
}

.alert-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0;
  border-bottom: 1px solid rgba(0,0,0,.06);
  font-size: 13px;
}
.alert-item:last-child { border-bottom: none; }
.alert-item span { color: var(--text-2); font-size: 12px; }
.alert-item.urgent strong { color: var(--danger); }

.emp-layout { display: flex; flex-direction: column; gap: 0; }
.emp-section { overflow: hidden; }

.emp-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.emp-table th {
  padding: 9px 12px;
  text-align: left;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-2);
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.emp-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.emp-table tr:last-child td { border-bottom: none; }
.emp-table tr:hover td { background: #f8fafc; }

.emp-name-cell { display: flex; align-items: center; gap: 10px; }
.emp-email { font-size: 11px; color: var(--text-2); margin-top: 1px; }

.mono { font-family: monospace; font-size: 12.5px; color: var(--text-2); }

.contract-badge {
  background: #f1f5f9;
  color: var(--text-2);
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}

/* Expiry states */
.expired     { color: var(--danger); font-weight: 700; }
.expiring-soon{ color: var(--warning); font-weight: 700; }
.expiring    { color: #d97706; }

.action-cell { display: flex; gap: 6px; white-space: nowrap; }

/* Modal wide */
.modal-wide { max-width: 680px; }

.form-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-2);
  margin: 20px 0 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

/* Users grid */
.users-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
}
