/* =========================================================
   PWA PETROGAS - APP.CSS GLOBAL ÚNICO
   - Base global
   - Index
   - Dashboard
   - Navbar / Footer
   - Módulos
========================================================= */


/* =========================================================
   1. VARIABLES GLOBALES
========================================================= */
:root {
  --color-primary: #21409A;
  --color-primary-light: #4DA3FF;
  --color-primary-dark: #1a337d;
  --color-secondary: #1F1F1F;

  --color-bg: #F4F4F4;
  --color-card-bg: #FFFFFF;
  --color-text: #1F1F1F;
  --color-text-muted: #666666;
  --color-border: #E0E0E0;

  --color-success: #2e7d32;
  --color-warning: #ed6c02;
  --color-danger: #d32f2f;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-pill: 999px;

  --shadow-sm: 0 2px 6px rgba(0, 0, 0, .08);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, .12);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, .18);
}


/* =========================================================
   2. RESET Y BASE GLOBAL
========================================================= */
*,
*::before,
*::after {
  box-sizing: border-box;
}

body.pg-body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  padding-top: env(safe-area-inset-top);
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
}


/* =========================================================
   3. LAYOUT GENERAL
========================================================= */
.pg-container {
  width: 100%;
  max-width: 620px;
  margin: 0 auto;
  padding: 16px;
}


/* =========================================================
   4. COMPONENTES BASE
========================================================= */

/* ---------- Cards base ---------- */
.card,
.pg-card {
  background: var(--color-card-bg);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
}

/* ---------- Botones base ---------- */
.btn {
  display: inline-block;
  width: 100%;
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}

.btn-primary {
  background: var(--color-primary);
  color: #FFFFFF;
}

.btn-secondary {
  background: #6c757d;
  color: #FFFFFF;
}

.btn-danger {
  background: #E63946;
  color: #FFFFFF;
}

.btn-success {
  background: #58B947;
  color: #FFFFFF;
}

.btn:active {
  transform: scale(.98);
}

/* ---------- Formularios base ---------- */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.form-group label {
  font-weight: 600;
  font-size: 13px;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 10px;
  font-size: 14px;
}


/* =========================================================
   5. INDEX / LISTADOS PRINCIPALES
========================================================= */
.pg-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 10px;
}

.pg-container .pg-list {
  max-width: 420px;
  margin: 16px auto;
}

.pg-btncard {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  min-height: 48px;
  border-radius: 10px;
  text-decoration: none;
  font-size: .95rem;
  font-weight: 600;
  transition: all .2s ease;
}

.pg-btncard--list {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  min-height: 44px;
  border: 1px solid var(--color-primary);
  border-radius: var(--radius-pill);
  background: #FFFFFF;
  color: var(--color-primary);
  text-decoration: none;
  font-size: .9rem;
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .08);
  transition: background .2s, color .2s, box-shadow .2s, transform .2s;
}

.pg-btncard--list:hover {
  background: var(--color-primary);
  color: #FFFFFF;
  box-shadow: 0 3px 6px rgba(0, 0, 0, .15);
  transform: translateY(-1px);
}

.pg-btncard--list i {
  font-size: 1rem;
}

.pg-btncard-text {
  flex: 1;
  margin-left: 6px;
}

.pg-btncard--list .pg-chev {
  font-size: .8rem;
  opacity: .6;
}

.pg-btncard--primary {
  background: var(--color-primary);
  color: #FFFFFF;
  border: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .18);
}

.pg-btncard--primary i {
  color: #FFFFFF;
}

.pg-btncard--primary .pg-chev {
  opacity: .85;
}

.pg-btncard--primary:hover {
  background: var(--color-primary-dark);
  transform: translateY(-2px);
}


/* =========================================================
   6. DASHBOARD / MÉTRICAS
========================================================= */
.dashboard-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.pg-metric i {
  font-size: 22px;
  color: var(--color-primary);
  margin-bottom: 6px;
}

.pg-metric h3 {
  margin: 0 0 6px;
  font-size: 1rem;
  color: var(--color-primary);
  font-weight: 700;
}

.pg-metric span {
  display: block;
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--color-text);
}

.pg-metric small {
  font-size: .8rem;
  color: var(--color-text-muted);
}


/* =========================================================
   7. HEADER
========================================================= */
.pg-header h1 {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.2;
  font-weight: 700;
  color: inherit;
}

.pg-header--center {
  background: #FFFFFF;
  color: var(--color-primary);
  text-align: center;
  border-bottom: 2px solid var(--color-primary);
  box-shadow: none;
}

.pg-header--center h1 {
  margin: 8px 0 10px;
  font-size: 1.05rem !important;
  font-weight: 800;
  letter-spacing: .2px;
}

.pg-title {
  margin: 8px 0 12px;
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-primary);
  text-align: center;
}

.pg-brand {
  height: 22px;
  max-height: 24px;
  width: auto;
  vertical-align: middle;
  margin-right: 6px;
}


/* =========================================================
   8. ALERTAS Y UTILIDADES
========================================================= */
.pg-alert {
  max-width: 500px;
  margin: 0 auto;
  padding: 12px 16px;
  border-radius: 8px;
  font-weight: 500;
  text-align: center;
  box-shadow: var(--shadow-sm);
}

.pg-alert--success {
  background-color: #d1fae5;
  color: #065f46;
  border: 1px solid #10b981;
}

.pg-alert--error {
  background-color: #fee2e2;
  color: #991b1b;
  border: 1px solid #ef4444;
}

.pg-alert--warning {
  background-color: #fef3c7;
  color: #92400e;
  border: 1px solid #f59e0b;
}

.pg-alert--info {
  background-color: #e0f2fe;
  color: #075985;
  border: 1px solid #0ea5e9;
}

.pg-user-info {
  margin-top: 4px;
  font-size: .9rem;
  font-weight: 500;
  color: var(--color-primary);
  text-align: center;
}

.pg-hidden {
  display: none !important;
}


/* =========================================================
   9. OVERLAY GLOBAL
========================================================= */
#overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  justify-content: center;
  align-items: center;
  background: rgba(0, 0, 0, .4);
}

#overlay .spinner {
  background: #FFFFFF;
  padding: 20px 30px;
  border-radius: 10px;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--color-primary);
  box-shadow: 0 3px 10px rgba(0, 0, 0, .2);
}


/* =========================================================
   10. NAVBAR INFERIOR
========================================================= */
.pg-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  min-height: 64px;
  display: flex;
  justify-content: space-around;
  align-items: center;
  background: var(--color-secondary);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  z-index: 1000;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, .15);
}

.pg-bottom-nav a,
.pg-bottom-nav .pg-nav-more {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 4px 2px;
  background: none;
  border: none;
  color: #bfc6d4;
  text-decoration: none;
  text-align: center;
  font-size: 11px;
  font-family: inherit;
  cursor: pointer;
  transition: color .15s ease;
}

.pg-bottom-nav a i,
.pg-bottom-nav .pg-nav-more i {
  font-size: 18px;
  line-height: 1;
}

.pg-bottom-nav a span,
.pg-bottom-nav .pg-nav-more span {
  display: block;
  font-size: 10px;
  line-height: 1.1;
  text-align: center;
  white-space: nowrap;
}

.pg-bottom-nav a:hover,
.pg-bottom-nav a.active,
.pg-bottom-nav .pg-nav-more:hover {
  color: var(--color-primary-light);
}

.pg-bottom-nav a:focus,
.pg-bottom-nav .pg-nav-more:focus {
  outline: none;
}


/* =========================================================
   11. MENÚ MÁS
========================================================= */
.pg-more-menu {
  position: fixed;
  right: 12px;
  bottom: 76px;
  min-width: 180px;
  background: #FFFFFF;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  overflow: hidden;
  z-index: 1100;
  box-shadow: var(--shadow-lg);
}

.pg-more-menu a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  text-decoration: none;
  color: var(--color-text);
  font-size: 14px;
  border-bottom: 1px solid #f1f1f1;
}

.pg-more-menu a:last-child {
  border-bottom: none;
}

.pg-more-menu a i {
  width: 18px;
  text-align: center;
  color: var(--color-primary);
}

.pg-more-menu a:hover {
  background: #f9fafb;
}


/* =========================================================
   12. FOOTER
========================================================= */
.pg-footer {
  position: fixed;
  bottom: calc(64px + env(safe-area-inset-bottom));
  left: 0;
  right: 0;
  z-index: 900;
  background: #FFFFFF;
  border-top: 1px solid #e5e7eb;
  text-align: center;
  padding: 6px 8px;
  font-size: .75rem;
  font-weight: 500;
  color: var(--color-text-muted);
}

.pg-footer p {
  margin: 0;
  line-height: 1.2;
}


/* =========================================================
   13. MÓDULOS ESPECÍFICOS
========================================================= */

/* ---------- Checklist ---------- */
.pg-checklist .item-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid #eeeeee;
}

/* ---------- Historial checklist ---------- */
.pg-checklist-history .pg-table {
  width: 100%;
  border-collapse: collapse;
}

.pg-checklist-history th {
  background: var(--color-primary);
  color: #FFFFFF;
  padding: 8px;
}

.pg-checklist-history td {
  padding: 8px;
  border-bottom: 1px solid #eeeeee;
}

/* ---------- OT ---------- */
.pg-ot .pg-ot-card {
  background: #FFFFFF;
  border-radius: 14px;
  padding: 18px;
  box-shadow: var(--shadow-md);
}

.pg-ot-submit {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 10px;
  background: var(--color-primary);
  color: #FFFFFF;
}

/* ---------- Parte diario ---------- */
.pg-parte .pg-special-row {
  display: flex;
  gap: 10px;
}

.pg-parte .pg-special-label {
  flex: 1;
  padding: 12px;
  border: 1px solid #cccccc;
  border-radius: 8px;
  text-align: center;
}

/* ---------- Wizard ---------- */
.pg-wizard .wizard-step {
  display: none;
}

.pg-wizard .wizard-step.active {
  display: block;
}

.pg-wizard .btn {
  width: auto;
}


/* =========================================================
   14. RESPONSIVE
========================================================= */
@media (max-width: 480px) {
  .pg-container {
    padding: 12px;
  }

  .btn {
    font-size: 13px;
  }
}