/* ═══════════════════════════════════════════════════════════════
   SURIAPP – inventory-extras.css
   Estilos para columnas nuevas: Imagen, Descripción, Proveedor +
   secciones Clientes y Proveedores. Coherente con el tema oscuro
   (variables de dashboard.css). Totalmente responsive.
   ═══════════════════════════════════════════════════════════════ */

/* ─────────────────────────────────────────────────────────────
   COLUMNA IMAGEN — Thumbnail / botón de cámara
   ───────────────────────────────────────────────────────────── */
.tbl-inventory .td-image,
.tbl-inventory .th-image { width: 62px; }

.prod-image-thumb {
  width: 44px; height: 44px;
  border-radius: 10px;
  border: 1px dashed var(--border2);
  background: var(--dark3);
  color: var(--text3);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all .2s ease;
  padding: 0;
  overflow: hidden;
}
.prod-image-thumb i { font-size: 1.1rem; }
.prod-image-thumb:hover {
  border-color: var(--violet2);
  color: var(--violet2);
  background: rgba(123,63,228,.08);
  transform: translateY(-1px);
}
.prod-image-thumb.has-image {
  border-style: solid;
  border-color: var(--border);
  cursor: zoom-in;
}
.prod-image-thumb.has-image:hover {
  border-color: var(--sky);
  box-shadow: 0 0 0 3px rgba(41,182,246,.12);
  transform: none;
}
.prod-image-thumb img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}

/* Preview grande dentro del modal Editar producto */
.prod-image-edit-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  background: var(--dark3);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.prod-image-preview {
  width: 96px; height: 96px;
  border-radius: 12px;
  border: 1px dashed var(--border2);
  background: var(--dark2);
  color: var(--text3);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}
.prod-image-preview i { font-size: 2rem; }
.prod-image-preview.has-image { border-style: solid; border-color: var(--border); }
.prod-image-preview img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}

/* ─────────────────────────────────────────────────────────────
   COLUMNA DESCRIPCIÓN — Botón inline editable
   ───────────────────────────────────────────────────────────── */
.cell-desc-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 1px dashed transparent;
  color: var(--text2);
  font-size: .8rem;
  padding: 4px 8px;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  max-width: 280px;
  transition: all .2s;
  font-family: inherit;
}
.cell-desc-btn span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}
.cell-desc-btn:hover {
  border-color: var(--border2);
  background: rgba(255,255,255,.03);
  color: var(--text1);
}
.cell-desc-btn .cell-desc-edit {
  font-size: .8rem;
  color: var(--sky);
  opacity: 0;
  transition: opacity .2s;
  flex-shrink: 0;
}
.cell-desc-btn:hover .cell-desc-edit { opacity: 1; }

/* ─────────────────────────────────────────────────────────────
   COLUMNA PROVEEDOR — Nombre + botón Contactar
   ───────────────────────────────────────────────────────────── */
.cell-supplier {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 140px;
}
.cell-supplier-name {
  font-size: .82rem;
  color: var(--text1);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}

.btn-contact-supplier {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(34,197,94,.1);
  color: #4ade80;
  border: 1px solid rgba(34,197,94,.25);
  border-radius: 8px;
  font-size: .72rem;
  font-weight: 700;
  padding: 5px 10px;
  cursor: pointer;
  transition: all .2s;
  text-decoration: none;
  font-family: inherit;
  width: fit-content;
  white-space: nowrap;
}
.btn-contact-supplier i { font-size: .9rem; }
.btn-contact-supplier:hover {
  background: rgba(34,197,94,.18);
  border-color: rgba(34,197,94,.4);
  color: #4ade80;
  transform: translateY(-1px);
}
.btn-contact-supplier--disabled {
  background: rgba(255,255,255,.03);
  color: var(--text3);
  border-color: var(--border);
}
.btn-contact-supplier--disabled:hover {
  background: rgba(123,63,228,.08);
  border-color: rgba(123,63,228,.25);
  color: var(--violet2);
}

/* ─────────────────────────────────────────────────────────────
   ACCIONES DE FILA — wrap controlado
   ───────────────────────────────────────────────────────────── */
.row-actions {
  display: inline-flex;
  flex-wrap: nowrap;
  gap: 4px;
  align-items: center;
}

/* Botones que sólo se muestran en mobile (cuando Descripción/Proveedor
   se ocultan con .col-hide-mobile, breakpoint 767px) */
.mobile-only-action { display: none; }

/* Estilos para los botones de acción específicos */
.btn-icon.btn-icon-wa { color: #4ade80; border-color: rgba(34,197,94,.25); background: rgba(34,197,94,.06); }
.btn-icon.btn-icon-wa:hover { background: rgba(34,197,94,.18); color: #4ade80; border-color: rgba(34,197,94,.45); }

/* ─────────────────────────────────────────────────────────────
   CLIENTES — Textarea de observaciones inline
   ───────────────────────────────────────────────────────────── */
.cli-obs-input {
  min-height: 38px;
  max-height: 90px;
  font-size: .82rem;
  padding: 8px 10px;
  resize: vertical;
  font-family: inherit;
  width: 100%;
  min-width: 220px;
}
.cli-obs-status {
  display: inline-block;
  margin-top: 4px;
  font-size: .7rem;
  color: var(--text3);
  transition: color .2s;
}
.cli-obs-status.editing { color: var(--text2); }
.cli-obs-status.saving  { color: var(--gold);  }
.cli-obs-status.saved   { color: #4ade80; }
.cli-obs-status.error   { color: #f87171; }

/* Indicador de guardado del mensaje de WhatsApp */
.wa-msg-status {
  font-size: .7rem;
  color: var(--text3);
  font-weight: 400;
  transition: color .2s;
}
.wa-msg-status.editing { color: var(--text2); }
.wa-msg-status.saved   { color: #4ade80; }

/* ─────────────────────────────────────────────────────────────
   TEXTAREA general dentro de modales (theme oscuro)
   ───────────────────────────────────────────────────────────── */
textarea.form-control-dark {
  font-family: inherit;
  resize: vertical;
  min-height: 44px;
  line-height: 1.45;
}

/* ─────────────────────────────────────────────────────────────
   PAGE TOOLBAR (Clientes / Proveedores)
   ───────────────────────────────────────────────────────────── */
#page-clientes .page-toolbar,
#page-proveedores .page-toolbar { gap: 8px; }


/* ═════════════════════════════════════════════════════════════
   ════════════════════  RESPONSIVE  ═══════════════════════════
   ═════════════════════════════════════════════════════════════ */

/* TABLET (≤991px) — Anchos compactos */
@media (max-width: 991px) {
  .cell-desc-btn         { max-width: 200px; }
  .cell-desc-btn span    { max-width: 150px; }
  .cell-supplier         { min-width: 120px; }
  .cell-supplier-name    { max-width: 130px; font-size: .78rem; }
  .btn-contact-supplier  { font-size: .68rem; padding: 4px 8px; }

  .prod-image-thumb      { width: 40px; height: 40px; border-radius: 9px; }
  .tbl-inventory .td-image,
  .tbl-inventory .th-image { width: 56px; }

  .cli-obs-input         { min-width: 180px; }
}

/* MOBILE (≤767px) — Mismo breakpoint que .col-hide-mobile */
@media (max-width: 767px) {

  /* Mostrar los íconos extra de acción que estaban ocultos */
  .mobile-only-action { display: inline-flex !important; }

  /* Acciones en fila — sin wrap, scroll horizontal de la tabla los acomoda */
  .row-actions {
    flex-wrap: nowrap;
    gap: 3px;
    justify-content: flex-end;
  }
  .row-actions .btn-icon {
    width: 30px !important; height: 30px !important;
    font-size: .82rem !important;
    border-radius: 7px !important;
  }

  /* Toolbar Clientes/Proveedores: stack vertical */
  #page-clientes .page-toolbar,
  #page-proveedores .page-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  #page-clientes .page-toolbar .search-box,
  #page-proveedores .page-toolbar .search-box {
    display: flex !important;
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }
  #page-clientes .page-toolbar > .d-flex,
  #page-proveedores .page-toolbar > .d-flex {
    width: 100%;
  }
  #page-clientes .page-toolbar .btn-grad,
  #page-proveedores .page-toolbar .btn-grad {
    flex: 1;
    justify-content: center;
  }

  /* Imagen — thumbnail más chica pero aún táctil */
  .prod-image-thumb     { width: 38px; height: 38px; border-radius: 8px; }
  .prod-image-thumb i   { font-size: .95rem; }
  .tbl-inventory .td-image,
  .tbl-inventory .th-image { width: 50px; }

  /* Modal Editar producto: preview de imagen apilada y centrada */
  .prod-image-edit-row  {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 12px;
  }
  .prod-image-edit-row > div:last-of-type {
    flex-direction: row !important;
    flex-wrap: wrap;
  }
  .prod-image-edit-row > div:last-of-type .btn-outline,
  .prod-image-edit-row > div:last-of-type .btn-danger {
    flex: 1;
    min-width: 140px;
    justify-content: center;
  }
  .prod-image-preview   {
    width: 100px; height: 100px;
    margin: 0 auto;
  }

  /* Clientes: textarea de observaciones más compacta */
  .cli-obs-input        {
    min-width: 160px;
    min-height: 36px;
    font-size: .8rem;
    padding: 7px 9px;
  }
  .cli-obs-status       { font-size: .65rem; }

  /* Proveedores: WhatsApp button más táctil */
  .btn-contact-supplier {
    padding: 7px 12px;
    font-size: .72rem;
    min-height: 32px;
  }
  .btn-contact-supplier i { font-size: 1rem; }

  /* Modal contactar proveedor: preview message altura optimizada */
  #modal-contact-supplier #contact-message-preview {
    min-height: 110px;
    font-size: .82rem;
  }

  /* Modales con muchos campos: padding reducido entre filas */
  #modal-add-cliente   .row.g-3,
  #modal-edit-cliente  .row.g-3,
  #modal-add-proveedor .row.g-3,
  #modal-edit-proveedor .row.g-3,
  #modal-contact-supplier .row.g-3 {
    --bs-gutter-y: 0.6rem;
  }

  /* Sidebar nav badges */
  #badge-clientes,
  #badge-proveedores  { font-size: .65rem; }
}

/* SMARTPHONE PEQUEÑO (≤430px) */
@media (max-width: 430px) {
  .prod-image-thumb     { width: 34px; height: 34px; border-radius: 7px; }
  .prod-image-thumb i   { font-size: .85rem; }
  .tbl-inventory .td-image,
  .tbl-inventory .th-image { width: 44px; }

  .row-actions .btn-icon {
    width: 28px !important; height: 28px !important;
    font-size: .75rem !important;
  }
  .row-actions { gap: 2px; }

  .cli-obs-input        {
    min-width: 80px;
    width: 100%;
    font-size: .76rem;
  }

  .prod-image-preview   { width: 88px; height: 88px; }

  /* Modal de contacto: filas más compactas */
  #modal-contact-supplier .modal-body .row.g-3 {
    --bs-gutter-y: 0.5rem;
  }
}

/* SMARTPHONE MUY PEQUEÑO (≤360px) */
@media (max-width: 360px) {
  .prod-image-thumb     { width: 32px; height: 32px; }
  .tbl-inventory .td-image,
  .tbl-inventory .th-image { width: 40px; }

  .row-actions .btn-icon {
    width: 26px !important; height: 26px !important;
    border-radius: 6px !important;
  }

  .cli-obs-input        { min-width: 0; width: 100%; font-size: .72rem; padding: 6px 8px; }

  /* Acciones (clientes y proveedores): asegurar 3 en una sola fila */
  #cli-tbody td:last-child,
  #prov-tbody td:last-child { white-space: nowrap; padding: 4px 4px !important; }
  #cli-tbody td:last-child .btn-icon,
  #prov-tbody td:last-child .btn-icon { width: 26px !important; height: 26px !important; font-size: .72rem; }
}