/**
 * ProtectSofa Gifts - CSS Frontend
 * 
 * Estilos responsive para el selector de cojines de regalo
 * 
 * @author      Cursor AI
 * @copyright   2026 ProtectSofa
 * @version     2.0.0
 * Creado: 2026-01-22
 */

/* ==========================================================================
   Variables
   ========================================================================== */
:root {
    --psgifts-primary: #db953b;
    --psgifts-primary-dark: #c47f2a;
    --psgifts-dark: #333;
    --psgifts-light: #f5f5f5;
    --psgifts-border: #ddd;
    --psgifts-success: #4caf50;
    --psgifts-white: #fff;
    --psgifts-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    --psgifts-radius: 8px;
    --psgifts-transition: all 0.3s ease;
}

/* ==========================================================================
   Contenedor principal
   ========================================================================== */
.psgifts-selector {
    font-family: inherit;
    box-sizing: border-box;
}

.psgifts-selector *,
.psgifts-selector *::before,
.psgifts-selector *::after {
    box-sizing: inherit;
}

/* ==========================================================================
   Barra de información (solo en carrito)
   ========================================================================== */
.psgifts-info-bar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 10px;
    padding: 15px;
    background: var(--psgifts-light);
    border-radius: var(--psgifts-radius);
    margin: 20px 0;
}

.psgifts-info-text {
    flex: 1;
    color: var(--psgifts-dark);
    font-size: 14px;
}

.psgifts-info-text strong {
    color: var(--psgifts-primary);
    font-size: 18px;
}

.psgifts-select-btn {
    background: var(--psgifts-dark) !important;
    color: var(--psgifts-white) !important;
    border: none !important;
    padding: 10px 20px !important;
    border-radius: 5px !important;
    font-weight: 600 !important;
    transition: var(--psgifts-transition) !important;
    cursor: pointer !important;
}

.psgifts-select-btn:hover {
    background: var(--psgifts-primary) !important;
    transform: translateY(-2px);
}

/* ==========================================================================
   Contenedor del selector (modal)
   ========================================================================== */
.psgifts-selector-container {
    position: relative;
}

.psgifts-context-cart .psgifts-selector-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 9999;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 20px;
    overflow-y: auto;
}

.psgifts-selector-container.psgifts-hidden {
    display: none !important;
}

/* Overlay */
.psgifts-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1;
    cursor: pointer;
}

.psgifts-context-modal .psgifts-overlay,
.psgifts-context-checkout .psgifts-overlay {
    display: none;
}

/* Panel principal */
.psgifts-panel {
    position: relative;
    z-index: 2;
    background: var(--psgifts-white);
    border-radius: var(--psgifts-radius);
    box-shadow: var(--psgifts-shadow);
    max-width: 1000px;
    width: 100%;
    margin: 50px auto;
    padding: 25px;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
}

.psgifts-context-modal .psgifts-panel,
.psgifts-context-checkout .psgifts-panel {
    margin: 20px 0;
    box-shadow: none;
    border: 1px solid var(--psgifts-border);
}

/* ==========================================================================
   Cabecera
   ========================================================================== */
.psgifts-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--psgifts-light);
}

.psgifts-title-container {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    gap: 15px;
}

.psgifts-icon {
    max-height: 50px;
    width: auto;
}

.psgifts-title {
    background: var(--psgifts-primary);
    color: var(--psgifts-white);
    padding: 8px 20px;
    border-radius: 5px;
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    text-align: center;
    white-space: nowrap;
}

.psgifts-close {
    background: none;
    border: none;
    font-size: 28px;
    color: var(--psgifts-dark);
    cursor: pointer;
    padding: 5px 10px;
    line-height: 1;
    transition: var(--psgifts-transition);
}

.psgifts-close:hover {
    color: var(--psgifts-primary);
    transform: scale(1.1);
}

/* ==========================================================================
   Grid de cojines
   ========================================================================== */
.psgifts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 15px;
}

/* Item individual */
.psgifts-item {
    background: var(--psgifts-white);
    border: 1px solid var(--psgifts-border);
    border-radius: var(--psgifts-radius);
    padding: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: var(--psgifts-transition);
}

.psgifts-item:hover {
    transform: scale(1.05);
    box-shadow: var(--psgifts-shadow);
    z-index: 10;
}

/* Imagen del cojín */
.psgifts-item-image {
    width: 100%;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: 4px;
    background: var(--psgifts-light);
    margin-bottom: 10px;
}

.psgifts-item-image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transition: var(--psgifts-transition);
}

.psgifts-item:hover .psgifts-item-image img {
    transform: scale(1.1);
}

.psgifts-no-image {
    color: #ccc;
    font-size: 40px;
}

/* Info del item */
.psgifts-item-info {
    width: 100%;
    text-align: center;
    margin-bottom: 10px;
}

.psgifts-item-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--psgifts-dark);
    margin: 0;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Botón añadir */
.psgifts-add-btn {
    width: 100%;
    background: var(--psgifts-dark) !important;
    color: var(--psgifts-white) !important;
    border: none !important;
    padding: 8px 12px !important;
    border-radius: 4px !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    transition: var(--psgifts-transition) !important;
}

.psgifts-add-btn:hover:not(:disabled) {
    background: var(--psgifts-primary) !important;
}

.psgifts-add-btn:disabled {
    background: #999 !important;
    cursor: not-allowed !important;
    opacity: 0.7;
}

.psgifts-add-btn.psgifts-loading {
    pointer-events: none;
    opacity: 0.7;
}

/* ==========================================================================
   Loader
   ========================================================================== */
.psgifts-loader {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    z-index: 100;
    align-items: center;
    justify-content: center;
}

.psgifts-loader.psgifts-visible {
    display: flex;
}

.psgifts-loader-inner {
    text-align: center;
}

.psgifts-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--psgifts-light);
    border-top-color: var(--psgifts-primary);
    border-radius: 50%;
    animation: psgifts-spin 0.8s linear infinite;
    margin: 0 auto 15px;
}

@keyframes psgifts-spin {
    to { transform: rotate(360deg); }
}

.psgifts-loader-inner p {
    margin: 0;
    color: var(--psgifts-dark);
    font-weight: 500;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

/* Tablets */
@media (max-width: 992px) {
    .psgifts-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 12px;
    }
    
    .psgifts-panel {
        padding: 20px;
    }
    
    .psgifts-title {
        font-size: 14px;
        padding: 6px 15px;
    }
    
    .psgifts-icon {
        max-height: 40px;
    }
}

/* Móviles */
@media (max-width: 768px) {
    .psgifts-info-bar {
        flex-direction: column;
        text-align: center;
    }
    
    .psgifts-info-text {
        text-align: center;
    }
    
    .psgifts-select-btn {
        width: 100%;
    }
    
    .psgifts-context-cart .psgifts-selector-container {
        padding: 10px;
    }
    
    .psgifts-panel {
        padding: 15px;
        margin: 20px auto;
    }
    
    .psgifts-header {
        flex-wrap: wrap;
    }
    
    .psgifts-title-container {
        width: 100%;
        flex-wrap: wrap;
        gap: 10px;
    }
    
    .psgifts-icon {
        max-height: 35px;
    }
    
    .psgifts-icon.psgifts-icon-right {
        display: none;
    }
    
    .psgifts-title {
        font-size: 13px;
        padding: 5px 12px;
    }
    
    .psgifts-close {
        position: absolute;
        top: 10px;
        right: 10px;
    }
    
    .psgifts-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 10px;
    }
    
    .psgifts-item {
        padding: 8px;
    }
    
    .psgifts-item:hover {
        transform: scale(1.02);
    }
    
    .psgifts-item-name {
        font-size: 11px;
    }
    
    .psgifts-add-btn {
        font-size: 11px !important;
        padding: 6px 10px !important;
    }
}

/* Móviles pequeños */
@media (max-width: 480px) {
    .psgifts-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .psgifts-icon.psgifts-icon-left {
        display: none;
    }
}

/* ==========================================================================
   Contexto Modal (dentro del modal del carrito)
   ========================================================================== */
.psgifts-context-modal .psgifts-panel {
    max-width: 100%;
    margin: 15px 0;
    padding: 15px;
    border-radius: var(--psgifts-radius);
}

.psgifts-context-modal .psgifts-header {
    margin-bottom: 15px;
    padding-bottom: 10px;
}

.psgifts-context-modal .psgifts-grid {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 10px;
}

.psgifts-context-modal .psgifts-item-name {
    font-size: 10px;
}

.psgifts-context-modal .psgifts-add-btn {
    font-size: 10px !important;
    padding: 5px 8px !important;
}

/* ==========================================================================
   Contexto Checkout
   ========================================================================== */
.psgifts-context-checkout .psgifts-panel {
    max-width: 100%;
    margin: 0;
    padding: 15px;
}

.psgifts-context-checkout .psgifts-grid {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
}

/* ==========================================================================
   AVISOS DE COJINES EN CARRITO
   CREADO: 2026-01-24 - Cursor AI
   MODIFICADO: 2026-01-27 - FASE 1 Refactorización - CSS movido desde PHP
   ========================================================================== */

/* Contenedor del aviso - En linea con el boton */
.psg-notice-container {
    display: inline-block;
    margin-left: 15px;
    vertical-align: top;
}

/* Estilo base para avisos */
.psg-notice-container .alert {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    margin: 0;
    border-radius: 0;
    font-size: 14px;
    padding: 0 20px;
    height: 42px;
    box-sizing: border-box;
}

.psg-notice-container .alert .material-icons {
    font-size: 18px;
    flex-shrink: 0;
}

/* Warning (FALTAN cojines) - Fondo naranja suave */
.psg-notice-container .alert-warning {
    background-color: #ffe8cc;
    border: 1px solid #ffcc99;
    color: #000;
}

.psg-notice-container .alert-warning .material-icons {
    color: #ff9a52;
}

.psg-notice-container .psg-alert-content {
    line-height: 1.4;
}

/* Danger (SOBRAN cojines) - Fondo rosa suave */
.psg-notice-container .alert-danger {
    background-color: #ffe6e6;
    border: 1px solid #ffcccc;
    color: #000;
}

.psg-notice-container .alert-danger .material-icons {
    color: #d32f2f;
}

.psg-notice-container .alert-danger strong {
    color: #d32f2f;
}

/* Boton ELEGIR */
.psg-notice-container .psg-alert-btn {
    background: #ff9a52;
    color: #fff;
    border: none;
    padding: 0 20px;
    border-radius: 0;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    height: 28px;
    line-height: 28px;
}

.psg-notice-container .psg-alert-btn:hover {
    background: #e88a42;
    color: #fff;
}

/* Checkout bloqueado */
.psg-checkout-blocked {
    pointer-events: none !important;
    opacity: 0.5 !important;
    cursor: not-allowed !important;
}

/* ==========================================================================
   MODAL SELECTOR DE COJINES (JavaScript)
   ========================================================================== */

.psg-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 99999;
    justify-content: center;
    align-items: flex-start;
    padding-top: 30px;
    overflow-y: auto;
}

.psg-modal-overlay.psg-show {
    display: flex;
}

.psg-modal {
    background: #fff;
    border-radius: 12px;
    max-width: 900px;
    width: 90%;
    max-height: calc(100vh - 60px);
    overflow-y: auto;
    position: relative;
    animation: psgSlideIn 0.3s ease;
}

@keyframes psgSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.psg-modal-close {
    position: absolute;
    top: 10px;
    right: 15px;
    background: none;
    border: none;
    font-size: 28px;
    color: #666;
    cursor: pointer;
    z-index: 10;
}

.psg-modal-close:hover {
    color: #333;
}

/* Selector de regalos - Disenio limpio y MAS GRANDE */
/* MODIFICADO: 2026-01-24 - Cursor AI */
.psg-selector {
    background: #fff;
    border-radius: 12px;
    margin: 15px 0;
    border: 1px solid #e0e0e0;
    overflow: hidden;
}

.psg-header {
    background: linear-gradient(135deg, #db953b 0%, #c47f2a 100%);
    padding: 20px 24px;
    text-align: center;
}

.psg-title {
    color: #fff;
    font-size: 18px;
    font-weight: 600;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.psg-title .psg-num {
    background: #fff;
    color: #db953b;
    padding: 4px 16px;
    border-radius: 15px;
    font-weight: 700;
    font-size: 17px;
}

.psg-num {
    background: #fff;
    color: #db953b;
    padding: 3px 14px;
    border-radius: 15px;
    font-weight: 700;
}

.psg-body {
    padding: 25px;
}

.psg-intro {
    font-size: 14px;
    color: #666;
    text-align: center;
    margin: 0 0 22px 0;
}

.psg-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 18px;
    margin-bottom: 18px;
}

.psg-card {
    background: #fafafa;
    border: 2px solid #eee;
    border-radius: 10px;
    padding: 14px;
    text-align: center;
    transition: all 0.2s ease;
}

.psg-card:hover {
    border-color: #db953b;
    background: #fff;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
}

.psg-card.added {
    border-color: #4CAF50;
    background: #f5fff5;
}

.psg-card-img {
    width: 100%;
    height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
    position: relative;
    cursor: pointer;
}

.psg-card-img img {
    max-width: 100%;
    max-height: 140px;
    object-fit: contain;
    border-radius: 6px;
    transition: transform 0.2s;
}

.psg-card:hover .psg-card-img img {
    transform: scale(1.05);
}

/* MODIFICADO: 2026-01-28 - Cursor AI - Badge "X escogidos" por modelo */
.psg-card-badge {
    display: none;
    position: absolute;
    top: 6px;
    right: 6px;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    background: #db953b;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    line-height: 22px;
    text-align: center;
    border-radius: 11px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
    align-items: center;
    justify-content: center;
    pointer-events: auto;
    z-index: 2;
    cursor: default;
}
.psg-card-badge.psg-visible {
    display: flex;
}

.psg-card-zoom {
    position: absolute;
    bottom: 5px;
    right: 5px;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    font-size: 14px;
    line-height: 26px;
    opacity: 0;
    transition: opacity 0.2s;
    cursor: pointer;
}

.psg-card:hover .psg-card-zoom {
    opacity: 1;
}

.psg-card-name {
    font-size: 13px;
    font-weight: 500;
    color: #333;
    margin: 0 0 12px 0;
    line-height: 1.4;
    height: 38px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.psg-card-btn {
    width: 100%;
    background: #333;
    color: #fff;
    border: none;
    padding: 11px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.psg-card-btn:hover {
    background: #db953b;
}

.psg-card-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.psg-card-btn.loading {
    background: #666;
}

.psg-card-btn.done {
    background: #4CAF50;
}

.psg-footer {
    padding: 16px 24px;
    background: #f5f5f5;
    border-top: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.psg-status {
    font-size: 15px;
    color: #555;
}

.psg-status strong {
    color: #db953b;
    font-weight: 700;
}

.psg-skip-btn {
    background: none;
    border: 1px solid #aaa;
    color: #666;
    padding: 9px 18px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.psg-skip-btn:hover {
    border-color: #333;
    color: #333;
}

/* ==========================================================================
   RESPONSIVE - AVISOS CARRITO
   ========================================================================== */

/* Responsive - Selector */
@media (max-width: 1024px) {
    .psg-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 15px;
    }
}

@media (max-width: 768px) {
    .psg-notice-container {
        display: block;
        margin: 15px 0;
        width: 100%;
    }
    
    .psg-notice-container .alert {
        display: flex;
        width: 100%;
    }
    
    /* FASE 1: Añadido desde PHP - Responsive para cart-grid-body */
    .cart-grid-body .cart-overview {
        display: block;
    }
    
    .psg-modal {
        width: 95%;
        max-height: 90vh;
    }
    
    .psg-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 12px;
    }
    
    .psg-card-img {
        height: 100px;
    }
    
    .psg-card-img img {
        max-height: 100px;
    }
    
    .psg-card-name {
        font-size: 12px;
        height: 34px;
    }
    
    .psg-card-btn {
        padding: 9px;
        font-size: 12px;
    }
    
    /* FASE 1: Añadido desde PHP - Responsive para psg-info-notice */
    .psg-info-notice {
        flex-wrap: wrap;
        width: 100%;
        justify-content: center;
        text-align: center;
    }
    
    .psg-info-notice-text {
        width: 100%;
        margin-bottom: 8px;
    }
}

@media (max-width: 480px) {
    .psg-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    
    .psg-card {
        padding: 10px;
    }
    
    .psg-card-img {
        height: 80px;
    }
    
    .psg-card-img img {
        max-height: 80px;
    }
    
    .psg-footer {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
}

/* ==========================================================================
   AVISOS ANTIGUOS (para compatibilidad)
   CREADO: 2026-01-24 - Cursor AI
   ========================================================================== */

/* Aviso BLOQUEANTE cuando sobran cojines */
.psg-error-notice {
    display: block;
    background: linear-gradient(135deg, #ffebee 0%, #ffcdd2 100%);
    border: 2px solid #e53935;
    border-radius: 8px;
    padding: 15px 20px;
    margin: 15px 0;
    box-shadow: 0 2px 8px rgba(229, 57, 53, 0.2);
}

.psg-error-notice-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
    font-weight: 700;
    color: #c62828;
    margin-bottom: 8px;
}

.psg-error-notice-title svg {
    width: 24px;
    height: 24px;
    fill: #c62828;
}

.psg-error-notice-text {
    font-size: 14px;
    color: #b71c1c;
    line-height: 1.5;
}

.psg-error-notice-text strong {
    color: #c62828;
}

/* Aviso informativo cuando faltan cojines */
.psg-info-notice {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    background: linear-gradient(135deg, #fff8e1 0%, #ffecb3 100%);
    border: 2px solid #db953b;
    border-radius: 8px;
    padding: 12px 18px;
    margin-left: 15px;
    vertical-align: middle;
    box-shadow: 0 2px 8px rgba(219, 149, 59, 0.2);
}

.psg-info-notice-text {
    font-size: 14px;
    color: #333;
    line-height: 1.4;
}

.psg-info-notice-text strong {
    color: #db953b;
    font-weight: 700;
}

.psg-info-notice-btn {
    background: #db953b;
    color: #fff;
    border: none;
    padding: 8px 16px;
    border-radius: 5px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.psg-info-notice-btn:hover {
    background: #c47f2a;
    transform: translateY(-1px);
}

@media (max-width: 768px) {
    .psg-info-notice {
        flex-wrap: wrap;
        margin: 15px 0 0 0;
        width: 100%;
        justify-content: center;
        text-align: center;
    }
    
    .psg-info-notice-text {
        width: 100%;
        margin-bottom: 8px;
    }
}
