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

/* ── PCU Group Design System ── */
:root {
  --primary:      #3EB2ED;
  --primary-dark: #2196d3;
  --primary-bg:   #ebf7ff;
  --secondary:    #1b1e42;
  --accent:       #2ecc71;
  --danger:       #e74c3c;
  --warning:      #f39c12;
  --warning-bg:   #fffbeb;
  --bg:           #f4f6f9;
  --surface:      #ffffff;
  --border:       #e2e8f0;
  --border-2:     #cbd5e1;
  --text:         #2c3e50;
  --muted:        #7f8c8d;
  --r-xs:   4px;
  --r-sm:   6px;
  --r-md:   10px;
  --r-lg:   16px;
  --r-xl:   20px;
  --r-pill: 999px;
  --sh-sm: 0 1px 3px rgba(0,0,0,.06);
  --sh-md: 0 4px 14px rgba(0,0,0,.07);
  --sh-lg: 0 12px 32px rgba(0,0,0,.1);
  --t: all .18s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Ubuntu', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
button, input, select, textarea { font-family: inherit; font-size: inherit; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
.hidden { display: none !important; }
.page-center { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: var(--bg); }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 3px; }

/* ══ Card ══ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 36px;
  box-shadow: var(--sh-sm);
  width: 100%;
  max-width: 520px;
}
.card-wide { max-width: 680px; }

.brand-header { text-align: center; margin-bottom: 28px; }
.brand-header .brand-logo { height: 38px; width: auto; margin: 0 auto 14px; }
.brand-header h1 { font-size: 1.15rem; font-weight: 700; color: var(--secondary); letter-spacing: -.01em; }
.brand-header p { font-size: .82rem; color: var(--muted); margin-top: 3px; }

/* ══ Spinner ══ */
.spinner-wrap { display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--muted); font-size: .875rem; padding: 24px 0; }
.spinner { width: 20px; height: 20px; border: 2px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .65s linear infinite; flex-shrink: 0; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ══ Alerts ══ */
.alert { display: flex; align-items: flex-start; gap: 10px; padding: 11px 14px; border-radius: var(--r-md); font-size: .855rem; line-height: 1.45; margin-bottom: 14px; }
.alert i, .alert-icon { font-size: 1rem; flex-shrink: 0; margin-top: 2px; }
.alert-error   { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }
.alert-warning { background: var(--warning-bg); border: 1px solid #fed7aa; color: #92400e; }
.alert-info    { background: var(--primary-bg); border: 1px solid #bae6fd; color: #075985; }

/* ══ Forms ══ */
.form-section { margin-bottom: 22px; }
.form-section-title { font-size: .67rem; font-weight: 700; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); margin-bottom: 12px; padding-bottom: 7px; border-bottom: 1px solid var(--border); }
.form-group { margin-bottom: 12px; }
label { display: block; font-size: .8rem; font-weight: 500; color: var(--text); margin-bottom: 5px; }
.optional { color: var(--muted); font-weight: 400; font-size: .75rem; }
input[type=text], input[type=tel], input[type=email], select { width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--r-sm); background: #f8fafc; color: var(--text); outline: none; transition: var(--t); font-size: .875rem; }
input:focus, select:focus { border-color: var(--primary); background: #fff; box-shadow: 0 0 0 3px rgba(62,178,237,.11); }
input.error { border-color: var(--danger); }
.field-error { font-size: .74rem; color: var(--danger); margin-top: 3px; }

.radio-group { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.radio-option { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border: 1.5px solid var(--border); border-radius: var(--r-md); cursor: pointer; font-size: .875rem; font-weight: 500; color: var(--muted); background: #f8fafc; transition: var(--t); user-select: none; }
.radio-option input { display: none; }
.radio-option i { font-size: 1.1rem; }
.radio-option:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-bg); }
.selected-carga    { border-color: var(--primary); background: var(--primary-bg); color: var(--primary); }
.selected-descarga { border-color: var(--secondary); background: #eef0f8; color: var(--secondary); }

/* ══ Buttons ══ */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 18px; border: none; border-radius: var(--r-sm); font-weight: 500; font-size: .875rem; cursor: pointer; transition: var(--t); white-space: nowrap; line-height: 1; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn i { font-size: .95rem; }
.btn-primary   { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled)   { background: var(--primary-dark); }
.btn-secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: #f1f5f9; border-color: var(--border-2); }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled)    { background: #c0392b; }
.btn-success   { background: var(--accent); color: #fff; }
.btn-success:hover:not(:disabled)   { background: #27ae60; }
.btn-warning   { background: var(--warning); color: #fff; }
.btn-warning:hover:not(:disabled)   { background: #e67e22; }
.btn-dark      { background: var(--secondary); color: #fff; }
.btn-dark:hover:not(:disabled)      { background: #14163a; }
.btn-sm   { padding: 5px 11px; font-size: .78rem; border-radius: var(--r-xs); }
.btn-full { width: 100%; }

/* ══ Badges / Estado pills ══ */
.badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: var(--r-pill); font-size: .67rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; white-space: nowrap; }
.badge-registrado { background: #dbeafe; color: #1e3a8a; }
.badge-validado   { background: #e0e7ff; color: #3730a3; }
.badge-llamado    { background: #fef3c7; color: #78350f; }
.badge-ingresado  { background: #d1fae5; color: #065f46; }
.badge-rechazado  { background: #fee2e2; color: #7f1d1d; }
.badge-cancelado  { background: #f3f4f6; color: #4b5563; }

/* ══ Login ══ */
.login-page { background: linear-gradient(140deg, var(--secondary) 0%, #243148 55%, #1a4a6e 100%); position: relative; overflow: hidden; }
.login-page::before { content: ''; position: absolute; width: 480px; height: 480px; background: rgba(62,178,237,.07); border-radius: 50%; top: -100px; right: -80px; filter: blur(70px); pointer-events: none; }
.login-card { background: rgba(255,255,255,.97); border-radius: var(--r-xl); padding: 40px 36px; width: 100%; max-width: 400px; box-shadow: 0 20px 48px rgba(0,0,0,.28); text-align: center; position: relative; z-index: 2; }
.login-card .brand-logo { height: 44px; }
.btn-google { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; padding: 11px 20px; border: 1px solid var(--border); border-radius: var(--r-md); background: #fff; color: var(--text); font-size: .9rem; font-weight: 500; cursor: pointer; transition: var(--t); box-shadow: var(--sh-sm); }
.btn-google:hover { background: #f8fafc; box-shadow: var(--sh-md); }

/* ══ QR Page ══ */
.qr-page { min-height: 100vh; background: var(--secondary); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px 24px; gap: 24px; position: relative; }
.qr-page-logo { height: 30px; width: auto; opacity: .82; }
.qr-card { background: #fff; border-radius: var(--r-xl); padding: 36px 40px; display: flex; flex-direction: column; align-items: center; gap: 18px; box-shadow: 0 24px 56px rgba(0,0,0,.4); }
.qr-instruction { font-size: .71rem; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); text-align: center; }
.qr-timer { display: flex; align-items: center; gap: 6px; font-size: .82rem; color: var(--muted); }
.qr-timer i { color: var(--primary); font-size: .9rem; }
#countdown { font-weight: 700; color: var(--secondary); min-width: 30px; }
.qr-hint { font-size: .71rem; color: rgba(255,255,255,.32); text-align: center; max-width: 300px; }
.qr-signout { position: absolute; top: 16px; right: 18px; background: transparent; border: 1px solid rgba(255,255,255,.14); color: rgba(255,255,255,.38); padding: 5px 12px; border-radius: var(--r-sm); font-size: .72rem; cursor: pointer; transition: var(--t); font-family: inherit; display: flex; align-items: center; gap: 5px; }
.qr-signout:hover { background: rgba(255,255,255,.07); color: rgba(255,255,255,.7); }
.qr-error { color: #fca5a5; text-align: center; font-size: .9rem; }

/* ══ Code input ══ */
.code-input { width: 100%; text-align: center; font-size: 2.2rem; font-weight: 700; letter-spacing: .28em; padding: 14px; border: 2px solid var(--border); border-radius: var(--r-md); background: #f8fafc; color: var(--secondary); outline: none; transition: var(--t); margin-bottom: 4px; }
.code-input:focus { border-color: var(--primary); background: #fff; box-shadow: 0 0 0 3px rgba(62,178,237,.12); }
.code-hint { font-size: .73rem; color: var(--muted); text-align: center; }

/* ══ Confirmation ══ */
.turno-badge { display: inline-block; background: var(--secondary); color: #fff; font-size: 2.2rem; font-weight: 700; letter-spacing: .06em; padding: 10px 28px; border-radius: var(--r-lg); margin: 8px 0 20px; }

/* ══ Admin layout ══ */
.admin-layout { min-height: 100vh; display: flex; flex-direction: column; background: var(--bg); }

.admin-topbar { background: var(--secondary); height: 54px; padding: 0 24px; display: flex; align-items: center; justify-content: space-between; box-shadow: 0 2px 10px rgba(0,0,0,.22); position: sticky; top: 0; z-index: 100; flex-shrink: 0; }
.admin-topbar-brand { display: flex; align-items: center; gap: 12px; }
.admin-topbar-brand img { height: 22px; width: auto; }
.topbar-divider { width: 1px; height: 16px; background: rgba(255,255,255,.2); }
.topbar-subtitle { font-size: .71rem; font-weight: 500; color: rgba(255,255,255,.5); letter-spacing: .02em; }
.admin-topbar-right { display: flex; align-items: center; gap: 7px; }
.topbar-user { font-size: .73rem; color: rgba(255,255,255,.45); margin-right: 4px; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-btn { display: inline-flex; align-items: center; gap: 5px; padding: 5px 11px; border-radius: var(--r-xs); font-size: .74rem; font-weight: 500; cursor: pointer; transition: var(--t); border: 1px solid transparent; font-family: inherit; line-height: 1; }
.topbar-btn i { font-size: .88rem; }
.topbar-btn-accent { background: rgba(62,178,237,.16); color: #7dd3fc; border-color: rgba(62,178,237,.22); }
.topbar-btn-accent:hover { background: rgba(62,178,237,.26); }
.topbar-btn-ghost { background: transparent; color: rgba(255,255,255,.4); border-color: rgba(255,255,255,.12); }
.topbar-btn-ghost:hover { background: rgba(255,255,255,.07); color: rgba(255,255,255,.75); }

.admin-stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; padding: 20px 24px 0; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); padding: 14px 16px; box-shadow: var(--sh-sm); }
.stat-value { font-size: 1.75rem; font-weight: 700; color: var(--secondary); line-height: 1; }
.stat-value.primary { color: var(--primary); }
.stat-value.warning { color: var(--warning); }
.stat-value.success { color: var(--accent); }
.stat-value.danger  { color: var(--danger); }
.stat-label { font-size: .67rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin-top: 5px; }

.admin-main { flex: 1; padding: 18px 24px 40px; display: flex; flex-direction: column; gap: 14px; }

.admin-toolbar { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); padding: 11px 16px; display: flex; align-items: center; gap: 10px; box-shadow: var(--sh-sm); flex-wrap: wrap; }
.filter-label { font-size: .67rem; font-weight: 700; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); }
.filter-select { padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--r-xs); background: #f8fafc; color: var(--text); font-size: .82rem; outline: none; cursor: pointer; font-family: inherit; transition: var(--t); }
.filter-select:focus { border-color: var(--primary); }
.toolbar-spacer { flex: 1; }
.last-update { font-size: .69rem; color: var(--muted); }

#alert-panel { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; padding: 10px 14px; border-radius: var(--r-sm); font-size: .855rem; display: flex; align-items: center; gap: 8px; }

.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--sh-sm); overflow: hidden; flex: 1; }
table { width: 100%; border-collapse: collapse; font-size: .84rem; }
thead th { background: #f8fafc; padding: 10px 14px; text-align: left; font-size: .67rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); border-bottom: 1px solid var(--border); white-space: nowrap; }
tbody td { padding: 11px 14px; border-bottom: 1px solid var(--border); color: var(--text); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #fafbfc; }
.actions-cell { white-space: nowrap; }
.actions-cell .btn + .btn { margin-left: 4px; }
.turno-num { font-weight: 700; color: var(--secondary); }

#table-vacia { padding: 52px 24px; text-align: center; color: var(--muted); font-size: .875rem; }
#table-vacia i { font-size: 1.8rem; display: block; margin-bottom: 8px; color: var(--border-2); }
#table-loading { padding: 40px; }

.modal-overlay { position: fixed; inset: 0; background: rgba(15,20,40,.58); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; padding: 24px; z-index: 200; }
.modal { background: var(--surface); border-radius: var(--r-xl); padding: 28px; width: 100%; max-width: 440px; box-shadow: var(--sh-lg); animation: fadeUp .16s ease forwards; }
.modal h2 { font-size: .95rem; font-weight: 700; color: var(--secondary); margin-bottom: 6px; }
.modal > p { font-size: .845rem; color: var(--muted); margin-bottom: 14px; }
.modal textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--r-sm); font-family: inherit; font-size: .875rem; resize: vertical; outline: none; background: #f8fafc; color: var(--text); transition: var(--t); }
.modal textarea:focus { border-color: var(--primary); background: #fff; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
#modal-error { font-size: .77rem; color: var(--danger); margin-top: 4px; }
@keyframes fadeUp { from { opacity:0; transform:translateY(6px); } to { opacity:1; transform:translateY(0); } }

@media (max-width: 960px) { .admin-stats { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 640px) {
  .admin-topbar { padding: 0 14px; height: 50px; }
  .topbar-subtitle, .topbar-user { display: none; }
  .admin-stats { grid-template-columns: repeat(2, 1fr); padding: 14px 14px 0; }
  .admin-main { padding: 14px 14px 32px; }
  .card { padding: 24px 20px; }
  thead { display: none; }
  tbody tr { display: block; border-bottom: 2px solid var(--border); }
  tbody td { display: flex; justify-content: space-between; align-items: center; padding: 7px 14px; border: none; font-size: .82rem; }
  tbody td::before { content: attr(data-label); font-weight: 700; font-size: .66rem; text-transform: uppercase; color: var(--muted); letter-spacing: .05em; flex-shrink: 0; margin-right: 8px; }
  .actions-cell { flex-direction: column; align-items: flex-end; gap: 5px; padding-top: 8px; padding-bottom: 8px; }
  .actions-cell::before { align-self: flex-start; }
  .actions-cell .btn + .btn { margin-left: 0; }
}
