/* =====================================================
   ROOT / BRANDING
===================================================== */
:root {
  --color-primary: #2563eb; /* Azul principal (botón) */
  --color-primary-dark: #1e4fd8;
  --color-accent: #18c1d6; /* Turquesa del logo */
  --color-bg: #f4f6f8; /* Fondo app */
  --color-card: #ffffff;
  --color-text: #111827;
  --color-border: #d1d5db;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family:
    -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'SF Pro Display',
    system-ui, Arial, sans-serif;
  background: #f4f6f8;
}

* {
  touch-action: manipulation;
}

/* ==============================
   LAYOUT BASE
================================ */

body,
html {
  height: 100%;
  margin: 0;
  overflow: hidden; /* 🔑 evita scroll global */
}

#appMain {
  position: fixed;
  top: 56px; /* altura del header */
  bottom: 56px; /* altura del footer */
  left: 0;
  right: 0;
  overflow-y: auto; /* 🔑 scroll SOLO aquí */
  -webkit-overflow-scrolling: touch;
}

/* ==============================
   BACK BUTTON
================================ */
.global-back-button {
  background: none;
  border: none;
  color: var(--color-primary);
  font-size: 14px;
  cursor: pointer;
  margin-bottom: 12px;
  padding: 0;
}

/* ==============================
   HEADER
================================ */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: #ffffff;
  border-bottom: 1px solid #e5e5e5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  z-index: 100;
}

/* LEFT */
.header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  flex: 1; /* 👈 ocupa el espacio disponible */
  min-width: 0; /* 👈 CLAVE para text-wrap */
}

.header-right {
  position: relative;
  flex-shrink: 0; /* 👈 nunca se comprime */
}

.header-logo {
  height: 28px;
}

.header-company {
  font-weight: 600;
  font-size: 13px;
  line-height: 1.2;
  color: var(--color-text);

  display: -webkit-box;
  -webkit-line-clamp: 2; /* 👈 máximo 2 renglones */
  -webkit-box-orient: vertical;
  overflow: hidden;

  word-break: break-word;
}

/* RIGHT */
.header-user-btn {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--color-primary-dark);
}

/* DROPDOWN */
.header-user-menu {
  position: absolute;
  top: 56px;
  right: 8px;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
  min-width: 220px;
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.header-user-menu.open {
  display: flex;
}

.header-user-menu button {
  background: none;
  border: none;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  cursor: pointer;
  text-align: left;
  color: var(--color-primary-dark);
}

.header-user-menu button:hover {
  background: #f5f5f5;
}

.header-user-menu i {
  font-size: 18px;
}

.menu-divider {
  height: 1px;
  background: #e5e5e5;
  margin: 4px 0;
}

.header-user-menu .logout {
  color: #b91c1c;
}

/* ==============================
   FOOTER CLASS (DYNAMIC)
================================ */
.app-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 64px;
  background: #ffffff;
  border-top: 1px solid #e5e5e5;

  display: flex; /* 🔑 clave */
  justify-content: space-between;
  align-items: center;

  z-index: 100;
}

.app-footer button {
  flex: 1; /* 🔑 distribución equitativa */
  background: none;
  border: none;
  font-size: 11px;
  color: #6b7280;

  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;

  cursor: pointer;
}

.app-footer button i {
  font-size: 20px;
}

.app-footer button.active {
  color: var(--color-primary-dark);
}

/* ==============================
   TOAST
================================ */
.app-toast {
  position: fixed;
  bottom: 90px; /* arriba del footer */
  left: 50%;
  transform: translateX(-50%);
  min-width: 240px;
  max-width: 90%;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.25s ease,
    transform 0.25s ease;
  z-index: 9999;
}

/* Visible */
.app-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(-6px);
}

/* TIPOS */
.app-toast-info {
  background: #e0f2fe;
  color: #0369a1;
}

.app-toast-success {
  background: #dcfce7;
  color: #166534;
}

.app-toast-warning {
  background: #fef9c3;
  color: #854d0e;
}

.app-toast-error {
  background: #fee2e2;
  color: #991b1b;
}

/* USER MENU INFO */
.user-menu-info {
  padding: 12px 14px 8px;
}

.user-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text);
}

.user-role {
  font-size: 12px;
  color: #6b7280;
  margin-top: 2px;
}

/* ==============================
   BOTONES
================================ */
.global-btn-edit,
.global-btn-save,
.global-btn-delete,
.global-btn-cancel,
.global-btn-toggle,
.global-btn-settings,
.global-btn-add {
  border: none;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}

/* EDIT */
.global-btn-edit {
  background: #e5e7eb;
  color: #374151;
}

/* SAVE */
.global-btn-save {
  background: #dcfce7;
  color: #166534;
}

/* CANCEL */
.global-btn-cancel {
  background: #fee2e2;
  color: #991b1b;
}

/* DELETE */
.global-btn-delete {
  background: #ff8282;
  color: #888888;
}

/* ADD */
.global-btn-add {
  background: #e2ecfe;
  color: #2563eb;
}

/* SETTINGS / TYPES */
.global-btn-settings {
  background: #ede9fe;
  color: #6d28d9;
}

/* TOGGLE ACTIVE / INACTIVE */
.global-btn-toggle {
  background: #fef3c7; /* ámbar suave */
  color: #92400e; /* ámbar oscuro */
}

.global-btn-toggle.is-active {
  background: #fee2e2; /* similar a cancel */
  color: #991b1b;
}

/* ==============================
   MORE MENU
================================ */
.more-menu {
  position: absolute;
  bottom: 56px; /* altura del footer */
  right: 0;
  width: 72px; /* mismo ancho que el botón More */
  background: #ffffff;
  border-radius: 10px;
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.12);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  z-index: 1000;
}

.more-menu button {
  background: none;
  border: none;
  padding: 10px 0;
  font-size: 11px;
  color: #374151;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}

.more-menu button i {
  font-size: 18px;
}

.more-menu.hidden {
  display: none;
}

/* ==============================
   TEXTAREA 3 LINES STYLE
================================ */

.textarea-3-lines {
  width: 100%;
  min-height: 72px; /* aprox 3 líneas */
  resize: none;
  padding: 8px 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  background: #ffffff;
  box-sizing: border-box;
}

.textarea-3-lines:focus {
  outline: none;
  border-color: var(--color-primary);
}

/* =========================
   WORK ORDER TEXTAREA
========================= */

textarea.workorder-textarea {
  width: 100%;
  min-height: 72px; /* ~3 líneas */
  max-height: 90px;
  resize: vertical;
  padding: 8px 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
}

/* =======================================
   TAX RATE ROW TABLE STYLE
======================================= */

.tax-rate-row {
  display: grid;
  grid-template-columns: 1fr 80px 60px;
  align-items: center;
  padding: 10px 12px;
  background: #ffffff;
  border-radius: 10px;
  margin-bottom: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.tax-rate-name {
  font-size: 14px;
  font-weight: 500;
}

.tax-rate-value {
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: #2563eb;
}

.tax-rate-switch {
  display: flex;
  justify-content: flex-end;
}
