/* --- VARIABLES & RESET (Banking Theme) --- */
:root {
  --tdvm-primary: #004481;       /* Azul corporativo banca */
  --tdvm-primary-hover: #003366;
  --tdvm-accent: #2dcccd;        /* Turquesa para acciones */
  --tdvm-bg: #f0f4f8;            /* Fondo general más claro */
  --tdvm-card-bg: #ffffff;
  --tdvm-border: #dbe0e6;
  --tdvm-text-main: #121212;
  --tdvm-text-muted: #5e6d82;
  --tdvm-radius: 12px;           /* Bordes más redondeados */
  --tdvm-focus-ring: rgba(0, 68, 129, 0.15);
}

/* --- ENVOLTORIO PRINCIPAL (Centrado y Fondo) --- */
.tdvm-wrap {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  color: var(--tdvm-text-main);
  line-height: 1.5;
  background: linear-gradient(to bottom, #f8fafc, #eef2f7);
  padding: 40px 20px;
  min-height: 90vh; 
  display: flex;
  justify-content: center;
  align-items: center;
}
.tdvm-wrap * { box-sizing: border-box; }

/* --- TARJETA PRINCIPAL (Más llamativa) --- */
.tdvm-card {
  background: var(--tdvm-card-bg);
  border-radius: 16px; 
  box-shadow: 0 20px 60px -15px rgba(0,0,0,0.15), 0 10px 20px -5px rgba(0,0,0,0.05);
  border: 1px solid rgba(255,255,255,0.5); 
  padding: 50px;
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
  position: relative;
}

/* --- HEADER ELEGANTE (Texto Izq - Logo Der) --- */
.tdvm-header { 
    display: flex; 
    align-items: center; 
    justify-content: space-between; /* Separa texto y logo */
    gap: 40px; 
    margin-bottom: 45px; 
    text-align: right; /* Alinea el texto a la derecha hacia el logo */
}

.tdvm-logo {
    max-width: 180px; /* Logo grande y elegante */
    height: auto;
    display: block;
    flex-shrink: 0; 
}

.tdvm-header-text {
    flex-grow: 1;
}

.tdvm-title {
  font-size: 2.4rem;
  font-weight: 800;
  color: var(--tdvm-primary);
  margin: 0 0 10px 0;
  letter-spacing: -0.5px;
  line-height: 1.1;
}
.tdvm-subtitle { color: var(--tdvm-text-muted); font-size: 1.15rem; margin: 0; }
.tdvm-badge {
    display: inline-block;
    background: #e3f2fd;
    padding: 6px 12px;
    border-radius: 6px;
    color: var(--tdvm-primary);
    font-size: 0.9rem;
    margin-top: 10px !important;
}

/* --- SECCIONES --- */
.tdvm-section-title {
  font-size: 1.2rem;
  color: var(--tdvm-primary);
  font-weight: 700;
  margin: 45px 0 25px 0;
  padding-bottom: 12px;
  border-bottom: 2px solid #eff2f7;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* --- GRID SYSTEM --- */
.tdvm-grid-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 30px; 
  margin-bottom: 20px;
}

/* --- INPUTS & SELECTS --- */
.tdvm-field { display: flex; flex-direction: column; }
.tdvm-field span {
    display: flex;
    align-items: center;
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 10px;
    color: var(--tdvm-text-main);
}
.tdvm-req-star { color: #e74c3c !important; margin-left: 4px; }

.tdvm-input {
  width: 100%;
  height: 50px !important;
  padding: 0 18px;
  border: 2px solid var(--tdvm-border);
  border-radius: 10px !important;
  background-color: #fff;
  font-size: 1.05rem;
  color: var(--tdvm-text-main);
  transition: all 0.2s ease;
  -webkit-appearance: none; -moz-appearance: none; appearance: none;
}
textarea#tdvm-userMessage { height: 120px !important; padding-top: 15px; }

select.tdvm-input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23004481' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 18px center;
  background-size: 14px;
  padding-right: 45px;
  cursor: pointer;
}

.tdvm-input:focus {
  outline: none;
  border-color: var(--tdvm-primary);
  box-shadow: 0 0 0 4px var(--tdvm-focus-ring);
}
.tdvm-input::placeholder { color: #a0aec0; }

/* --- TARJETAS DINÁMICAS --- */
#tdvm-dynamic-account-wrapper, #tdvm-dynamic-receipts-wrapper {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 25px;
}

.tdvm-account-card {
  background: #ffffff;
  border: 1px solid var(--tdvm-border);
  border-radius: 12px;
  padding: 30px;
  position: relative;
  transition: all 0.3s ease;
  box-shadow: 0 4px 6px rgba(0,0,0,0.04);
}
.tdvm-account-card:hover {
  border-color: var(--tdvm-accent);
  box-shadow: 0 10px 25px rgba(0,0,0,0.08);
  transform: translateY(-2px);
}

.tdvm-receipt-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
    align-items: start;
}

.tdvm-account-title {
  font-size: 0.9rem;
  text-transform: uppercase;
  font-weight: 800;
  color: var(--tdvm-primary);
  margin-top: 0;
  margin-bottom: 20px;
  letter-spacing: 1px;
}
.tdvm-receipt-grid span {
    height: 20px;
}
div#tdvm-modal-overlay {
    max-width: 100%;
}
.tdvm-remove {
	padding: 2px;
    position: absolute; top: 10px; right: 10px;
    background: #fff0f0; border: none;
    color: #e74c3c; width: 30px; height: 30px;
    border-radius: 50%; font-size: 20px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: 0.2s; line-height: 1;
}
.tdvm-remove:hover { background: #e74c3c; color: white; }

.tdvm-add-card {
  font-size: 32px;
  display: flex; align-items: center; justify-content: center;
  min-height: 120px; background: #f8fafc;
  border: 2px dashed #cbd5e0; border-radius: 12px;
  color: var(--tdvm-primary); cursor: pointer; transition: 0.3s;
}
.tdvm-add-card:hover {
  background: #edf2f7; border-color: var(--tdvm-primary); transform: scale(1.02);
}

/* --- BOTÓN PRINCIPAL --- */
.tdvm-btn-primary {
  width: 100%; max-width: 400px;
  margin: 60px auto 0; display: block;
  padding: 18px 36px;
  background: linear-gradient(135deg, var(--tdvm-primary) 0%, #003366 100%);
  color: white; border: none; border-radius: 50px;
  font-size: 1.2rem; font-weight: 700; cursor: pointer;
  box-shadow: 0 10px 20px -5px rgba(0, 68, 129, 0.4);
  transition: all 0.3s; text-transform: uppercase; letter-spacing: 1px;
}
.tdvm-btn-primary:hover {
  transform: translateY(-3px); box-shadow: 0 15px 30px -5px rgba(0, 68, 129, 0.5);
}

/* --- MODAL --- */
.tdvm-modal-overlay {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0, 20, 40, 0.85); backdrop-filter: blur(8px);
  z-index: 99999; display: flex; align-items: center; justify-content: center;
  opacity: 0; visibility: hidden; transition: all 0.3s ease; padding: 20px;
}
.tdvm-modal-overlay.tdvm-active { opacity: 1; visibility: visible; }

.tdvm-modal-content {
  background: #fff; width: 100%; max-width: 550px;
  border-radius: 20px; padding: 0;
  transform: scale(0.8) !important; transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 30px 60px -15px rgba(0, 0, 0, 0.6); overflow: hidden;
}
.tdvm-modal-overlay.tdvm-active .tdvm-modal-content { transform: scale(1); }

.tdvm-modal-header {
	border-radius: 19px 19px 0px 0px;
  background: linear-gradient(135deg, var(--tdvm-primary) 0%, #002a52 100%);
  padding: 19px 30px; text-align: center; color: white; position: relative;
}
.tdvm-result-big { font-size: 3.0rem; font-weight: 800; color: #fff; margin: 13px 0; text-shadow: 0 4px 8px rgba(0,0,0,0.2); }
.tdvm-result-label { text-transform: uppercase; font-size: 0.9rem; letter-spacing: 2px; opacity: 0.8; font-weight: 600;}

.tdvm-modal-body { padding: 29px 25px; }
.tdvm-close-modal {
    position: absolute; top: 15px; right: 15px;
    background: rgba(255, 255, 255, 0.15); border: none; color: white;
    width: 36px; height: 36px; border-radius: 50%; font-size: 22px;
    cursor: pointer; line-height: 1; display: flex; align-items: center; justify-content: center;
    transition: 0.2s; padding: 0; margin: 0;
}
.tdvm-close-modal:hover { background: rgba(255,255,255,0.3); }

.tdvm-btn-secondary {
  width: 100%; background: var(--tdvm-accent); color: #003366;
  border: none; padding: 18px; border-radius: 12px;
  font-weight: 800; font-size: 1.1rem; cursor: pointer;
  margin-top: 20px; text-transform: uppercase; transition: 0.3s;
}
.tdvm-btn-secondary:hover { background: #23b5b6; box-shadow: 0 5px 15px rgba(45, 204, 205, 0.4); }

/* --- RESULTADOS EN MODAL --- */
strong#tdvm-current-gain, strong#tdvm-max-gain { font-size: 1.3rem; }
.tdvm-modal-body span { font-size: 1rem; }

/* UTILIDADES */
.tdvm-hidden { display: none !important; }
.tdvm-disabled-group { opacity: 0.5; pointer-events: none; filter: grayscale(1); }
.tdvm-input-error { border-color: #e74c3c !important; background: #fff5f5 !important; }
.tdvm-error { color: #e74c3c; text-align: center; margin-top: 20px; font-weight: 700; background: #fff5f5; padding: 10px; border-radius: 8px; }
.tdvm-confirmation { background: #d1fae5; color: #065f46; padding: 15px; border-radius: 8px; margin-top:20px; text-align: center; font-weight: bold; border: 1px solid #a7f3d0; }
@media (min-width: 1024px) {
	.tdvm-logo {
    right: 5%;
    position: absolute;
    max-width: 160px;
    height: auto;
    display: block;
    flex-shrink: 0;
}
	.tdvm-header-text {
    text-align: center;
    
}
  /* CSS SOLO ESCRITORIO */
}
/* --- RESPONSIVE (Móvil) --- */
@media (max-width: 768px) {
	.tdvm-logo {
		max-width: 126px !important;
	}
	.tdvm-result-big {
		font-size: 2.5rem !important;
	}
	
	
  .tdvm-wrap { padding: 20px 10px; align-items: flex-start; } 
  .tdvm-card { padding: 25px; border-radius: 12px; }
  
  /* AQUÍ LA CLAVE: Invertimos a Columna Inversa */
  /* Esto hace que el Logo (que es el 2º en HTML) suba arriba */
  .tdvm-header { 
      flex-direction: column-reverse; 
      text-align: center; 
      gap: 20px; 
  }
  
  .tdvm-title { font-size: 1.8rem; }
  .tdvm-logo { margin: 0 auto; } /* Centra el logo */
  
  .tdvm-grid-row { grid-template-columns: 1fr !important; gap: 20px; } 
  .tdvm-receipt-grid { grid-template-columns: 1fr; }
  .tdvm-btn-primary { width: 100%; max-width: none; }
  
  .ast-container, .ast-container-fluid { padding-left: 0 !important; padding-right: 0 !important; }
}