/* ==========================================================================
   Johnson Warranty – Frontend CSS
   ========================================================================== */

/* --------------------------------------------------------------------------
   Wrapper
   -------------------------------------------------------------------------- */
.johnson-warranty-wrap {
    font-family: inherit;
    margin:0;
}

#johnson-warranty-form{
    margin: 0;
}

/* --------------------------------------------------------------------------
   Botones
   -------------------------------------------------------------------------- */
.jw-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 22px;
    /* border-radius: 6px; */
    font-size: 14px;
    font-weight: 600;
    line-height: 1.4;
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    /*white-space: nowrap;*/
    min-width: 1px!important;
    min-height: 1px!important;
}

.jw-btn-primary {
    background: var(--fs-color-primary);
    color: #fff;
}
.jw-btn-extended {
    width: 100%;
    justify-content: center;
}
.jw-btn-primary:hover,
.jw-btn-primary:focus {
    background: var(--fs-color-secondary);
    text-decoration: none;
}

.jw-btn-outline {
    background: transparent;
    color: #374151;
    border: 1px solid #d1d5db;
}
.jw-btn-outline:hover,
.jw-btn-outline:focus {
    background: #f3f4f6;
    text-decoration: none;
}

/* --------------------------------------------------------------------------
   Cabecera de Mi Cuenta
   -------------------------------------------------------------------------- */
.jw-account-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 24px;
    flex-direction: row;
    flex-wrap: wrap;
}

.jw-account-header > button{
    margin: 0;
}

.jw-account-title {
    margin: 0;
    font-size: 1.4em;
    max-width: 75%;
}

/* --------------------------------------------------------------------------
   Sección de búsqueda de producto (input unificado + cámara + autocomplete)
   -------------------------------------------------------------------------- */
.jw-search-section {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    /* border-radius: 10px; */
    padding: 20px;
    margin-bottom: 24px;
}

.jw-search-intro {
    margin: 0 0 14px;
    font-size: 14px;
    color: #4b5563;
}

/* Fila: input + botón cámara */
.jw-search-row {
    display: flex;
    align-items: stretch;
    gap: 8px;
}

.jw-search-row .jw-autocomplete-wrap {
    flex: 1;
    min-width: 0;
}

/* Botón de cámara (icono cuadrado) */
.jw-btn-camera {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    flex-shrink: 0;
    background: transparent;
    border: 1px solid #d1d5db;
    /* border-radius: 6px; */
    color: #374151;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.jw-btn-camera:hover {
    background: #5fd8a517;
    border-color: var(--fs-color-secondary);
    color: var(--fs-color-secondary);
}

.jw-btn-camera-stop {
    border-color: #fca5a5;
    color: #dc2626;
}

.jw-btn-camera-stop:hover {
    background: #fef2f2;
    border-color: #dc2626;
    color: #dc2626;
}

/* Autocompletado */
.jw-autocomplete-wrap {
    position: relative;
}

.jw-autocomplete-wrap input[type="text"] {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #d1d5db;
    /* border-radius: 6px; */
    font-size: 14px;
    box-sizing: border-box;
    height: 44px;
    transition: border-color 0.15s, box-shadow 0.15s;
    background: #fff;
    color: var(--fs-color-primary);
}

.jw-autocomplete-wrap input[type="text"]:focus {
    outline: none;
    border-color: var(--fs-color-secondary);
    box-shadow: none
}

.jw-autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1000;
    background: #fff;
    border: 1px solid #d1d5db;
    border-top: none;
    /* border-radius: 0 0 8px 8px; */
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
    max-height: 280px;
    overflow-y: auto;
}

.jw-ac-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    cursor: pointer;
    transition: background 0.1s;
}

.jw-ac-item:hover,
.jw-ac-item.jw-ac-active {
    background: #eff6ff;
}

.jw-ac-thumb {
    width: 40px;
    height: 40px;
    object-fit: cover;
    /* border-radius: 4px; */
    border: 1px solid #e5e7eb;
    flex-shrink: 0;
}

.jw-ac-thumb-placeholder {
    width: 40px;
    height: 40px;
    /* border-radius: 4px; */
    background: #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    color: #9ca3af;
    flex-shrink: 0;
}

.jw-ac-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.jw-ac-info strong {
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.jw-ac-info small {
    font-size: 12px;
    color: #6b7280;
}

.jw-ac-loading,
.jw-ac-empty {
    padding: 14px 16px;
    font-size: 13px;
    color: #9ca3af;
    text-align: center;
}

/* Preview de producto seleccionado (dentro de .jw-search-section) */
.jw-product-preview {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 14px;
    padding: 10px 14px;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    /* border-radius: 6px; */
}

.jw-preview-thumb {
    width: 44px;
    height: 44px;
    object-fit: cover;
    /* border-radius: 4px; */
    flex-shrink: 0;
}

.jw-preview-name {
    font-size: 14px;
    font-weight: 600;
    color: #166534;
    flex: 1;
}

.jw-preview-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-width: 0;
}

.jw-preview-attrs {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.jw-attr-badge {
    display: inline-block;
    font-size: 11px;
    padding: 2px 7px;
    background: #dcfce7;
    color: #15803d;
    border: 1px solid #bbf7d0;
    border-radius: 20px;
    white-space: nowrap;
}

/* Atributos en el dropdown */
.jw-ac-attr {
    color: #1e40af;
    font-size: 11px;
    display: block;
}

.jw-btn-clear-product {
    background: none;
    border: none;
    font-size: 13px;
    color: #6b7280;
    cursor: pointer;
    margin: 0 0 0 5px;
    padding: 2px 6px;
    /* border-radius: 4px; */
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
    flex-shrink: 0;
}

.jw-btn-clear-product:hover {
    background: #fee2e2;
    color: #991b1b;
}

/* Hint de campo */
.jw-field-help {
    display: block;
    font-size: 0.7em;
    color: #6b7280;
    font-style: italic;
    margin: -7px 0 7px;
}

/* Botón de ayuda (?) junto al label */
.jw-help-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 15px;
    min-width: auto;
    height: 15px;
    min-height: auto;
    padding: 0;
    margin: 0 0 0 5px;
    background: none;
    border: 1.5px solid var(--fs-color-secondary);
    border-radius: 50%;
    color: var(--fs-color-secondary);
    cursor: pointer;
    vertical-align: middle;
    font-size: 0.9em;
    font-weight: 700;
    line-height: 1;
    transition: color 0.15s, border-color 0.15s;
    position: relative;
}

.jw-help-btn:hover {
    color: #fff;
    background-color: var(--fs-color-secondary);
}

/* Contenedor del label con tooltip */
label:has(.jw-help-btn) {
    position: relative;
}

/* Tooltip */
.jw-tooltip {
    position: absolute;
    left: 0;
    top: calc(100% + 6px);
    z-index: 1100;
    width: 260px;
    background: #1f2937;
    border-radius: 6px;
    padding: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.18);
}

.jw-tooltip::before {
    content: '';
    position: absolute;
    top: -6px;
    left: 16px;
    border-width: 0 6px 6px;
    border-style: solid;
    border-color: transparent transparent #1f2937;
}

.jw-tooltip-text {
    font-size: 12px;
    color: #e5e7eb;
    margin: 0 0 8px;
    line-height: 1.5;
}

.jw-tooltip-img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 4px;
}

.jw-tooltip[hidden] {
    display: none;
}

#jw-scanner-container {
    margin-top: 12px;
}

#jw-scanner {
    width: 100%;
    height: 220px;
    background: var(--fs-color-primary);
    /* border-radius: 8px; */
    overflow: hidden;
    position: relative;
    display: none; /* visible una vez que se activa */
}

#jw-scanner.active {
    display: block;
}

#jw-scanner video,
#jw-scanner canvas {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover;
}

/* Mira de escaneo */
#jw-scanner::after {
    content: '';
    position: absolute;
    inset: 20%;
    border: 2px solid rgba(255, 255, 255, 0.6);
    /* border-radius: 4px; */
    pointer-events: none;
}

.jw-scanner-status {
    font-size: 13px;
    color: #6b7280;
    margin: 8px 0 0;
    min-height: 1.4em;
}

/* --------------------------------------------------------------------------
   Formulario
   -------------------------------------------------------------------------- */
.jw-form-wrap {
    max-width: 560px;
}

.jw-field-group {
    margin-bottom: 18px;
}

.jw-field-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 14px;
    color: var(--fs-color-primary);
    display: flex;
    align-items: center;
}

.jw-required {
    color: #dc2626;
    margin-left: 2px;
}

.jw-optional {
    font-weight: 400;
    color: #9ca3af;
    font-size: 13px;
    margin-left: 4px;
}

.jw-field-group input[type="text"],
.jw-field-group input[type="date"] {
    width: 100%;
    padding: 10px 15px;
    border: 1px solid #d1d5db;
    font-size: 14px;
    box-sizing: border-box;
    transition: all ease-in-out 0.5s;
    background: #fff;
    color: var(--fs-color-primary);
    box-shadow: none!important;
    height: auto;
}

.jw-field-group input:focus {
    outline: none;
    border-color: var(--fs-color-secondary);
}

/* Input de archivo personalizado */
.jw-file-input-wrap {
    position: relative;
}

.jw-file-input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
}

.jw-file-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    border: 1px dashed #d1d5db;
    /* border-radius: 6px; */
    font-size: 14px;
    cursor: pointer;
    color: #374151;
    transition: border-color 0.15s, background 0.15s;
    background: #fafafa;
}

.jw-file-label:hover {
    border-color: var(--fs-color-secondary);
    background: #5fd8a517;
    color: var(--fs-color-secondary);
}

.jw-file-hint {
    display: block;
    margin-top: 6px;
    font-size: 12px;
    color: #9ca3af;
}

/* Mensajes del formulario */
.jw-form-message {
    padding: 12px 16px;
    /* border-radius: 6px; */
    margin-bottom: 16px;
    font-size: 14px;
}

.jw-form-message.jw-success {
    background: #5fd8a517;
    border: 1px solid var(--fs-color-secondary);
    color: var(--fs-color-secondary);
}

.jw-form-message.jw-error {
    background: #fef2f2;
    border: 1px solid #fca5a5;
    color: #991b1b;
}

/* --------------------------------------------------------------------------
   Tabla de garantías
   -------------------------------------------------------------------------- */
.jw-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.jw-warranty-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    min-width: 520px;
}

.jw-warranty-table th,
.jw-warranty-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
    vertical-align: middle;
}
.jw-warranty-table th:first-child,
.jw-warranty-table td:first-child{
    padding: 12px 16px!important;
}

.jw-warranty-table th {
    background: #f9fafb;
    font-weight: 600;
    color: #374151;
    white-space: nowrap;
}

.jw-warranty-table tbody tr:hover {
    background: #fafafa;
}

.jw-product-cell {
    display: flex;
    align-items: center;
    gap: 12px;
}

.jw-thumb {
    width: 52px;
    height: 52px;
    object-fit: cover;
    /* border-radius: 6px; */
    border: 1px solid #e5e7eb;
    flex-shrink: 0;
}

.jw-thumb-placeholder {
    width: 52px;
    height: 52px;
    /* border-radius: 6px; */
    background: #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 700;
    color: #9ca3af;
    flex-shrink: 0;
}

.jw-product-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.jw-product-info strong {
    font-size: 14px;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.jw-product-info small {
    color: #6b7280;
    font-size: 12px;
    display: block;
}

/* Badges de estado */
.jw-status {
    display: inline-block;
    padding: 3px 10px;
    /* border-radius: 20px; */
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.jw-status-active {
    background: var(--fs-color-secondary);
    color: #fff;
}

.jw-status-expired {
    background: #fee2e2;
    color: #991b1b;
}

/* --------------------------------------------------------------------------
   Estado vacío
   -------------------------------------------------------------------------- */
.jw-empty-state {
    text-align: center;
    padding: 48px 24px;
    color: #9ca3af;
}

.jw-empty-state svg {
    display: block;
    margin: 0 auto 16px;
    color: #d1d5db;
}

.jw-empty-state p {
    font-size: 15px;
    margin-bottom: 20px;
}

/* --------------------------------------------------------------------------
   Modal
   -------------------------------------------------------------------------- */
.jw-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    opacity: 0;
    transition: opacity 0.2s;
}

.jw-modal-overlay.jw-visible {
    opacity: 1;
}

.jw-modal {
    background: #fff;
    /* border-radius: 12px; */
    width: 100%;
    max-width: 600px;
    max-height: 92vh;
    overflow-y: auto;
    position: relative;
    transform: translateY(20px);
    transition: transform 0.2s;
}

.jw-modal-overlay.jw-visible .jw-modal {
    transform: translateY(0);
}

.jw-modal-header {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 30px;
    position: sticky;
    top: 0;
    left: 0;
    background: var(--fs-color-primary);
    z-index: 1;
    text-align: center;
}

.jw-modal-header h2 {
    margin: 0;
    font-size: 1.1em;
    color: #fff;
    text-transform: uppercase;
}

.jw-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    color: #6b7280;
    padding: 4px 8px;
    transition: color 0.15s, background 0.15s;
    position: absolute;
    top: 0;
    right: 0;
}

.jw-modal-close:hover {
    color: var(--fs-color-secondary);
}

.jw-modal-body {
    padding: 24px;
}

body.jw-modal-open {
    overflow: hidden;
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 600px) {
    .jw-account-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .jw-modal-body {
        padding: 16px;
    }
}
