/* PIM CRUD - Estilos compartidos (Weelko) */
@import url('/web/fonts/segoe/style.css?v=20250714.1');

:root {
    --pim-brand: #2b2b2b;
    --pim-brand-dark: #1a1a1a;
    --pim-brand-light: rgba(43, 43, 43, 0.12);
    --pim-bg: #f7f8f9;
    --pim-surface: #ffffff;
    --pim-text: #333333;
    --pim-text-muted: #6c757d;
    --pim-border: #e9ecef;
    --pim-shadow: 0 0 5px 0 rgba(0, 0, 0, 0.12);
    --pim-shadow-hover: 0 4px 14px 0 rgba(43, 43, 43, 0.18);
    --pim-radius: 8px;
    --pim-radius-lg: 12px;
    --pim-font: 'Segoe UI Regular', 'Segoe UI', sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: inherit; }

button, input, select, textarea {
    font-family: var(--pim-font);
    font-size: inherit;
}

body.pim-body,
body {
    font-family: var(--pim-font);
    font-weight: normal;
    font-size: 14px;
    background: var(--pim-bg);
    color: var(--pim-text);
    line-height: 1.5;
    min-height: 100vh;
}

.pim-container { max-width: 1200px; margin: 0 auto; padding: 20px 16px 32px; }

/* Zona de subida Excel (importadores PIM) */
.pim-import-upload-zone {
    display: block;
    width: 100%;
    box-sizing: border-box;
    border: 2px dashed #d1d5db;
    border-radius: 10px;
    padding: 28px 20px;
    text-align: center;
    background: #fafafa;
    cursor: pointer;
    position: relative;
    overflow: visible;
}
.pim-import-upload-zone:hover,
.pim-import-upload-zone:focus-visible {
    border-color: var(--pim-brand);
    outline: none;
}
.pim-import-upload-zone input[type="file"] {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
.pim-import-upload-inner {
    pointer-events: none;
}
.pim-import-sel-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 10px;
    font-size: 13px;
}
.pim-import-sel-bar .btn-pim {
    font-size: 12px;
    padding: 4px 10px;
}
.pim-import-sel-count {
    margin-left: auto;
    color: #64748b;
    font-size: 13px;
}

/* Cabecera */
.pim-header {
    background: var(--pim-surface);
    border-radius: var(--pim-radius-lg);
    padding: 22px 24px;
    margin-bottom: 20px;
    box-shadow: var(--pim-shadow);
    border-left: 4px solid var(--pim-brand);
}
.pim-header h1 { font-size: 1.35rem; color: #1a1a2e; font-weight: 600; }
.pim-header p  { color: var(--pim-text-muted); font-size: 14px; margin-top: 6px; max-width: 52rem; }
.pim-back-link {
    color: #6c757d; text-decoration: none; font-size: 14px;
    display: flex; align-items: center; gap: 6px;
    white-space: nowrap;
}
.pim-back-link:hover { color: var(--pim-brand); }

/* Barra superior (Apps › PIM CRUD) */
.pim-app-bar {
    --pim-app-bar-logo-slot: 142px;
    position: relative;
    background: var(--pim-brand);
    color: #fff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}
.pim-app-bar-row {
    max-width: 1200px;
    margin: 0 auto;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}
.pim-app-bar-brand {
    position: absolute;
    left: 12px;
    top: 0;
    bottom: 0;
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    text-decoration: none;
    line-height: 0;
    padding: 2px 0;
    margin-left: 0;
}
.pim-app-bar-brand:hover { opacity: 0.88; }
.pim-app-bar-brand-logo {
    height: 26px;
    width: auto;
    max-width: 130px;
    object-fit: contain;
    object-position: left center;
    display: block;
    mix-blend-mode: lighten;
}
.pim-app-bar-main {
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0;
    gap: 12px;
    flex-wrap: wrap;
}
.pim-app-bar-main::before {
    content: '';
    flex-shrink: 0;
    width: var(--pim-app-bar-logo-slot);
    height: 26px;
    pointer-events: none;
}
.pim-app-bar-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    margin-left: auto;
}
.pim-app-bar-logo-link {
    display: inline-flex;
    align-items: center;
    line-height: 0;
    text-decoration: none;
    border-radius: 4px;
    transition: opacity 0.15s;
}
.pim-app-bar-logo-link:hover {
    opacity: 0.88;
}
.pim-app-bar-logo-link:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.65);
    outline-offset: 2px;
}
.pim-app-bar-logo {
    height: 22px;
    width: auto;
    max-width: 110px;
    object-fit: contain;
    display: block;
    mix-blend-mode: lighten;
}
.pim-app-bar-inner {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 14px;
    flex: 1;
    min-width: 0;
}
.pim-app-bar-link {
    color: rgba(255, 255, 255, 0.92);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 6px;
    border: 1px solid transparent;
    background: transparent;
    font-weight: 500;
    transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.pim-app-bar-link:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.22);
    text-decoration: none;
}
.pim-app-bar-link:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.65);
    outline-offset: 2px;
}
.pim-app-bar-icon { font-size: 14px; opacity: 0.95; }
.pim-app-bar-sep {
    color: rgba(255, 255, 255, 0.45);
    user-select: none;
    font-size: 14px;
    font-weight: 400;
    padding: 0 2px;
}
.pim-app-bar-current {
    color: #fff;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.2);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: default;
}
.pim-app-bar-back {
    flex-shrink: 0;
    color: rgba(255, 255, 255, 0.92);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    padding: 7px 12px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.22);
    background: transparent;
    white-space: nowrap;
    transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.pim-app-bar-back:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.35);
    text-decoration: none;
}
.pim-app-bar-back:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.65);
    outline-offset: 2px;
}

.pim-app-bar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.pim-app-bar-dropdown {
    position: relative;
}

.pim-app-bar-menu-toggle {
    color: rgba(255, 255, 255, 0.92);
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 6px;
    padding: 6px 28px 6px 12px;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.3;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: color 0.15s, background 0.15s, border-color 0.15s;
    position: relative;
}

.pim-app-bar-menu-toggle::after {
    content: '';
    position: absolute;
    right: 10px;
    top: 50%;
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid rgba(255, 255, 255, 0.85);
    transform: translateY(-35%);
}

.pim-app-bar-menu-toggle:hover,
.pim-app-bar-menu-toggle:focus-visible,
.pim-app-bar-dropdown:focus-within .pim-app-bar-menu-toggle {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.35);
}

.pim-app-bar-menu-toggle:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.65);
    outline-offset: 2px;
}

.pim-app-bar-logged-as-other {
    color: #ff8a8a !important;
    font-weight: 700;
}

.pim-app-bar-dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    min-width: 12rem;
    margin: 0;
    padding: 6px 0;
    list-style: none;
    background: #fff;
    color: var(--pim-text);
    border: 1px solid var(--pim-border);
    border-radius: 8px;
    box-shadow: var(--pim-shadow-hover);
    font-size: 13px;
    z-index: 20;
}

.pim-app-bar-dropdown-menu::before {
    content: '';
    position: absolute;
    right: 0;
    bottom: 100%;
    left: 0;
    height: 4px;
}

.pim-app-bar-dropdown:hover .pim-app-bar-dropdown-menu,
.pim-app-bar-dropdown:focus-within .pim-app-bar-dropdown-menu {
    display: block;
}

.pim-app-bar-dropdown-menu a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    color: var(--pim-text);
    text-decoration: none;
    white-space: nowrap;
}

.pim-app-bar-dropdown-menu a:hover {
    background: rgba(43, 43, 43, 0.06);
    color: var(--pim-text);
    text-decoration: none;
}

.pim-app-bar-dropdown-menu a i {
    width: 1rem;
    text-align: center;
    opacity: 0.85;
}

.pim-app-bar-dropdown-divider {
    height: 1px;
    margin: 6px 0;
    background: var(--pim-border);
}

/* Barra a ancho completo cuando está dentro de un contenedor acotado (p. ej. Bootstrap) */
.pim-app-bar-bleed {
    width: 100vw;
    max-width: 100vw;
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);
}

/* Subnavegación (solo en subpáginas) */
.pim-subnav {
    max-width: 1200px;
    margin: 0 auto;
    padding: 10px 16px 0;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    font-size: 13px;
    color: var(--pim-text-muted);
}
.pim-subnav a {
    color: var(--pim-brand);
    text-decoration: none;
}
.pim-subnav a:hover { text-decoration: underline; }
.pim-subnav-sep { color: #adb5bd; }
.pim-subnav-current { color: var(--pim-text); font-weight: 600; }

/* Cabecera de página */
.pim-toolbar {
    display: flex; align-items: center; gap: 12px;
    margin-bottom: 16px; flex-wrap: wrap;
}
.pim-search {
    flex: 1; min-width: 200px;
    padding: 9px 14px;
    border: 1px solid #ddd; border-radius: 6px;
    font-size: 14px;
}
.pim-search:focus { outline: none; border-color: var(--pim-brand); }

/* Botones */
.btn-pim {
    padding: 9px 18px; border: none; border-radius: 6px;
    font-size: 14px; cursor: pointer; font-weight: 500;
    display: inline-flex; align-items: center; gap: 6px;
    text-decoration: none; white-space: nowrap;
    transition: background 0.15s, opacity 0.15s;
}
.btn-pim:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-pim-primary  { background: var(--pim-brand); color: #fff; }
.btn-pim-primary:hover  { background: var(--pim-brand-dark); }
.btn-pim-success  { background: #28a745; color: #fff; }
.btn-pim-success:hover  { background: #218838; }
.btn-pim-danger   { background: #fff; color: #dc3545; border: 1px solid #dc3545; }
.btn-pim-danger:hover   { background: #dc3545; color: #fff; }
.btn-pim-secondary { background: #6c757d; color: #fff; }
.btn-pim-secondary:hover { background: #5a6268; }
.btn-pim-icon { padding: 6px 10px; font-size: 15px; }

/* Tabla */
.pim-card {
    background: #fff; border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08); overflow: hidden;
}
.pim-table { width: 100%; border-collapse: collapse; }
.pim-table thead { background: #f8f9fa; }
.pim-table th {
    padding: 13px 16px; text-align: left;
    font-size: 13px; font-weight: 600; color: #495057;
    border-bottom: 2px solid #e9ecef;
    cursor: pointer; user-select: none; white-space: nowrap;
}
.pim-table th:hover { background: #eef0f3; }
.pim-table th .sort-icon { margin-left: 4px; opacity: 0.4; font-style: normal; }
.pim-table th.sorted-asc .sort-icon::after  { content: ' ▲'; opacity: 1; }
.pim-table th.sorted-desc .sort-icon::after { content: ' ▼'; opacity: 1; }
.pim-table td {
    padding: 12px 16px; border-bottom: 1px solid #f0f0f0;
    font-size: 14px; vertical-align: middle;
}
.pim-table tbody tr:hover { background: #fafbfc; }
.pim-table tbody tr:last-child td { border-bottom: none; }
.pim-table .col-id    { width: 60px; color: #aaa; font-size: 13px; }
.pim-table .col-order { width: 70px; text-align: center; }
.pim-table .col-unit  { width: 110px; }
.pim-table .col-actions { width: 110px; text-align: right; white-space: nowrap; }

.pim-tag {
    display: inline-block; padding: 2px 8px; border-radius: 4px;
    font-size: 12px; background: #e9ecef; color: #495057;
}

/* Estado vacío */
.pim-empty {
    padding: 60px 20px; text-align: center; color: #aaa;
}
.pim-empty p { font-size: 16px; margin-bottom: 6px; }

/* Mensaje de alerta */
.pim-msg {
    padding: 12px 16px; border-radius: 6px;
    font-size: 14px; margin-bottom: 16px; display: none;
}
.pim-msg.success { background: #d4edda; color: #155724; display: block; }
.pim-msg.error   { background: #f8d7da; color: #721c24; display: block; }

/* Modal */
.pim-modal-backdrop {
    display: none; position: fixed;
    inset: 0; background: rgba(0,0,0,0.45);
    z-index: 1000; align-items: center; justify-content: center;
}
.pim-modal-backdrop.open { display: flex; }
.pim-modal {
    background: #fff; border-radius: 12px;
    width: 100%; max-width: 500px; margin: 20px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
    animation: pimModalIn 0.18s ease;
}
@keyframes pimModalIn {
    from { transform: translateY(-16px); opacity: 0; }
    to   { transform: translateY(0);     opacity: 1; }
}
.pim-modal-header {
    padding: 20px 24px 0;
    display: flex; align-items: center; justify-content: space-between;
}
.pim-modal-header h2 { font-size: 17px; color: #1a1a2e; }
.pim-modal-close {
    background: none; border: none; font-size: 20px;
    cursor: pointer; color: #aaa; line-height: 1;
}
.pim-modal-close:hover { color: #333; }
.pim-modal-body { padding: 20px 24px; }
.pim-modal-footer {
    padding: 0 24px 20px;
    display: flex; justify-content: flex-end; gap: 10px;
}

/* Formulario modal */
.pim-form-row { margin-bottom: 14px; }
.pim-form-row label {
    display: block; font-size: 13px; font-weight: 600;
    color: #555; margin-bottom: 5px;
}
.pim-form-row input {
    width: 100%; padding: 9px 12px;
    border: 1px solid #ddd; border-radius: 6px; font-size: 14px;
}
.pim-form-row input:focus { outline: none; border-color: var(--pim-brand); }
.pim-form-row select {
    width: 100%; padding: 9px 12px;
    border: 1px solid #ddd; border-radius: 6px; font-size: 14px;
    background: #fff; color: #333; appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23999' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 12px center;
    padding-right: 36px; cursor: pointer;
}
.pim-form-row select:focus { outline: none; border-color: var(--pim-brand); }
.pim-form-row .pim-hint { font-size: 12px; color: #999; margin-top: 3px; }

/* Valores existentes en modal feature */
.feat-existing-values {
    margin-top: 6px; padding: 10px 12px;
    background: #f8f9fa; border-radius: 6px;
    border: 1px solid #e9ecef;
    max-height: 140px; overflow-y: auto;
}
.feat-existing-values .fev-loading { color: #aaa; font-size: 13px; font-style: italic; }
.feat-existing-values .fev-empty   { color: #bbb; font-size: 13px; }
.feat-existing-values .fev-list    { display: flex; flex-wrap: wrap; gap: 5px; }
.fev-pill {
    display: inline-block; padding: 2px 9px; border-radius: 12px;
    font-size: 12px; background: #e9ecef; color: #555;
    white-space: nowrap; max-width: 220px;
    overflow: hidden; text-overflow: ellipsis;
}
.fev-count { font-size: 12px; color: #aaa; margin-top: 6px; }
.pim-form-row-inline { display: flex; gap: 12px; }
.pim-form-row-inline .pim-form-row { flex: 1; }

/* Modal de confirmación */
.pim-confirm-msg { font-size: 15px; color: #333; margin-bottom: 6px; }
.pim-confirm-sub { font-size: 13px; color: #888; }

/* Columna miniatura en tabla */
.pim-table .col-img { width: 56px; text-align: center; }
.feat-thumb {
    width: 40px; height: 40px; object-fit: contain;
    border-radius: 4px; border: 1px solid #eee;
    display: block; margin: 0 auto;
}

/* Área de subida de imagen en modal */
.pim-img-upload-area {
    border: 2px dashed #d0d5dd; border-radius: 8px;
    padding: 16px; text-align: center; cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    min-height: 80px;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 4px;
}
.pim-img-upload-area:hover { border-color: var(--pim-brand); background: var(--pim-brand-light); }
.pim-img-upload-area p { font-size: 13px; color: #777; margin: 0; }

/* Home — secciones y tarjetas */
.pim-home-section {
    margin-bottom: 28px;
}
.pim-home-section:last-child {
    margin-bottom: 0;
}
.pim-home-section-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--pim-brand);
    margin: 0 0 14px 2px;
}
.pim-home-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
    gap: 16px;
}
.pim-home-card {
    background: var(--pim-surface);
    border-radius: var(--pim-radius-lg);
    padding: 20px;
    box-shadow: var(--pim-shadow);
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 100%;
    transition: box-shadow 0.18s ease, border-color 0.18s ease;
    border: 1px solid var(--pim-border);
}
.pim-home-card:hover {
    box-shadow: 0 6px 18px rgba(43, 43, 43, 0.1);
    border-color: rgba(43, 43, 43, 0.28);
    text-decoration: none;
    color: inherit;
}
.pim-home-card:focus-visible {
    outline: 2px solid var(--pim-brand);
    outline-offset: 2px;
}
.pim-home-card .card-icon-wrap {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: var(--pim-brand-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    line-height: 1;
    flex-shrink: 0;
}
.pim-home-card .card-icon-wrap--external {
    background: rgba(52, 58, 64, 0.08);
}
.pim-home-card .card-title {
    font-size: 16px;
    font-weight: 600;
    color: #1a1a2e;
    line-height: 1.3;
}
.pim-home-card .card-desc {
    font-size: 13px;
    color: var(--pim-text-muted);
    flex: 1;
    line-height: 1.45;
}
.pim-home-card .card-action {
    margin-top: auto;
    padding-top: 4px;
    font-size: 13px;
    color: var(--pim-brand);
    font-weight: 600;
    transition: color 0.15s ease;
}
.pim-home-card:hover .card-action {
    color: var(--pim-brand-dark);
}
.pim-home-card--external:hover {
    border-color: rgba(43, 43, 43, 0.28);
}

@media (max-width: 576px) {
    .pim-container { padding: 12px 12px 24px; }
    .pim-header { padding: 16px 18px; }
    .pim-header h1 { font-size: 1.2rem; }
    .pim-home-grid { grid-template-columns: 1fr; }
    .pim-app-bar-row { flex-direction: column; align-items: stretch; }
    .pim-app-bar-main { flex-direction: column; align-items: stretch; }
    .pim-app-bar-main::before { display: none; }
    .pim-app-bar-brand {
        position: static;
    }
    .pim-app-bar-right { margin-left: 0; justify-content: space-between; width: 100%; flex-wrap: wrap; }
    .pim-app-bar-actions { width: 100%; justify-content: flex-end; flex-wrap: wrap; }
    .pim-app-bar-back { text-align: center; }
    .pim-app-bar-brand-logo { height: 24px; }
}

@media print {
    .pim-app-bar,
    .pim-subnav {
        display: none !important;
    }
}
