/* ============================================================
   CONTROL DE ACCESO — Estilos principales
   Mobile-first, dark mode, profesional
   ============================================================ */

/* ---- Variables ---- */
:root {
  --primary:    #4F46E5;
  --primary-d:  #3730A3;
  --success:    #16A34A;
  --success-d:  #15803D;
  --danger:     #DC2626;
  --danger-d:   #B91C1C;
  --warning:    #D97706;
  --info:       #0891B2;
  --gray-50:    #F9FAFB;
  --gray-100:   #F3F4F6;
  --gray-200:   #E5E7EB;
  --gray-400:   #9CA3AF;
  --gray-600:   #4B5563;
  --gray-700:   #374151;
  --gray-800:   #1F2937;
  --gray-900:   #111827;
  --bg:         #F9FAFB;
  --surface:    #FFFFFF;
  --text:       #111827;
  --text-muted: #6B7280;
  --border:     #E5E7EB;
  --radius:     12px;
  --radius-sm:  8px;
  --shadow:     0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:  0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --shadow-lg:  0 10px 15px rgba(0,0,0,.1), 0 4px 6px rgba(0,0,0,.05);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:         #0F172A;
    --surface:    #1E293B;
    --text:       #F1F5F9;
    --text-muted: #94A3B8;
    --border:     #334155;
    --gray-100:   #1E293B;
    --gray-200:   #334155;
  }
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

img { max-width: 100%; display: block; }
button { cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 1rem; }

/* ---- Utils ---- */
.hidden        { display: none !important; }
.text-center   { text-align: center; }
.text-muted    { color: var(--text-muted); }
.text-small    { font-size: .8125rem; }
.text-warning  { color: var(--warning); }
.text-success  { color: var(--success); }
.text-danger   { color: var(--danger); }

/* ============================================================
   EMPLOYEE APP
   ============================================================ */

#employee-app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.view {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1.5rem;
  animation: fadeIn .25s ease;
}

@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; } }

/* ---- App Header ---- */
.app-header {
  text-align: center;
  margin-bottom: 2rem;
}

.app-logo {
  font-size: 3rem;
  line-height: 1;
  margin-bottom: .5rem;
}

.app-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: .25rem;
}

.app-subtitle { color: var(--text-muted); font-size: .9rem; }

/* ---- Card ---- */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 2rem;
  width: 100%;
  max-width: 400px;
}

.card-icon {
  font-size: 4rem;
  text-align: center;
  margin-bottom: 1rem;
  line-height: 1;
}

.card-title {
  font-size: 1.375rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: .5rem;
}

.card-subtitle {
  font-size: .9rem;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 1.5rem;
}

/* ---- Empleado Info ---- */
.empleado-info {
  background: var(--gray-100);
  border-radius: var(--radius-sm);
  padding: 1rem;
  margin-bottom: 1.5rem;
}

.empleado-nombre {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: .25rem;
}

.empleado-meta {
  display: flex;
  gap: .75rem;
  flex-wrap: wrap;
  font-size: .85rem;
  color: var(--text-muted);
}

/* ---- Estado Badge ---- */
.estado-badge {
  display: inline-block;
  padding: .2rem .75rem;
  border-radius: 999px;
  font-size: .8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.badge-dentro  { background: #DCFCE7; color: #15803D; }
.badge-fuera   { background: #FEF9C3; color: #854D0E; }
.badge-success { background: #DCFCE7; color: #15803D; }
.badge-danger  { background: #FEE2E2; color: #B91C1C; }
.badge-warning { background: #FEF9C3; color: #854D0E; }
.badge-info    { background: #E0F2FE; color: #075985; }
.badge-secondary { background: var(--gray-200); color: var(--gray-600); }

/* ---- Botones ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .6rem 1.25rem;
  border: none;
  border-radius: var(--radius-sm);
  font-size: .925rem;
  font-weight: 600;
  transition: opacity .15s, transform .1s;
  text-decoration: none;
  white-space: nowrap;
}

.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn-primary  { background: var(--primary);  color: #fff; }
.btn-success  { background: var(--success);  color: #fff; }
.btn-danger   { background: var(--danger);   color: #fff; }
.btn-warning  { background: var(--warning);  color: #fff; }
.btn-outline  { background: transparent; border: 2px solid var(--primary); color: var(--primary); }
.btn-ghost    { background: transparent; color: var(--text-muted); }
.btn-secondary { background: var(--gray-200); color: var(--gray-700); }

.btn-sm   { padding: .35rem .75rem; font-size: .8125rem; }
.btn-lg   { padding: .875rem 1.75rem; font-size: 1.05rem; }
.btn-full { width: 100%; }

/* ---- Loading Spinner ---- */
.spinner {
  width: 48px; height: 48px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  margin: 0 auto 1rem;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-text { color: var(--text-muted); text-align: center; font-size: .95rem; }

/* ---- Success ---- */
.success-card { text-align: center; }

.success-hora {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -.02em;
  line-height: 1;
  margin: 1rem 0 .25rem;
}

.success-duracion {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  background: #EDE9FE;
  color: var(--primary);
  padding: .4rem 1rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: .95rem;
  margin-top: .75rem;
}

/* ---- Goodbye ---- */
.goodbye-view { background: linear-gradient(135deg, var(--primary) 0%, #7C3AED 100%); color: #fff; }
.goodbye-view .card { background: rgba(255,255,255,.15); backdrop-filter: blur(10px); color: #fff; }

/* ---- Error ---- */
.error-icon { font-size: 3rem; text-align: center; margin-bottom: .75rem; }
.error-title { color: var(--danger); }
.error-msg { color: var(--text-muted); font-size: .9rem; white-space: pre-wrap; word-break: break-word; }

/* ---- Countdown ---- */
.countdown-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  color: var(--text-muted);
  font-size: .875rem;
  margin-top: 1.25rem;
}

.countdown-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  font-weight: 700;
  font-size: .875rem;
}

/* ---- Sign-in ---- */
#google-btn-container, #admin-google-btn {
  display: flex;
  justify-content: center;
  margin-top: 1.25rem;
}

/* ============================================================
   ADMIN APP
   ============================================================ */

#admin-app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ---- Admin Loading ---- */
#admin-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  gap: 1rem;
}

/* ---- Admin Login ---- */
#admin-login {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1.5rem;
}

/* ---- Admin Layout ---- */
.admin-layout {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.admin-sidebar {
  width: 240px;
  background: var(--gray-900);
  color: #fff;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 50;
  transition: transform .3s;
}

.sidebar-logo {
  padding: 1.5rem;
  border-bottom: 1px solid rgba(255,255,255,.1);
}

.sidebar-logo-icon { font-size: 1.75rem; }
.sidebar-logo-title { font-weight: 700; font-size: 1rem; margin-top: .25rem; }
.sidebar-logo-sub   { font-size: .75rem; opacity: .6; }

.sidebar-nav {
  flex: 1;
  padding: 1rem 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .75rem 1.5rem;
  color: rgba(255,255,255,.7);
  cursor: pointer;
  transition: background .15s, color .15s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-size: .925rem;
  border-left: 3px solid transparent;
}

.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.tab-active { background: rgba(79,70,229,.3); color: #fff; border-left-color: var(--primary); }
.nav-item-icon { font-size: 1.1rem; width: 20px; }

.sidebar-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid rgba(255,255,255,.1);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: .75rem;
}

.sidebar-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .9rem;
  flex-shrink: 0;
  overflow: hidden;
}

.sidebar-user-name  { font-size: .875rem; font-weight: 600; }
.sidebar-user-email { font-size: .75rem; opacity: .6; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 140px; }

/* Main content */
.admin-main {
  margin-left: 240px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow: hidden;
}

.admin-topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 40;
}

.admin-topbar-title { font-size: 1.25rem; font-weight: 700; }

.admin-content { padding: 1.5rem; flex: 1; max-width: 1200px; }

/* ---- Stats Grid ---- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  text-align: center;
}

.stat-value { font-size: 2.25rem; font-weight: 800; line-height: 1; color: var(--primary); }
.stat-label { font-size: .8rem; color: var(--text-muted); margin-top: .25rem; }

/* ---- Data Tables ---- */
.table-container {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.table-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.table-title { font-weight: 700; font-size: 1rem; }

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  padding: .75rem 1rem;
  text-align: left;
  font-size: .8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  background: var(--gray-100);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: .875rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: .9rem;
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--gray-100); }

.emp-name { font-weight: 600; }
.actions-cell { white-space: nowrap; }
.actions-cell .btn + .btn { margin-left: .4rem; }

/* ---- Filters ---- */
.filters-bar {
  display: flex;
  gap: .75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.form-input, .form-select {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .5rem .875rem;
  color: var(--text);
  font-size: .9rem;
  transition: border-color .15s;
  min-width: 0;
}

.form-input:focus, .form-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,.15);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: .35rem;
  margin-bottom: 1rem;
}

.form-label { font-size: .875rem; font-weight: 600; }

.form-msg {
  padding: .75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  margin-top: .75rem;
}

.form-msg.success { background: #DCFCE7; color: #15803D; }
.form-msg.error   { background: #FEE2E2; color: #B91C1C; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

/* ---- Informe ---- */
.informe-controls {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  align-items: flex-end;
}

#inf-resultado {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

/* ---- Config ---- */
.config-form {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  max-width: 600px;
}

/* ---- Agregar empleado ---- */
.add-emp-form {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  max-width: 600px;
  margin-top: 1.5rem;
}

.form-check {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .9rem;
}

/* ---- Hamburger (mobile) ---- */
.btn-menu {
  display: none;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text);
  padding: .25rem;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 768px) {
  .admin-sidebar {
    transform: translateX(-100%);
  }

  .admin-sidebar.open {
    transform: translateX(0);
  }

  .admin-main {
    margin-left: 0;
  }

  .btn-menu { display: block; }

  .sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 49;
    display: none;
  }

  .sidebar-overlay.open { display: block; }

  .stats-grid { grid-template-columns: repeat(2, 1fr); }

  th:nth-child(n+5), td:nth-child(n+5) { display: none; }

  .form-row { grid-template-columns: 1fr; }

  .informe-controls { flex-direction: column; }

  .admin-content { padding: 1rem; }

  .table-header { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 380px) {
  .card { padding: 1.5rem; }
  .success-hora { font-size: 2rem; }
}

/* ---- Print ---- */
@media print {
  .admin-sidebar, .admin-topbar, .btn, .filters-bar { display: none !important; }
  .admin-main { margin-left: 0; }
}
