/* ═══════════════════════════════════════════════════════════════════════
   WattiQ — Calculadora de Consumo Eléctrico
   CSS Widget — todo con prefijo .wq- para no interferir con Drupal/CMS
   ═══════════════════════════════════════════════════════════════════════ */

/* ── Variables ─────────────────────────────────────────────────────────── */
.wq-app {
  --wq-primary:       #1565C0;
  --wq-primary-light: #1E88E5;
  --wq-primary-dark:  #0D47A1;
  --wq-secondary:     #0097A7;
  --wq-accent:        #FFB300;
  --wq-accent-light:  #FFD54F;
  --wq-bg:            #F0F4F8;
  --wq-surface:       #FFFFFF;
  --wq-surface-alt:   #E8F0FE;
  --wq-text:          #212121;
  --wq-text-sec:      #546E7A;
  --wq-text-light:    #90A4AE;
  --wq-border:        #DDEEFF;
  --wq-error:         #D32F2F;
  --wq-success:       #2E7D32;
  --wq-white:         #FFFFFF;
  --wq-radius-sm:     8px;
  --wq-radius-md:     14px;
  --wq-radius-lg:     20px;
  --wq-radius-xl:     28px;
  --wq-shadow-sm:     0 2px 8px rgba(21,101,192,.10);
  --wq-shadow-md:     0 4px 16px rgba(21,101,192,.14);
  --wq-shadow-lg:     0 8px 32px rgba(21,101,192,.18);
  --wq-grad:          linear-gradient(135deg, #1565C0 0%, #0097A7 100%);
  --wq-grad-btn:      linear-gradient(90deg,  #1565C0 0%, #0097A7 100%);

  /* Reset básico dentro del widget */
  box-sizing: border-box;
  font-family: 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  font-size: 15px;
  color: var(--wq-text);
  background: var(--wq-bg);
  border-radius: var(--wq-radius-lg);
  overflow: hidden;
  max-width: 620px;
  margin: 0 auto;
  box-shadow: var(--wq-shadow-lg);
}

.wq-app *, .wq-app *::before, .wq-app *::after {
  box-sizing: inherit;
  margin: 0;
  padding: 0;
}

/* ── Header ─────────────────────────────────────────────────────────────── */
.wq-header {
  background: var(--wq-grad);
  padding: 20px 20px 16px;
}
.wq-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.wq-logo {
  font-size: 22px;
  font-weight: 800;
  color: var(--wq-white);
  letter-spacing: .3px;
}
.wq-logo-sub {
  font-size: 12px;
  color: rgba(255,255,255,.72);
  margin-top: 2px;
}
.wq-refresh-btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,.2);
  border: 1.5px solid rgba(255,255,255,.5);
  color: var(--wq-white);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  transition: background .2s;
}
.wq-refresh-btn:hover { background: rgba(255,255,255,.32); }
.wq-refresh-btn:disabled { opacity: .5; cursor: default; }

.wq-price-badge {
  background: rgba(255,255,255,.15);
  border-radius: var(--wq-radius-sm);
  padding: 9px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.wq-price-badge-label { font-size: 12px; color: rgba(255,255,255,.8); }
.wq-price-badge-value { font-size: 14px; font-weight: 700; color: var(--wq-accent-light); }

/* ── Navigation tabs ────────────────────────────────────────────────────── */
.wq-tabs {
  display: flex;
  background: var(--wq-surface);
  border-bottom: 2px solid var(--wq-border);
}
.wq-tab {
  flex: 1;
  padding: 13px 0;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--wq-text-light);
  cursor: pointer;
  border: none;
  background: none;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: color .2s, border-color .2s;
}
.wq-tab.active {
  color: var(--wq-primary);
  border-bottom-color: var(--wq-primary);
}

/* ── Screens ────────────────────────────────────────────────────────────── */
.wq-screen { display: none; }
.wq-screen.active { display: block; }

/* ── Scroll area ────────────────────────────────────────────────────────── */
.wq-scroll {
  padding: 16px;
  background: var(--wq-bg);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.wq-scroll::-webkit-scrollbar { width: 4px; }
.wq-scroll::-webkit-scrollbar-thumb { background: var(--wq-border); border-radius: 4px; }

/* ── Card ───────────────────────────────────────────────────────────────── */
.wq-card {
  background: var(--wq-surface);
  border-radius: var(--wq-radius-lg);
  padding: 18px;
  box-shadow: var(--wq-shadow-sm);
}
.wq-card-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .12em;
  color: var(--wq-primary);
  text-transform: uppercase;
  margin-bottom: 14px;
}

/* ── Appliance selector ─────────────────────────────────────────────────── */
.wq-appliance-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--wq-surface-alt);
  border: 1.5px solid var(--wq-border);
  border-radius: var(--wq-radius-md);
  padding: 11px 14px;
  cursor: pointer;
  transition: border-color .2s, box-shadow .2s;
  text-align: left;
}
.wq-appliance-btn:hover {
  border-color: var(--wq-primary-light);
  box-shadow: var(--wq-shadow-sm);
}
.wq-appliance-icon-wrap {
  width: 44px; height: 44px;
  background: var(--wq-surface);
  border-radius: var(--wq-radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
}
.wq-appliance-btn-name  { font-size: 15px; font-weight: 600; color: var(--wq-text); }
.wq-appliance-btn-desc  { font-size: 12px; color: var(--wq-text-sec); margin-top: 2px; }
.wq-appliance-btn-arrow { margin-left: auto; font-size: 20px; color: var(--wq-primary); }

/* ── Form fields ────────────────────────────────────────────────────────── */
.wq-field { margin-top: 14px; }
.wq-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--wq-text-sec);
  margin-bottom: 6px;
}
.wq-hint {
  font-size: 11px;
  color: var(--wq-text-light);
  font-style: italic;
  margin-top: 4px;
}
.wq-input-wrap {
  display: flex;
  align-items: stretch;
  border: 1.5px solid var(--wq-border);
  border-radius: var(--wq-radius-md);
  overflow: hidden;
  background: var(--wq-surface);
  transition: border-color .2s;
}
.wq-input-wrap:focus-within { border-color: var(--wq-primary); }
.wq-input-wrap.error { border-color: var(--wq-error); }
.wq-input {
  flex: 1;
  border: none;
  outline: none;
  padding: 11px 14px;
  font-size: 15px;
  color: var(--wq-text);
  background: transparent;
}
.wq-input-unit {
  padding: 0 12px;
  background: var(--wq-surface-alt);
  display: flex; align-items: center;
  font-size: 12px; font-weight: 700;
  color: var(--wq-primary);
  border-left: 1.5px solid var(--wq-border);
  white-space: nowrap;
}
.wq-error-msg {
  font-size: 11px;
  color: var(--wq-error);
  margin-top: 4px;
  display: none;
}
.wq-error-msg.visible { display: block; }

/* ── Stepper ────────────────────────────────────────────────────────────── */
.wq-stepper {
  display: flex;
  align-items: stretch;
  border: 1.5px solid var(--wq-border);
  border-radius: var(--wq-radius-md);
  overflow: hidden;
  background: var(--wq-surface);
}
.wq-step-btn {
  width: 48px;
  background: var(--wq-surface-alt);
  border: none;
  cursor: pointer;
  font-size: 20px;
  color: var(--wq-primary);
  display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.wq-step-btn:hover { background: var(--wq-border); }
.wq-step-input {
  flex: 1;
  border: none;
  outline: none;
  text-align: center;
  font-size: 18px;
  font-weight: 700;
  color: var(--wq-text);
  padding: 10px 0;
  background: transparent;
}

/* ── Price toggle ───────────────────────────────────────────────────────── */
.wq-toggle {
  display: flex;
  background: var(--wq-surface-alt);
  border-radius: 12px;
  padding: 4px;
  gap: 4px;
  margin-bottom: 14px;
}
.wq-toggle-btn {
  flex: 1;
  padding: 9px 8px;
  border: none;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s, color .2s;
  background: transparent;
  color: var(--wq-primary);
}
.wq-toggle-btn.active {
  background: var(--wq-primary);
  color: var(--wq-white);
}

.wq-auto-price-box {
  background: var(--wq-surface-alt);
  border-radius: var(--wq-radius-md);
  padding: 16px;
  text-align: center;
}
.wq-auto-price-value {
  font-size: 28px; font-weight: 800;
  color: var(--wq-primary);
}
.wq-auto-price-source {
  font-size: 12px; color: var(--wq-text-sec);
  margin-top: 4px;
}
.wq-spinner {
  display: inline-block;
  width: 24px; height: 24px;
  border: 3px solid var(--wq-border);
  border-top-color: var(--wq-primary);
  border-radius: 50%;
  animation: wq-spin .7s linear infinite;
}
@keyframes wq-spin { to { transform: rotate(360deg); } }

/* ── Calculate button ───────────────────────────────────────────────────── */
.wq-calc-btn {
  width: 100%;
  padding: 16px;
  background: var(--wq-grad-btn);
  color: var(--wq-white);
  border: none;
  border-radius: var(--wq-radius-lg);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--wq-shadow-md);
  transition: filter .2s, transform .1s;
  letter-spacing: .3px;
}
.wq-calc-btn:hover  { filter: brightness(1.08); }
.wq-calc-btn:active { transform: scale(.98); }

/* ── Results card ───────────────────────────────────────────────────────── */
.wq-results {
  display: none;
  flex-shrink: 0;
  border-radius: var(--wq-radius-lg);
  overflow: hidden;
  box-shadow: var(--wq-shadow-md);
  animation: wq-fadein .35s ease;
}
.wq-results.visible { display: block; }
@keyframes wq-fadein { from { opacity:0; transform:translateY(10px); } to { opacity:1; transform:none; } }

.wq-results-header {
  background: var(--wq-grad);
  padding: 16px 18px;
}
.wq-results-title  { font-size: 16px; font-weight: 700; color: var(--wq-white); }
.wq-results-params { font-size: 12px; color: rgba(255,255,255,.72); margin-top: 3px; }

.wq-results-body { background: var(--wq-surface); padding: 14px; }

.wq-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 10px;
}
.wq-cell {
  border-radius: var(--wq-radius-md);
  padding: 13px 10px;
  text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.wq-cell-plain { background: var(--wq-surface-alt); }
.wq-cell-hl    { background: var(--wq-grad); }
.wq-cell-emoji { font-size: 20px; line-height: 1; }
.wq-cell-label {
  font-size: 10px; font-weight: 600;
  color: var(--wq-text-sec);
  text-transform: uppercase; letter-spacing: .06em;
}
.wq-cell-hl .wq-cell-label { color: rgba(255,255,255,.75); }
.wq-cell-value { font-size: 16px; font-weight: 800; color: var(--wq-text); }
.wq-cell-hl .wq-cell-value { color: var(--wq-white); }

.wq-price-note {
  font-size: 11px; color: var(--wq-text-sec);
  margin-top: 6px; margin-bottom: 12px;
}

.wq-action-row {
  display: flex; gap: 10px;
  margin-top: 4px;
}
.wq-btn-outline {
  flex: 1; padding: 11px;
  border: 1.5px solid var(--wq-primary);
  border-radius: var(--wq-radius-md);
  background: transparent;
  color: var(--wq-primary);
  font-size: 13px; font-weight: 700;
  cursor: pointer;
  transition: background .15s;
}
.wq-btn-outline:hover { background: var(--wq-surface-alt); }
.wq-btn-solid {
  flex: 1; padding: 11px;
  border: none;
  border-radius: var(--wq-radius-md);
  background: var(--wq-primary);
  color: var(--wq-white);
  font-size: 13px; font-weight: 700;
  cursor: pointer;
  transition: filter .15s;
}
.wq-btn-solid:hover { filter: brightness(1.1); }

/* ── Toast ──────────────────────────────────────────────────────────────── */
.wq-toast {
  position: fixed;
  bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #212121; color: #fff;
  padding: 10px 20px;
  border-radius: 24px;
  font-size: 13px; font-weight: 600;
  box-shadow: 0 4px 16px rgba(0,0,0,.25);
  opacity: 0; pointer-events: none;
  transition: opacity .3s;
  z-index: 9999;
  white-space: nowrap;
}
.wq-toast.show { opacity: 1; }

/* ── Picker modal ───────────────────────────────────────────────────────── */
.wq-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 9000;
  display: flex; align-items: flex-end; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity .25s;
}
.wq-modal-overlay.open { opacity: 1; pointer-events: all; }

.wq-modal {
  width: 100%; max-width: 620px;
  background: var(--wq-surface);
  border-radius: var(--wq-radius-xl) var(--wq-radius-xl) 0 0;
  max-height: 85vh;
  display: flex; flex-direction: column;
  transform: translateY(40px);
  transition: transform .25s;
}
.wq-modal-overlay.open .wq-modal { transform: translateY(0); }

.wq-modal-handle {
  width: 40px; height: 4px;
  background: var(--wq-border);
  border-radius: 4px;
  margin: 10px auto 4px;
  flex-shrink: 0;
}
.wq-modal-header {
  background: var(--wq-grad);
  padding: 14px 18px;
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
}
.wq-modal-title { font-size: 17px; font-weight: 700; color: var(--wq-white); }
.wq-modal-close {
  background: rgba(255,255,255,.2); border: none;
  width: 32px; height: 32px; border-radius: 50%;
  color: var(--wq-white); font-size: 18px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}

.wq-search-row {
  padding: 10px 14px;
  flex-shrink: 0;
}
.wq-search-input-wrap {
  display: flex; align-items: center; gap: 8px;
  background: var(--wq-bg);
  border-radius: var(--wq-radius-md);
  padding: 8px 14px;
}
.wq-search-input {
  flex: 1; border: none; outline: none;
  background: transparent; font-size: 14px; color: var(--wq-text);
}

.wq-picker-list {
  overflow-y: auto; flex: 1;
  padding-bottom: 16px;
}
.wq-picker-list::-webkit-scrollbar { width: 4px; }
.wq-picker-list::-webkit-scrollbar-thumb { background: var(--wq-border); border-radius: 4px; }

.wq-cat-header {
  padding: 10px 16px 6px;
  background: var(--wq-bg);
  font-size: 10px; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--wq-text-sec);
}
.wq-picker-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--wq-border);
  transition: background .15s;
}
.wq-picker-item:hover { background: var(--wq-surface-alt); }
.wq-picker-item.selected { background: var(--wq-surface-alt); }
.wq-picker-item-icon {
  width: 42px; height: 42px;
  background: var(--wq-surface-alt);
  border-radius: var(--wq-radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; flex-shrink: 0;
}
.wq-picker-item-name { font-size: 14px; font-weight: 600; color: var(--wq-text); }
.wq-picker-item-desc { font-size: 11px; color: var(--wq-text-sec); margin-top: 2px; }
.wq-picker-item-power {
  margin-left: auto;
  background: var(--wq-surface-alt);
  border: 1px solid var(--wq-border);
  border-radius: 20px;
  padding: 3px 9px;
  font-size: 11px; font-weight: 700; color: var(--wq-primary);
  white-space: nowrap; flex-shrink: 0;
}
.wq-picker-check {
  margin-left: 6px; font-size: 16px; color: var(--wq-primary); font-weight: 700;
  flex-shrink: 0;
}

/* ── History screen ─────────────────────────────────────────────────────── */
.wq-hist-summary {
  background: var(--wq-grad);
  padding: 14px 18px;
  display: flex; align-items: center; justify-content: space-between;
}
.wq-hist-count  { font-size: 13px; font-weight: 600; color: rgba(255,255,255,.8); }
.wq-hist-annual { font-size: 14px; font-weight: 800; color: var(--wq-accent-light); }
.wq-clear-btn {
  background: rgba(255,255,255,.18); border: 1.5px solid rgba(255,255,255,.45);
  border-radius: 20px; padding: 5px 14px;
  color: var(--wq-white); font-size: 12px; font-weight: 600;
  cursor: pointer; transition: background .15s;
}
.wq-clear-btn:hover { background: rgba(255,255,255,.3); }

.wq-hist-list {
  padding: 14px;
  background: var(--wq-bg);
  display: flex; flex-direction: column; gap: 10px;
  max-height: 75vh; overflow-y: auto;
}
.wq-hist-list::-webkit-scrollbar { width: 4px; }
.wq-hist-list::-webkit-scrollbar-thumb { background: var(--wq-border); border-radius: 4px; }

.wq-hist-card {
  background: var(--wq-surface);
  border-radius: var(--wq-radius-lg);
  overflow: hidden;
  box-shadow: var(--wq-shadow-sm);
  cursor: pointer;
  transition: box-shadow .2s;
}
.wq-hist-card:hover { box-shadow: var(--wq-shadow-md); }

.wq-hist-card-top {
  display: flex; align-items: center; gap: 11px;
  padding: 12px 14px;
}
.wq-hist-icon {
  width: 44px; height: 44px;
  background: var(--wq-surface-alt); border-radius: var(--wq-radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; flex-shrink: 0;
}
.wq-hist-name { font-size: 14px; font-weight: 700; color: var(--wq-text); }
.wq-hist-date { font-size: 11px; color: var(--wq-text-light); margin-top: 2px; }
.wq-hist-actions { margin-left: auto; display: flex; gap: 4px; }
.wq-hist-action-btn {
  width: 32px; height: 32px;
  background: var(--wq-bg); border: none; border-radius: var(--wq-radius-sm);
  cursor: pointer; font-size: 15px; display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.wq-hist-action-btn:hover { background: var(--wq-border); }

.wq-hist-mid {
  display: flex;
  padding: 0 14px 10px;
  gap: 0;
}
.wq-hist-stat {
  flex: 1; text-align: center;
  border-right: 1px solid var(--wq-border);
}
.wq-hist-stat:last-child { border-right: none; }
.wq-hist-stat-label { font-size: 10px; font-weight: 600; color: var(--wq-text-light); text-transform: uppercase; }
.wq-hist-stat-value { font-size: 13px; font-weight: 700; color: var(--wq-text); margin-top: 2px; }
.wq-hist-stat-value.accent { color: var(--wq-primary); }

.wq-hist-footer {
  display: flex;
  background: linear-gradient(90deg, rgba(21,101,192,.07), rgba(0,151,167,.07));
  border-top: 1px solid var(--wq-border);
  padding: 9px 14px;
}
.wq-hist-footer-item {
  flex: 1; text-align: center;
  border-right: 1px solid var(--wq-border);
}
.wq-hist-footer-item:last-child { border-right: none; }
.wq-hist-footer-label { font-size: 10px; font-weight: 600; color: var(--wq-text-sec); }
.wq-hist-footer-value { font-size: 13px; font-weight: 700; color: var(--wq-text); margin-top: 2px; }
.wq-hist-footer-value.primary { color: var(--wq-primary); }

.wq-empty {
  text-align: center; padding: 48px 16px;
}
.wq-empty-emoji { font-size: 56px; line-height: 1; }
.wq-empty-title { font-size: 18px; font-weight: 700; color: var(--wq-text); margin-top: 12px; }
.wq-empty-text  { font-size: 13px; color: var(--wq-text-sec); margin-top: 8px; line-height: 1.6; }

/* ── Confirm dialog ──────────────────────────────────────────────────────── */
.wq-dialog-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 9100;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.wq-dialog-overlay.open { opacity: 1; pointer-events: all; }
.wq-dialog {
  background: var(--wq-surface);
  border-radius: var(--wq-radius-lg);
  padding: 24px;
  max-width: 360px; width: 100%;
  box-shadow: var(--wq-shadow-lg);
  transform: scale(.95); transition: transform .2s;
}
.wq-dialog-overlay.open .wq-dialog { transform: scale(1); }
.wq-dialog-title   { font-size: 17px; font-weight: 700; color: var(--wq-text); margin-bottom: 10px; }
.wq-dialog-message { font-size: 14px; color: var(--wq-text-sec); line-height: 1.5; margin-bottom: 20px; }
.wq-dialog-btns { display: flex; gap: 10px; justify-content: flex-end; }
.wq-dialog-cancel {
  padding: 9px 18px; border: 1.5px solid var(--wq-border); border-radius: var(--wq-radius-md);
  background: transparent; color: var(--wq-text-sec); font-size: 14px; font-weight: 600; cursor: pointer;
}
.wq-dialog-confirm {
  padding: 9px 18px; border: none; border-radius: var(--wq-radius-md);
  background: var(--wq-error); color: var(--wq-white); font-size: 14px; font-weight: 600; cursor: pointer;
}

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .wq-hist-list  { max-height: 70vh; }
  .wq-cell-value { font-size: 14px; }
  .wq-auto-price-value { font-size: 22px; }
}
