/**
 * Direcciones de bodega en el panel de cliente.
 *
 * Replica ExpressAddressesScreen de la app móvil: la tarjeta del casillero,
 * las instrucciones y las tarjetas de almacén con su distintivo de tipo.
 * Los valores salen del propio COLORS de esa pantalla.
 */

:root {
    --ad-primary: #14B1FE;
    --ad-secondary: #52C645;
    --ad-accent: #3B82F6;
    --ad-bg: #F8FAFC;
    --ad-white: #FFFFFF;
    --ad-text: #1F2937;
    --ad-text-secondary: #6B7280;
    --ad-border: #E5E7EB;
    --ad-air: #3B82F6;
    --ad-maritime: #10B981;
    --ad-note: #FEF3C7;
}

.ad-wrap {
    max-width: 900px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* ── Tarjeta del casillero ────────────────────────────────────────────── */
.ad-pobox {
    background: var(--ad-white);
    border: 1px solid var(--ad-border);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
}

.ad-pobox-head {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.ad-pobox-icon {
    font-size: 2rem;
    color: var(--ad-secondary);
    line-height: 1;
}

.ad-pobox-label {
    display: block;
    font-size: 0.8rem;
    color: var(--ad-text-secondary);
}

.ad-pobox-number {
    display: block;
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--ad-text);
    line-height: 1.2;
}

/* ── Instrucciones ────────────────────────────────────────────────────── */
.ad-steps {
    background: var(--ad-note);
    border-radius: 12px;
    padding: 16px;
}

.ad-steps h3 {
    margin: 0 0 10px;
    font-size: 0.95rem;
    font-weight: 700;
    color: #78350F;
}

.ad-step {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    font-size: 0.87rem;
    line-height: 1.5;
    color: #78350F;
    margin-bottom: 6px;
}
.ad-step:last-child { margin-bottom: 0; }
.ad-step i { color: var(--ad-accent); font-size: 1rem; flex-shrink: 0; margin-top: 1px; }

/* ── Encabezado de sección ────────────────────────────────────────────── */
.ad-section h2 {
    margin: 12px 0 2px;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--ad-text);
}
.ad-section p {
    margin: 0 0 4px;
    font-size: 0.87rem;
    color: var(--ad-text-secondary);
}

/* ── Tarjeta de almacén ───────────────────────────────────────────────── */
.ad-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(330px, 1fr));
    gap: 16px;
}

.ad-card {
    background: var(--ad-white);
    border: 1px solid var(--ad-border);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.ad-badges {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
}

.ad-type {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 12px;
    color: var(--ad-white);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.4px;
}
.ad-type.is-air { background: var(--ad-air); }
.ad-type.is-sea { background: var(--ad-maritime); }

.ad-price {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.78rem;
    font-weight: 700;
}
.ad-price.is-air { background: #EFF6FF; color: var(--ad-air); }
.ad-price.is-sea { background: #ECFDF5; color: var(--ad-maritime); }

/* La línea que el cliente debe copiar tal cual en su compra. */
.ad-name {
    font-size: 1rem;
    font-weight: 700;
    color: var(--ad-text);
    line-height: 1.4;
    margin-bottom: 12px;
    word-break: break-word;
}

.ad-lines {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 14px;
    flex: 1;
}

.ad-line {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    font-size: 0.88rem;
    line-height: 1.45;
    color: var(--ad-text-secondary);
    min-width: 0;
}
.ad-line i {
    color: var(--ad-text-secondary);
    font-size: 1rem;
    flex-shrink: 0;
    margin-top: 1px;
}
.ad-line span { word-break: break-word; }

/* ── Botones ──────────────────────────────────────────────────────────── */
.ad-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    border: 0;
    border-radius: 8px;
    padding: 10px 16px;
    font: inherit;
    font-size: 0.86rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: opacity 0.18s ease, background 0.18s ease;
}
.ad-btn:hover { opacity: 0.88; }

.ad-btn-primary {
    background: var(--ad-accent);
    color: var(--ad-white);
    width: 100%;
}

.ad-btn-ghost {
    background: #EFF6FF;
    color: var(--ad-accent);
}

.ad-btn-soft {
    background: #F3F4F6;
    color: var(--ad-text-secondary);
    padding: 8px 12px;
    font-size: 0.8rem;
}

.ad-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* Confirmación al copiar, en lugar del alert del navegador. */
.ad-toast {
    position: fixed;
    left: 50%;
    bottom: 28px;
    transform: translateX(-50%) translateY(12px);
    background: var(--ad-text);
    color: var(--ad-white);
    padding: 11px 18px;
    border-radius: 10px;
    font-size: 0.88rem;
    font-weight: 500;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 2000;
}
.ad-toast.is-on {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

@media (prefers-reduced-motion: reduce) {
    .ad-toast, .ad-btn { transition: none; }
}

/* ── Estados vacíos ───────────────────────────────────────────────────── */
.ad-empty {
    background: var(--ad-white);
    border: 1px solid var(--ad-border);
    border-radius: 12px;
    padding: 40px 20px;
    text-align: center;
    color: var(--ad-text-secondary);
}
.ad-empty i { font-size: 3rem; color: var(--ad-border); display: block; margin-bottom: 10px; }

@media (max-width: 575.98px) {
    .ad-cards { grid-template-columns: 1fr; }
    .ad-pobox { flex-direction: column; align-items: stretch; }
    .ad-pobox .ad-btn { width: 100%; }
}

/* ── Formulario de almacén (panel de administración) ──────────────────── */
.ad-form-wrap {
    max-width: 720px;
    margin: 0 auto;
}

.ad-alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 13px 15px;
    border-radius: 10px;
    font-size: 0.88rem;
    line-height: 1.55;
    margin-bottom: 16px;
}
.ad-alert i { font-size: 1.15rem; flex-shrink: 0; }
.ad-alert ul { margin: 4px 0 0; padding-left: 18px; }
.ad-alert.is-error { background: #FEE2E2; color: #991B1B; }
.ad-alert.is-ok { background: #D1FAE5; color: #065F46; }

.ad-form {
    background: var(--ad-white);
    border: 1px solid var(--ad-border);
    border-radius: 12px;
    padding: 22px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.ad-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

.ad-field { display: flex; flex-direction: column; min-width: 0; }

.ad-field > label {
    font-size: 0.74rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--ad-text-secondary);
    margin-bottom: 7px;
}

.ad-field input,
.ad-field select {
    width: 100%;
    background: #F9FAFB;
    border: 1px solid var(--ad-border);
    border-radius: 8px;
    padding: 11px 13px;
    font: inherit;
    font-size: 0.94rem;
    color: var(--ad-text);
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}
.ad-field input:focus,
.ad-field select:focus {
    outline: none;
    border-color: var(--ad-primary);
    box-shadow: 0 0 0 3px rgba(20, 177, 254, 0.15);
}
.ad-field input::placeholder { color: #9CA3AF; }
.ad-field select:disabled { background: #F3F4F6; color: #9CA3AF; cursor: not-allowed; }
.ad-field .is-invalid { border-color: #EF4444; background: #FEF6F6; }

.ad-field-error {
    margin-top: 6px;
    font-size: 0.8rem;
    color: #DC2626;
}

/* Tipo de envío: dos opciones grandes en vez de un desplegable de dos. */
.ad-choice { display: flex; gap: 12px; flex-wrap: wrap; }

.ad-opt { flex: 1; min-width: 140px; cursor: pointer; }
.ad-opt input { position: absolute; opacity: 0; pointer-events: none; }
.ad-opt span {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 13px;
    border: 2px solid var(--ad-border);
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.92rem;
    color: var(--ad-text-secondary);
    transition: border-color 0.18s ease, background 0.18s ease, color 0.18s ease;
}
.ad-opt span i { font-size: 1.2rem; }

.ad-opt.is-air input:checked + span {
    border-color: var(--ad-air);
    background: #EFF6FF;
    color: var(--ad-air);
}
.ad-opt.is-sea input:checked + span {
    border-color: var(--ad-maritime);
    background: #ECFDF5;
    color: var(--ad-maritime);
}
.ad-opt input:focus-visible + span { box-shadow: 0 0 0 3px rgba(20, 177, 254, 0.2); }

.ad-form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding-top: 6px;
    flex-wrap: wrap;
}
.ad-form-actions .ad-btn-primary { width: auto; }
.ad-form-actions .ad-btn-soft { text-decoration: none; padding: 10px 16px; font-size: 0.86rem; }

@media (prefers-reduced-motion: reduce) {
    .ad-field input, .ad-field select, .ad-opt span { transition: none; }
}

/* ── Listado de almacenes (panel de administración) ───────────────────── */
.ad-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.ad-btn-auto { width: auto; text-decoration: none; }

.ad-btn-danger {
    background: #FEE2E2;
    color: #B91C1C;
    padding: 10px 13px;
}
.ad-btn-danger:hover { background: #FECACA; opacity: 1; }

.ad-line-warn { color: #B45309; }
.ad-line-warn i { color: #D97706; }

/* En el modal el formulario no lleva tarjeta propia: ya está dentro de una. */
.ad-form-modal {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.ad-actions form { margin: 0; }

/* La bandera va dentro de la píldora de la tarifa, alineada con el texto. */
.ad-price {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.ad-flag {
    width: 20px;
    height: 14px;
    border-radius: 2px;
    border: 1px solid rgba(0, 0, 0, 0.12);
    object-fit: cover;
    display: block;
}

/* El código del país sustituye a la bandera dentro del PDF: ahí se muestra
   y la bandera se oculta. En pantalla es al revés. */
.ad-flag-code {
    display: none;
    font-weight: 700;
    letter-spacing: 0.5px;
}
.ad-pdf-mode .ad-flag { display: none; }
.ad-pdf-mode .ad-flag-code { display: inline; }
