/* css/components.css - Tarjetas, Formularios, Modales, Iconos SVG y Vale Digital Multi-Empresa */

/* Estilos de Iconos SVG Vectoriales */
.svg-icon {
  display: inline-block;
  vertical-align: middle;
  stroke-width: 2;
  stroke: currentColor;
  fill: none;
  transition: color 0.2s ease;
}

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

@media (min-width: 768px) {
  .card {
    padding: 24px;
  }
}

/* Botones */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  font-family: inherit;
  user-select: none;
}

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

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

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

.btn-outline {
  background-color: transparent;
  border-color: var(--border-color);
  color: var(--text-main);
}

.btn-outline:hover {
  background-color: var(--bg-body);
  border-color: var(--secondary);
}

.btn-success {
  background-color: #198754;
  color: #ffffff;
}
.btn-success:hover { background-color: #157347; }

.btn-danger {
  background-color: #dc3545;
  color: #ffffff;
}
.btn-danger:hover { background-color: #bb2d3b; }

.btn-warning {
  background-color: #ffc107;
  color: #000000;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
}

/* Formularios */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--secondary);
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  font-size: 0.95rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  outline: none;
  transition: border-color 0.2s ease;
  font-family: inherit;
  background-color: #ffffff;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(20, 122, 69, 0.15);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media (min-width: 576px) {
  .form-row-2 { grid-template-columns: 1fr 1fr; }
  .form-row-3 { grid-template-columns: 1fr 1fr 1fr; }
  .form-row-4 { grid-template-columns: repeat(4, 1fr); }
}

/* Reglas Mobile-First: Prevención de Auto-Zoom en iOS y Áreas Táctiles Cómodas */
@media (max-width: 768px) {
  .form-control,
  input.form-control,
  select.form-control,
  textarea.form-control {
    font-size: 16px !important; /* Estándar iOS Safari: previene zoom molesto al enfocar */
    min-height: 46px;
  }
  .btn {
    min-height: 44px;
  }
}

/* Control Segmentado Móvil (Formulario vs Vista Previa Digital) */
.mobile-voucher-view-switcher {
  display: flex;
  background-color: #e2e8f0;
  padding: 4px;
  border-radius: 8px;
  margin-bottom: 16px;
  gap: 4px;
}

@media (min-width: 992px) {
  .mobile-voucher-view-switcher {
    display: none; /* En escritorio se muestran en dos columnas lado a lado */
  }
}

.btn-mobile-subtab {
  flex: 1;
  padding: 10px 12px;
  font-size: 0.88rem;
  font-weight: 700;
  border: none;
  background: transparent;
  color: var(--secondary);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-mobile-subtab.active {
  background-color: #ffffff;
  color: var(--primary);
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

/* Layout Responsivo para Emisión de Vales */
.new-voucher-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 20px;
  width: 100%;
  min-width: 0;
}

#new-voucher-form-col,
#new-voucher-preview-col {
  min-width: 0;
  max-width: 100%;
  width: 100%;
  box-sizing: border-box;
}

@media (min-width: 992px) {
  .new-voucher-layout {
    grid-template-columns: minmax(0, 1.12fr) minmax(0, 0.88fr);
    gap: 24px;
  }
  #new-voucher-form-col, #new-voucher-preview-col {
    display: block !important;
  }
}

@media (max-width: 991.98px) {
  #new-voucher-preview-col {
    display: none;
  }
  #new-voucher-preview-col.mobile-active {
    display: block !important;
  }
  #new-voucher-form-col.mobile-hidden {
    display: none !important;
  }
}

/* Desglose de Gastos Responsivo Touch-Friendly */
.activity-input-responsive-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  align-items: end;
  margin-bottom: 12px;
}

.activity-field-concept {
  grid-column: span 2;
}

.activity-field-btn {
  grid-column: span 2;
}

.activity-field-btn button {
  width: 100%;
  min-height: 44px;
  font-weight: 700;
}

.mobile-only-label {
  display: block;
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--secondary);
  margin-bottom: 4px;
}

@media (min-width: 768px) {
  .activity-input-responsive-grid {
    grid-template-columns: 140px 1fr 120px auto;
  }
  .activity-field-concept {
    grid-column: auto;
  }
  .activity-field-btn {
    grid-column: auto;
  }
  .activity-field-btn button {
    width: auto;
  }
  .mobile-only-label {
    display: none;
  }
}

/* Botones de Acción Responsivos en Emisión */
.form-actions-responsive {
  display: flex;
  flex-direction: column-reverse;
  gap: 10px;
  margin-top: 20px;
}

@media (min-width: 576px) {
  .form-actions-responsive {
    flex-direction: row;
    justify-content: flex-end;
    gap: 12px;
  }
}

.btn-lg-touch {
  min-height: 48px;
  font-size: 1rem;
  font-weight: 700;
  width: 100%;
}

@media (min-width: 576px) {
  .btn-lg-touch {
    width: auto;
    font-size: 0.92rem;
  }
}

.voucher-digital-container {
  background-color: #ffffff;
  border: 2px solid var(--primary);
  border-radius: 4px;
  overflow: hidden;
  width: 760px;
  min-width: 760px;
  max-width: 760px;
  margin: 0 auto;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.12);
  font-family: Arial, Helvetica, sans-serif;
  color: #1a1a1a;
  transition: border-color 0.3s ease;
  box-sizing: border-box;
}

/* Contenedor desplazable con estética de papel sobre mesa */
#live-voucher-preview,
.voucher-scroll-viewport {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 12px;
  background: #f1f5f9;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  box-sizing: border-box;
  overscroll-behavior-x: contain;
}

#detail-modal-content {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 12px;
  background: #f1f5f9;
  box-sizing: border-box;
  overscroll-behavior-x: contain;
}

#live-voucher-preview::-webkit-scrollbar,
#detail-modal-content::-webkit-scrollbar,
.voucher-scroll-viewport::-webkit-scrollbar {
  height: 8px;
}

#live-voucher-preview::-webkit-scrollbar-track,
#detail-modal-content::-webkit-scrollbar-track,
.voucher-scroll-viewport::-webkit-scrollbar-track {
  background: #e2e8f0;
  border-radius: 4px;
}

#live-voucher-preview::-webkit-scrollbar-thumb,
#detail-modal-content::-webkit-scrollbar-thumb,
.voucher-scroll-viewport::-webkit-scrollbar-thumb {
  background: #94a3b8;
  border-radius: 4px;
}

.mobile-voucher-preview-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 0.78rem;
  color: #1e40af;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  padding: 8px 12px;
  border-radius: 6px;
  margin-bottom: 12px;
  font-weight: 600;
  text-align: center;
}

@media (min-width: 992px) {
  .mobile-voucher-preview-hint {
    display: none;
  }
}

.voucher-digital-header {
  background-color: var(--primary);
  color: #ffffff;
  padding: 2px 10px 2px 4px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background-color 0.3s ease;
}

.voucher-header-logo {
  display: flex;
  align-items: center;
  max-width: 280px;
}

.voucher-header-logo img {
  height: 48px;
  max-height: 48px;
  max-width: 280px;
  width: auto;
  object-fit: contain;
  object-position: left center;
  display: block;
}

.voucher-header-title {
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  text-align: center;
  flex: 1;
}

.voucher-header-version {
  font-size: 0.75rem;
  font-weight: 700;
  opacity: 0.9;
}

.voucher-grid-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.voucher-grid-table td,
.voucher-grid-table th {
  border: 1px solid var(--primary);
  padding: 6px 10px;
  vertical-align: top;
  font-size: 0.82rem;
  transition: border-color 0.3s ease;
}

.voucher-label {
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--primary);
  text-transform: uppercase;
  display: block;
  margin-bottom: 2px;
}

.voucher-date-box {
  display: flex;
  gap: 12px;
  text-align: center;
}

.voucher-date-item {
  flex: 1;
}

.voucher-amount-words {
  font-weight: 700;
  text-transform: uppercase;
  color: #000;
  min-height: 24px;
  word-break: break-word;
}

.voucher-amount-numeric-box {
  background-color: var(--primary-light);
  font-size: 1.1rem;
  font-weight: 900;
  color: var(--primary);
  text-align: right;
  padding: 4px 8px;
  border-radius: 4px;
}

.voucher-concept-box {
  min-height: 70px;
  font-size: 0.88rem;
  line-height: 1.6;
}

.voucher-footer-box {
  min-height: 48px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.signature-stamp {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #198754;
  font-weight: 700;
  font-size: 0.75rem;
  border: 1px dashed #198754;
  padding: 4px 8px;
  border-radius: 4px;
  width: fit-content;
  margin-top: 4px;
}

/* Modales */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  opacity: 0;
  padding: 16px;
  box-sizing: border-box;
}

.modal-backdrop.active {
  display: flex !important;
  opacity: 1;
}

.modal-content {
  background-color: #ffffff;
  border-radius: var(--radius);
  width: 100%;
  max-width: min(900px, calc(100vw - 32px));
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  overflow: hidden;
  box-sizing: border-box;
}

.modal-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--primary);
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-muted);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  background-color: #f8f9fa;
}

/* Lista de Vales */
.voucher-card-item {
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 16px;
  background-color: #ffffff;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: border-color 0.2s ease;
}

.voucher-card-item:hover {
  border-color: var(--primary);
}

.voucher-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.voucher-code {
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--primary);
}

.voucher-date {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.voucher-card-body {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  font-size: 0.9rem;
}

@media (min-width: 576px) {
  .voucher-card-body {
    grid-template-columns: 2fr 1fr;
  }
}

.voucher-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  border-top: 1px solid #f0f0f0;
  padding-top: 10px;
}

/* Pantalla de Login */
.login-container {
  min-height: 100vh;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
  width: 100%;
  max-width: 500px;
  padding: 32px 28px;
}

.login-header {
  text-align: center;
  margin-bottom: 24px;
}

.login-header .login-icon {
  width: 56px;
  height: 56px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}

.login-header h2 {
  font-size: 1.35rem;
  font-weight: 800;
  color: #0f172a;
  margin-bottom: 4px;
}

.login-header p {
  color: var(--text-muted);
  font-size: 0.88rem;
}

.demo-account-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
  margin-bottom: 6px;
}

.demo-account-chip:hover {
  background: #f1f5f9;
  border-color: var(--primary);
  transform: translateY(-1px);
}

/* ========================================================= */
/* SEARCHABLE BOTTOM SHEET PICKER (MOBILE-FIRST)             */
/* ========================================================= */
.search-picker-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  background-color: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  cursor: pointer;
  margin-bottom: 8px;
  user-select: none;
  transition: all 0.2s ease;
  box-sizing: border-box;
}

.search-picker-trigger:hover,
.search-picker-trigger:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(20, 122, 69, 0.12);
}

.search-picker-trigger-content {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1 1 auto;
  min-width: 0;
}

.search-picker-icon {
  font-size: 1.05rem;
  flex-shrink: 0;
}

.search-picker-text {
  font-size: 0.92rem;
  color: var(--text-main);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1 1 auto;
  min-width: 0;
}

.search-picker-chevron {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-left: 8px;
  flex-shrink: 0;
}

.bottom-sheet-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.55);
  display: none;
  z-index: 3000;
  opacity: 0;
  transition: opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-sizing: border-box;
}

.bottom-sheet-backdrop.active {
  display: flex !important;
  opacity: 1;
}

.bottom-sheet-container {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #ffffff;
  border-top-left-radius: 20px;
  border-top-right-radius: 20px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.25);
  transform: translateY(100%);
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  padding: 8px 16px calc(16px + env(safe-area-inset-bottom, 0px)) 16px;
  box-sizing: border-box;
}

.bottom-sheet-backdrop.active .bottom-sheet-container {
  transform: translateY(0);
}

/* En Desktop se muestra como un modal centrado moderno */
@media (min-width: 768px) {
  .bottom-sheet-backdrop {
    align-items: center;
    justify-content: center;
    padding: 24px;
  }
  .bottom-sheet-container {
    position: relative;
    bottom: auto;
    left: auto;
    right: auto;
    width: 100%;
    max-width: 520px;
    border-radius: 16px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    transform: scale(0.95);
    padding: 16px 20px 20px 20px;
  }
  .bottom-sheet-backdrop.active .bottom-sheet-container {
    transform: scale(1);
  }
  .bottom-sheet-drag-handle {
    display: none;
  }
}

.bottom-sheet-drag-handle {
  width: 44px;
  height: 5px;
  background-color: #cbd5e1;
  border-radius: 3px;
  margin: 4px auto 10px auto;
}

.bottom-sheet-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-color);
}

.bottom-sheet-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary);
  margin: 0;
}

.bottom-sheet-search-wrap {
  position: relative;
  margin: 12px 0 8px 0;
}

.bottom-sheet-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #94a3b8;
  font-size: 0.95rem;
  pointer-events: none;
}

.bottom-sheet-search-input {
  padding-left: 38px !important;
  padding-right: 36px !important;
  min-height: 48px !important;
  font-size: 16px !important;
  border-radius: 10px;
  background-color: #f8fafc;
}

.bottom-sheet-clear-btn {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  font-size: 1.1rem;
  color: #94a3b8;
  cursor: pointer;
  padding: 4px 8px;
}

.bottom-sheet-info-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 2px 8px 2px;
}

.bottom-sheet-list {
  max-height: 52vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.bottom-sheet-group-title {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--secondary);
  background: #f1f5f9;
  padding: 6px 12px;
  border-radius: 6px;
  margin: 6px 0 2px 0;
}

.bottom-sheet-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid #f1f5f9;
  background-color: #ffffff;
  cursor: pointer;
  min-height: 48px;
  transition: all 0.15s ease;
  user-select: none;
  box-sizing: border-box;
}

.bottom-sheet-item:hover,
.bottom-sheet-item:active {
  background-color: var(--primary-light);
  border-color: var(--primary);
}

.bottom-sheet-item.selected {
  background-color: var(--primary-light);
  border-color: var(--primary);
  font-weight: 700;
}

.bottom-sheet-item-text {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
}

.bottom-sheet-item-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bottom-sheet-item-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bottom-sheet-item .badge {
  flex-shrink: 0;
  margin-left: 8px;
  white-space: nowrap;
  font-size: 0.72rem;
  padding: 3px 8px;
}

.bottom-sheet-item-check {
  color: var(--primary);
  font-size: 1.1rem;
  font-weight: bold;
  flex-shrink: 0;
}

.mobile-table-scroll-hint {
  display: none;
  font-size: 0.74rem;
  color: var(--text-muted);
  text-align: right;
  margin-top: 4px;
}

@media (max-width: 768px) {
  .mobile-table-scroll-hint {
    display: block !important;
  }
}
