/* =================================================================
   Admin Master — listados y forms de Tiendas + Transportadoras
   Estilo: data-dense dashboard, premium (Vercel/Linear feel)
   ================================================================= */

.am-page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}
.am-page-head h1 {
    /* Mismo estilo que .page-title del resto del sitio (Inter 700 / 24px) */
    font-family: 'Inter', sans-serif;
    font-weight: 700;
    font-size: 24px;
    line-height: 1.2;
    margin: 0 0 4px;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}
.am-page-head .sub {
    /* Mismo estilo que .page-subtitle */
    color: var(--text-tertiary);
    font-size: 13.5px;
    line-height: 1.5;
    margin: 0;
    max-width: 580px;
    letter-spacing: -0.005em;
}

.am-saved-toast {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--accent-soft);
    color: var(--accent);
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid var(--accent);
}

/* ─── Grid de tiendas ─── */
.tiendas-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}

.tienda-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: 14px;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    transition: border-color 180ms, transform 180ms, box-shadow 180ms;
    position: relative;
}
.tienda-card:hover {
    border-color: var(--border-default);
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
}
.tienda-card.is-paused {
    background: var(--bg-elevated-2);
    opacity: 0.85;
}

.tienda-card-head {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}
.tienda-card-flag {
    font-size: 28px;
    line-height: 1;
    width: 52px;
    height: 52px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: var(--bg-elevated-2);
    border: 1px solid var(--border-subtle);
    flex-shrink: 0;
}
.tienda-card-info {
    flex: 1;
    min-width: 0;
}
.tienda-card-name {
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 16px;
    color: var(--text-primary);
    line-height: 1.2;
    margin: 0 0 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.tienda-card-pais {
    font-size: 12px;
    color: var(--text-tertiary);
    letter-spacing: 0.02em;
}
.tienda-card-pais .ts-row-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--text-tertiary);
    display: inline-block;
    margin: 0 6px;
    vertical-align: middle;
}

.tienda-card-stats {
    display: flex;
    gap: 14px;
    padding: 12px 0;
    border-top: 1px dashed var(--border-subtle);
    border-bottom: 1px dashed var(--border-subtle);
}
.tienda-stat {
    flex: 1;
    min-width: 0;
}
.tienda-stat-label {
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-tertiary);
    font-weight: 600;
    margin-bottom: 3px;
}
.tienda-stat-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 6px;
}
.tienda-stat-value .ts-sync-indicator {
    width: 18px;
    height: 18px;
}
.tienda-stat-value .ts-sync-indicator svg { width: 13px; height: 13px; }

.tienda-card-actions {
    display: flex;
    gap: 8px;
    margin-top: auto;
}
.tienda-card-actions a,
.tienda-card-actions button {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 8px 12px;
    background: var(--bg-elevated-2);
    border: 1px solid var(--border-subtle);
    border-radius: 9px;
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    font-size: 12px;
    text-decoration: none;
    cursor: pointer;
    transition: all 150ms;
    min-height: 36px;
}
.tienda-card-actions a:hover,
.tienda-card-actions button:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
    color: var(--accent);
}
.tienda-card-actions a.is-primary {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent);
}
.tienda-card-actions a.is-primary:hover {
    background: var(--accent);
    color: white;
}

/* ─── Empty state ─── */
.am-empty {
    grid-column: 1 / -1;
    background: var(--bg-elevated);
    border: 1px dashed var(--border-default);
    border-radius: 14px;
    padding: 48px 24px;
    text-align: center;
}
.am-empty-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent);
    display: inline-grid;
    place-items: center;
    margin-bottom: 14px;
}
.am-empty h3 {
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 16px;
    margin: 0 0 6px;
    color: var(--text-primary);
}
.am-empty p {
    color: var(--text-secondary);
    font-size: 13px;
    margin: 0 0 18px;
    max-width: 360px;
    margin-left: auto;
    margin-right: auto;
}

/* ─── Form (tienda + transportadora) ─── */
.am-form {
    display: grid;
    grid-template-columns: 1fr 360px;
    gap: 24px;
    align-items: flex-start;
}
@media (max-width: 900px) {
    .am-form { grid-template-columns: 1fr; }
}

.am-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: 14px;
    padding: 20px;
    margin-bottom: 16px;
}
.am-card h3 {
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-tertiary);
    margin: 0 0 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.am-card h3 svg { width: 14px; height: 14px; color: var(--accent); }

.am-field {
    margin-bottom: 14px;
}
.am-field:last-child { margin-bottom: 0; }
.am-field label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 4px;
    letter-spacing: 0.01em;
}
.am-field label .req { color: var(--accent); }
.am-field input[type="text"],
.am-field input[type="email"],
.am-field input[type="password"],
.am-field input[type="url"],
.am-field select,
.am-field textarea {
    width: 100%;
    background: var(--bg-page);
    border: 1px solid var(--border-subtle);
    border-radius: 9px;
    padding: 10px 12px;
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: 13.5px;
    outline: none;
    transition: border-color 150ms, box-shadow 150ms, background 150ms;
}
.am-field input:focus,
.am-field select:focus,
.am-field textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
.am-field textarea { min-height: 76px; resize: vertical; }
.am-field .hint {
    font-size: 11px;
    color: var(--text-tertiary);
    margin-top: 4px;
    line-height: 1.4;
}
.am-field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 600px) { .am-field-row { grid-template-columns: 1fr; } }

/* Toggle pill */
.am-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    gap: 16px;
}
.am-toggle-row + .am-toggle-row { border-top: 1px solid var(--border-subtle); }
.am-toggle-info {
    flex: 1;
    min-width: 0;
}
.am-toggle-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}
.am-toggle-desc {
    font-size: 11.5px;
    color: var(--text-tertiary);
    margin-top: 2px;
    line-height: 1.4;
}
.am-toggle {
    --bg-off: var(--bg-subtle);
    --bg-on: var(--accent);
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
    flex-shrink: 0;
    cursor: pointer;
}
.am-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}
.am-toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--bg-off);
    border-radius: 999px;
    transition: background 180ms;
}
.am-toggle-slider::before {
    content: "";
    position: absolute;
    top: 3px; left: 3px;
    width: 16px; height: 16px;
    background: white;
    border-radius: 50%;
    transition: transform 180ms cubic-bezier(0.2, 0.8, 0.2, 1);
    box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}
.am-toggle input:checked + .am-toggle-slider { background: var(--bg-on); }
.am-toggle input:checked + .am-toggle-slider::before { transform: translateX(18px); }
.am-toggle input:focus-visible + .am-toggle-slider {
    box-shadow: 0 0 0 3px var(--accent-soft);
}

/* Transportadoras picker */
.tp-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 320px;
    overflow-y: auto;
    padding-right: 6px;
}
.tp-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: var(--bg-elevated-2);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    cursor: pointer;
    transition: all 150ms;
    position: relative;
}
.tp-row:hover {
    background: var(--bg-hover);
    border-color: var(--border-default);
}
.tp-row.is-checked {
    background: var(--accent-soft);
    border-color: var(--accent);
}
.tp-checkbox {
    width: 18px;
    height: 18px;
    border-radius: 5px;
    border: 1.5px solid var(--border-strong);
    background: var(--bg-page);
    display: grid;
    place-items: center;
    flex-shrink: 0;
    transition: all 150ms;
}
.tp-row.is-checked .tp-checkbox {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}
.tp-color-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 0 2px var(--bg-elevated);
}
.tp-row.is-checked .tp-color-dot {
    box-shadow: 0 0 0 2px var(--accent-soft);
}
.tp-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.tp-name {
    font-weight: 500;
    font-size: 13px;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.tp-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--text-tertiary);
}
.tp-tipo-badge {
    font-size: 9.5px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    background: var(--bg-page);
    color: var(--text-secondary);
}
.tp-tipo-badge.tipo-api {
    background: rgba(34, 197, 94, 0.15);
    color: #22C55E;
}
.tp-tipo-badge.tipo-link_externo {
    background: rgba(99, 102, 241, 0.15);
    color: #818CF8;
}
.tp-default-radio {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 10.5px;
    color: var(--text-tertiary);
    cursor: pointer;
    user-select: none;
}
.tp-default-radio input { margin: 0; cursor: pointer; }
.tp-row.is-checked .tp-default-radio { color: var(--text-secondary); }

.tp-empty {
    padding: 20px;
    text-align: center;
    color: var(--text-tertiary);
    font-size: 12px;
    background: var(--bg-elevated-2);
    border: 1px dashed var(--border-subtle);
    border-radius: 10px;
}

/* Footer del form */
.am-form-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 20px;
    padding-top: 18px;
    border-top: 1px solid var(--border-subtle);
}
.am-form-footer .left { font-size: 12px; color: var(--text-tertiary); }

/* ─── Transportadoras listado ─── */
.transp-group {
    margin-bottom: 12px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: 14px;
    overflow: hidden;
    transition: border-color 150ms;
}
.transp-group:hover {
    border-color: var(--border-default);
}
.transp-group.is-open {
    border-color: var(--border-default);
}

/* Head clickeable: reset de button + estilo de header */
.transp-group-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 13px 18px;
    background: var(--bg-elevated);
    border: none;
    border-bottom: 1px solid transparent;
    width: 100%;
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 13.5px;
    color: var(--text-primary);
    text-align: left;
    cursor: pointer;
    transition: background-color 150ms, border-color 150ms;
}
.transp-group-head:hover {
    background: var(--bg-elevated-2);
}
.transp-group-head:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}
.transp-group.is-open .transp-group-head {
    background: var(--bg-elevated-2);
    border-bottom-color: var(--border-subtle);
}
.transp-group-head .flag { font-size: 18px; line-height: 1; }
.transp-group-head .g-name { flex: 1; min-width: 0; }
.transp-group-head .count {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 9px;
    border-radius: 999px;
    background: var(--bg-elevated-2);
    color: var(--text-secondary);
    min-width: 22px;
    text-align: center;
}
.transp-group.is-open .transp-group-head .count {
    background: var(--accent-soft);
    color: var(--accent);
}
.transp-group-head .g-chevron {
    color: var(--text-tertiary);
    transition: transform 200ms cubic-bezier(0.2, 0.8, 0.2, 1), color 150ms;
    flex-shrink: 0;
}
.transp-group.is-open .transp-group-head .g-chevron {
    transform: rotate(180deg);
    color: var(--accent);
}

.transp-group-body {
    background: var(--bg-elevated);
}

.transp-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 18px;
    border-bottom: 1px solid var(--border-subtle);
    transition: background 150ms;
}
.transp-row:last-child { border-bottom: none; }
.transp-row:hover { background: var(--bg-hover); }

.transp-row .dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 0 2px var(--bg-elevated);
}
.transp-row .code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11.5px;
    color: var(--text-tertiary);
    width: 130px;
    flex-shrink: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.transp-row .name {
    flex: 1;
    min-width: 0;
    font-weight: 500;
    color: var(--text-primary);
    font-size: 13.5px;
}
.transp-row .name .url-preview {
    display: block;
    font-size: 11px;
    color: var(--text-tertiary);
    font-family: 'JetBrains Mono', monospace;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-top: 2px;
}
.transp-row .tipo {
    width: 86px;
    flex-shrink: 0;
}
.transp-row .uso {
    width: 80px;
    flex-shrink: 0;
    font-size: 12px;
    color: var(--text-tertiary);
    text-align: right;
}
.transp-row .uso strong {
    color: var(--text-primary);
    font-weight: 600;
}
.transp-row .actions {
    display: flex;
    gap: 6px;
}
.transp-row .actions a {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: inline-grid;
    place-items: center;
    color: var(--text-tertiary);
    border: 1px solid var(--border-subtle);
    text-decoration: none;
    transition: all 150ms;
}
.transp-row .actions a:hover {
    background: var(--bg-hover);
    color: var(--accent);
    border-color: var(--accent);
}

/* Inactive row */
.transp-row.is-inactive { opacity: 0.55; }
.transp-row.is-inactive .name::after {
    content: " · INACTIVA";
    font-size: 10px;
    color: var(--text-tertiary);
    letter-spacing: 0.06em;
}

/* ─── Color picker input ─── */
.color-picker {
    display: flex;
    align-items: center;
    gap: 10px;
}
.color-picker input[type="color"] {
    width: 44px;
    height: 36px;
    padding: 0;
    border: 1px solid var(--border-subtle);
    border-radius: 9px;
    cursor: pointer;
    background: transparent;
}
.color-picker input[type="text"] {
    flex: 1;
    font-family: 'JetBrains Mono', monospace;
}

/* ─── Tipo radio cards ─── */
.tipo-radio-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}
@media (max-width: 500px) { .tipo-radio-grid { grid-template-columns: 1fr; } }
.tipo-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 14px 8px;
    background: var(--bg-elevated-2);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    cursor: pointer;
    transition: all 150ms;
    text-align: center;
}
.tipo-card:hover { background: var(--bg-hover); border-color: var(--border-default); }
.tipo-card input { display: none; }
.tipo-card svg { width: 20px; height: 20px; color: var(--text-tertiary); transition: color 150ms; }
.tipo-card .tipo-card-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
}
.tipo-card .tipo-card-desc {
    font-size: 10.5px;
    color: var(--text-tertiary);
    line-height: 1.3;
}
.tipo-card.is-checked {
    background: var(--accent-soft);
    border-color: var(--accent);
}
.tipo-card.is-checked svg,
.tipo-card.is-checked .tipo-card-title { color: var(--accent); }
