/* ============================================================
   ABORGASE - app.css
   Fiel réplica del diseño original de Base44
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary:     #07506f;
  --primary-dark:#053d54;
  --primary-bg:  #dde9ed;
  --bg:          #f4f5f7;
  --card-bg:     #ffffff;
  --border:      #e2e6ea;
  --text:        #1a1d23;
  --text-muted:  #6b7280;
  --danger:      #dc2626;
  --danger-bg:   #fef2f2;
  --success:     #16a34a;
  --success-bg:  #f0fdf4;
  --warning:     #d97706;
  --shadow-sm:   0 1px 3px rgba(0,0,0,.08);
  --shadow-md:   0 4px 12px rgba(0,0,0,.10);
  --radius:      12px;
  --radius-sm:   8px;
  --font:        -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
}

/* ============================================================
   LOGIN
   ============================================================ */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: #f4f5f7;
}

.login-wrap {
  width: 100%;
  max-width: 420px;
  padding: 24px 16px;
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.logo-icon {
  width: 96px;
  height: 96px;
  margin: 0 auto 16px;
}

.logo-icon svg { width: 100%; height: 100%; border-radius: 22px; display: block; }

.login-logo h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.login-logo p {
  color: var(--text-muted);
  font-size: 13px;
}

.login-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 32px 28px;
}

.login-card h2 {
  font-size: 18px;
  font-weight: 600;
  text-align: center;
  margin-bottom: 24px;
}

/* ============================================================
   HEADER
   ============================================================ */
.app-header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(27,110,130,.25);
}

.header-left { display: flex; align-items: center; gap: 12px; }

.header-logo svg { width: 36px; height: 36px; flex-shrink: 0; }

.header-app-name { font-size: 15px; font-weight: 700; display: block; line-height: 1.2; }

.header-subtitle { font-size: 12px; opacity: .8; display: block; line-height: 1.2; }

.header-right { display: flex; align-items: center; gap: 8px; }

.header-nav {
  color: rgba(255,255,255,.8);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  padding: 5px 10px;
  border-radius: 6px;
  transition: background .15s;
}
.header-nav:hover, .header-nav.active { background: rgba(255,255,255,.18); color: white; }

.header-logout {
  color: rgba(255,255,255,.85);
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  transition: background .15s;
  text-decoration: none;
}
.header-logout:hover { background: rgba(255,255,255,.18); }
.header-logout svg { width: 20px; height: 20px; }

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main-content {
  max-width: 620px;
  margin: 0 auto;
  padding: 24px 16px 80px;
}

.main-content.wide {
  max-width: 1100px;
}

/* ============================================================
   TABS
   ============================================================ */
.tabs-bar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  margin-bottom: 20px;
}

.tab-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 12px 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background .15s, color .15s;
}
.tab-btn svg { width: 16px; height: 16px; }
.tab-btn.active {
  background: var(--primary);
  color: white;
  border-radius: var(--radius-sm);
  margin: 4px;
}
.tab-btn:not(.active):hover { background: var(--primary-bg); color: var(--primary); }

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 20px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 14px;
}

.section-subtitle {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--primary-bg);
}

.section-subtitle.mt { margin-top: 20px; }

/* ============================================================
   FORM FIELDS
   ============================================================ */
.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 12px;
}
.field:last-child { margin-bottom: 0; }

.field label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 16px;
}

.input-num, .input-text, .input-textarea {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 14px;
  font-family: var(--font);
  background: var(--card-bg);
  color: var(--text);
  width: 100%;
  transition: border-color .15s, box-shadow .15s;
  appearance: none;
}
.input-num:focus, .input-text:focus, .input-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(43,157,181,.15);
}

.input-textarea { resize: vertical; min-height: 80px; }

.input-date-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  background: var(--card-bg);
  transition: border-color .15s;
}
.input-date-wrap:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(43,157,181,.15); }
.input-date-wrap svg { width: 18px; height: 18px; color: var(--primary); flex-shrink: 0; }
.input-date {
  border: none;
  background: transparent;
  font-size: 14px;
  font-family: var(--font);
  color: var(--text);
  flex: 1;
}
.input-date:focus { outline: none; }

/* Password eye */
.input-eye { position: relative; }
.input-eye .input-num,
.input-eye input { padding-right: 40px; width: 100%; }
.eye-btn {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 2px;
}
.eye-btn svg { width: 18px; height: 18px; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: background .15s, transform .1s;
  text-decoration: none;
  font-family: var(--font);
}
.btn:active { transform: scale(.98); }

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }

.btn-outline {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-outline:hover { background: var(--bg); }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #b91c1c; }

.btn-full { width: 100%; }

.btn-sm { padding: 7px 14px; font-size: 13px; }

.btn-save {
  gap: 8px;
}
.btn-save svg { width: 18px; height: 18px; }

/* Icon buttons */
.icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 6px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--bg); color: var(--text); }
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn-danger:hover { background: var(--danger-bg); color: var(--danger); }

.btn-refresh {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 8px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  flex-shrink: 0;
  transition: background .15s;
}
.btn-refresh:hover { background: var(--bg); }
.btn-refresh svg { width: 18px; height: 18px; }

/* ============================================================
   ALERT
   ============================================================ */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 13px;
  font-weight: 500;
}
.alert-error { background: var(--danger-bg); color: var(--danger); border: 1px solid #fecaca; }

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-box {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 28px 24px;
  width: 100%;
  max-width: 420px;
}

.modal-box h3 { font-size: 17px; font-weight: 700; margin-bottom: 10px; }
.modal-box p  { color: var(--text-muted); font-size: 14px; margin-bottom: 20px; line-height: 1.6; }
.modal-box p strong { color: var(--text); }

.modal-actions { display: flex; gap: 10px; }
.modal-actions .btn { flex: 1; }

/* ============================================================
   TOAST
   ============================================================ */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: #1a1d23;
  color: white;
  padding: 12px 22px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  z-index: 999;
  transition: transform .3s cubic-bezier(.34,1.56,.64,1), opacity .3s;
  opacity: 0;
  white-space: nowrap;
  box-shadow: var(--shadow-md);
  pointer-events: none;
}
.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}
.toast.success { background: var(--success); }
.toast.error   { background: var(--danger); }

/* ============================================================
   SEARCH
   ============================================================ */
.search-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 20px;
}
.search-wrap svg { width: 18px; height: 18px; color: var(--text-muted); flex-shrink: 0; }
.search-wrap input {
  border: none;
  background: transparent;
  flex: 1;
  font-size: 14px;
  font-family: var(--font);
  color: var(--text);
}
.search-wrap input:focus { outline: none; }
.search-wrap input::placeholder { color: var(--text-muted); }

/* ============================================================
   TABLES (oficina)
   ============================================================ */
.table-section {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  margin-bottom: 28px;
  overflow: hidden;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border);
}
.section-title svg { width: 18px; height: 18px; color: var(--primary); }

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  white-space: nowrap;
}

.data-table th {
  background: #f8fafc;
  font-weight: 600;
  color: var(--text-muted);
  text-align: center;
  padding: 9px 10px;
  border-bottom: 2px solid var(--border);
  border-right: 1px solid var(--border);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.data-table th:first-child { text-align: left; }

.th-group {
  text-align: center !important;
  font-size: 11px !important;
  letter-spacing: .05em;
}
.th-pozo { background: #e8f4fb !important; color: var(--primary) !important; border-bottom: 1px solid #bde0ed !important; }
.th-dep  { background: #edf7f1 !important; color: var(--success)  !important; border-bottom: 1px solid #bbddc9 !important; }
.th-sub  { font-weight: 500 !important; text-transform: none !important; letter-spacing: 0 !important; }
.th-sub.th-dep { background: #f0fdf4 !important; }

.data-table td {
  padding: 8px 10px;
  text-align: right;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid #f1f3f5;
}

.td-fecha { text-align: left !important; font-weight: 600; color: var(--text); min-width: 75px; }
.td-op    { text-align: left !important; color: var(--text-muted); min-width: 130px; }
.td-dash  { color: #ccc; text-align: center !important; }
.td-empty { text-align: center !important; color: var(--text-muted); padding: 24px; }
.td-notas { max-width: 200px; overflow: hidden; text-overflow: ellipsis; }

.td-anomaly {
  background: #fff5f5;
  color: var(--danger) !important;
  font-weight: 600;
}

.anom-icon {
  font-size: 10px;
  color: var(--danger);
  vertical-align: super;
}

.data-table tbody tr:hover { background: #f8fafc; }

/* ============================================================
   ADMIN - OPERARIOS
   ============================================================ */
.admin-section {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  padding: 20px;
  margin-bottom: 24px;
}

.admin-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.admin-section-header .section-title { padding: 0; border: none; margin-bottom: 0; }

.op-group { margin-bottom: 20px; }
.op-group:last-child { margin-bottom: 0; }

.op-group-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.op-group-title svg { width: 14px; height: 14px; }

.op-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid #f1f3f5;
}
.op-row:last-child { border-bottom: none; }

.op-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.op-dot-green { background: #22c55e; }
.op-dot-gray  { background: #9ca3af; }
.op-dot-blue  { background: var(--primary); }

.op-info { flex: 1; min-width: 0; }
.op-name { display: block; font-weight: 500; font-size: 14px; }
.op-user { display: block; color: var(--text-muted); font-size: 12px; }

/* BADGES */
.badge {
  font-size: 12px;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: 999px;
  flex-shrink: 0;
  border: none;
  cursor: default;
}
.badge-system   { background: #eff6ff; color: #1d4ed8; }
.badge-active   { background: var(--success-bg); color: var(--success); cursor: pointer; }
.badge-inactive { background: var(--bg); color: var(--text-muted); cursor: pointer; }

/* SUB-TABS */
.sub-tabs {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 16px;
}

.sub-tab {
  flex: 1;
  background: none;
  border: none;
  cursor: pointer;
  padding: 9px 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  transition: background .15s;
  border-right: 1px solid var(--border);
}
.sub-tab:last-child { border-right: none; }
.sub-tab.active { background: var(--primary); color: white; }
.sub-tab:not(.active):hover { background: var(--bg); }

.subtab-content { display: none; }
.subtab-content.active { display: block; }

/* Record rows (admin list) */
.record-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 0;
  border-bottom: 1px solid #f1f3f5;
}
.record-row:last-child { border-bottom: none; }

.record-info { display: flex; flex-direction: column; }
.record-date { font-weight: 600; font-size: 14px; }
.record-op   { font-size: 12px; color: var(--text-muted); margin-top: 1px; }
.record-actions { display: flex; gap: 4px; }

.empty-msg { color: var(--text-muted); font-size: 13px; text-align: center; padding: 16px 0; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 600px) {
  .grid-2 { grid-template-columns: 1fr; gap: 0; }
  .main-content { padding: 16px 12px 80px; }
  .login-card { padding: 24px 18px; }
  .data-table { font-size: 12px; }
  .admin-section-header { flex-direction: column; align-items: flex-start; gap: 10px; }
}

/* Edit mode banner */
.alert-edit {
  background: #e8f4fd;
  color: #1565c0;
  border: 1px solid #b3d4f5;
  border-radius: 10px;
  padding: 11px 16px;
  margin-bottom: 16px;
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.alert-edit a { color: #1565c0; font-weight: 700; text-decoration: underline; }

/* ============================================================
   HEADER - BOTONES ICONO (nuevos)
   ============================================================ */
.header-icon-btn {
  color: rgba(255,255,255,.85);
  background: none;
  border: none;
  cursor: pointer;
  padding: 7px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
  text-decoration: none;
  line-height: 1;
}
.header-icon-btn:hover,
.header-icon-btn.active { background: rgba(255,255,255,.22); color: #fff; }
.header-icon-btn svg { width: 20px; height: 20px; }

/* Modal exportar BD */
.export-btns { display: flex; gap: 12px; }
.btn-export  { flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 15px; font-weight: 600; }

/* ============================================================
   LOGIN v2 - toggle "mantener sesión"
   ============================================================ */
.login-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 16px 0;
  font-size: 13px;
  color: var(--text-muted);
}
.login-toggle-switch { position: relative; display: inline-block; width: 40px; height: 22px; }
.login-toggle-switch input { opacity: 0; width: 0; height: 0; }
.login-toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: #cbd5e0;
  border-radius: 22px;
  transition: .3s;
}
.login-toggle-slider:before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: .3s;
}
.login-toggle-switch input:checked + .login-toggle-slider { background: var(--primary); }
.login-toggle-switch input:checked + .login-toggle-slider:before { transform: translateX(18px); }

/* Inputs numéricos: sin flechas y placeholder visible */
.input-num { -moz-appearance: textfield; }
.input-num::-webkit-outer-spin-button,
.input-num::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.input-num::placeholder { color: #b0bec5; font-style: italic; }
.input-text::placeholder { color: #b0bec5; }

/* Botón ojo - copiar último valor */
.btn-eye {
  width: 36px;
  height: 40px;
  background: #e8f2f7;
  border: 1px solid #b3cdd8;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #07506f;
  transition: background .15s;
}
.btn-eye:hover { background: #c5dde8; }
.num-wrap { display: flex; gap: 6px; align-items: center; }
.num-wrap .input-num { flex: 1; }

/* ============================================================
   MENÚ HAMBURGUESA - Solo móvil (≤640px)
   ============================================================ */

/* Botón hamburguesa: oculto en desktop */
.hamburger-btn {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 7px;
  border-radius: 7px;
  color: rgba(255,255,255,.9);
  align-items: center;
  justify-content: center;
  transition: background .15s;
  flex-shrink: 0;
}
.hamburger-btn:hover { background: rgba(255,255,255,.2); }
.hamburger-btn svg { width: 22px; height: 22px; }

/* Iconos del header: visibles en desktop, ocultos en móvil */
.header-icons-desktop { display: flex; align-items: center; gap: 8px; }

/* Overlay oscuro */
.drawer-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 998;
  opacity: 0;
  transition: opacity .25s;
}
.drawer-overlay.open { display: block; opacity: 1; }

/* Panel lateral derecho */
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: 240px;
  height: 100%;
  background: var(--primary-dark);
  z-index: 999;
  transform: translateX(100%);
  transition: transform .28s cubic-bezier(.4,0,.2,1);
  display: flex;
  flex-direction: column;
  box-shadow: -4px 0 20px rgba(0,0,0,.3);
}
.drawer.open { transform: translateX(0); }

/* Cabecera del drawer */
.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid rgba(255,255,255,.12);
}
.drawer-header span {
  color: rgba(255,255,255,.9);
  font-size: 14px;
  font-weight: 600;
}
.drawer-close {
  background: none;
  border: none;
  cursor: pointer;
  color: rgba(255,255,255,.8);
  padding: 4px;
  border-radius: 6px;
  display: flex;
  align-items: center;
}
.drawer-close:hover { background: rgba(255,255,255,.15); }
.drawer-close svg { width: 20px; height: 20px; }

/* Items del drawer */
.drawer-body { flex: 1; overflow-y: auto; padding: 10px 0; }

.drawer-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 18px;
  color: rgba(255,255,255,.88);
  font-size: 13px;
  font-weight: 500;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s;
}
.drawer-item:hover { background: rgba(255,255,255,.12); color: #fff; }
.drawer-item.active { background: rgba(255,255,255,.18); color: #fff; }
.drawer-item svg { width: 18px; height: 18px; flex-shrink: 0; opacity: .85; }

.drawer-separator {
  height: 1px;
  background: rgba(255,255,255,.1);
  margin: 8px 18px;
}

/* Activar en móvil */
@media (max-width: 640px) {
  .header-icons-desktop { display: none !important; }
  .hamburger-btn { display: flex; }
}

@media (max-width: 600px) {
  .sub-tabs { gap: 4px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .sub-tabs::-webkit-scrollbar { display: none; }
  .sub-tab { font-size: 11px; padding: 7px 8px; white-space: nowrap; flex-shrink: 0; border-radius: 8px; }
}
