/* ============================================
   STORE SELECTOR - Collapse/Acordeón Version
   ============================================ */

.store-selector-wrapper {
    position: relative;
    display: inline-block;
    width: auto;
    z-index: 999;
}

/* ============================================
   DESKTOP VERSION (.store-selector-desktop)
   ============================================ */

.store-selector-desktop {
    display: none !important;
}

@media (min-width: 769px) {
    .store-selector-desktop {
        display: inline-block !important;
        min-width: 200px;
        max-width: 350px;
        margin: 5px 0;
    }

    .store-selector-header {
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        border-radius: 25px;
        padding: 0;
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        transition: all 0.3s ease;
    }

    .store-selector-toggle {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 6px 16px;
        cursor: pointer;
        color: white;
        font-weight: 600;
        font-size: 14px;
        user-select: none;
        gap: 8px;
        background: transparent;
        border: none;
        width: 100%;
        transition: all 0.3s ease;
        outline: none;
    }

    .store-selector-toggle:hover {
        background: rgba(255, 255, 255, 0.1);
    }

    .store-selector-toggle:active {
        background: rgba(255, 255, 255, 0.15);
    }

    /* Quitar focus border azul */
    .store-selector-toggle:focus {
        outline: none !important;
        box-shadow: none !important;
        border: none !important;
    }

    .store-selector-toggle:focus-visible {
        outline: none !important;
        box-shadow: none !important;
        border: none !important;
    }

    .store-selector-label {
        flex: 1;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        text-align: left;
        font-weight: normal;
        font-size: 1rem;
    }

    .dropdown-icon {
        width: 20px;
        height: 20px;
        flex-shrink: 0;
        transition: transform 0.3s ease;
    }

    .store-selector-desktop[aria-expanded="true"] .dropdown-icon,
    .store-selector-desktop.open .dropdown-icon {
        transform: rotate(180deg);
    }

    /* Dropdown CERRADO por defecto */
    .store-selector-dropdown {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: white;
        border-radius: 0 0 8px 8px;
        box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
        margin-top: 4px;
        z-index: 1000;
        width: 250px;
    }

    /* Dropdown ABIERTO */
    .store-selector-desktop.open .store-selector-dropdown,
    .store-selector-desktop[aria-expanded="true"] .store-selector-dropdown {
        display: block;
    }

    .store-selector-content {
        padding: 8px 0;
    }

    .store-item {
        padding: 16px;
        border-bottom: 1px solid #f0f0f0;
        transition: all 0.2s ease;
        cursor: pointer;
    }

    .store-item:last-child {
        border-bottom: none;
    }

    .store-item:hover:not(.active) {
        background-color: #f8f9ff;
    }

    .store-item.active {
        background: linear-gradient(135deg, rgba(102, 126, 234, 0.05) 0%, rgba(118, 75, 162, 0.05) 100%);
        border-left: 4px solid #667eea;
        padding-left: 12px;
    }

    .store-item-header {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        margin-bottom: 8px;
        gap: 12px;
    }

    .store-item-info {
        display: flex;
        flex-direction: column;
        gap: 4px;
        flex: 1;
    }

    .store-name {
        font-weight: 600;
        font-size: 14px;
        color: #333;
        word-break: break-word;
    }

    .store-badge {
        display: inline-block;
        font-size: 11px;
        font-weight: 700;
        padding: 3px 8px;
        border-radius: 12px;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        width: fit-content;
    }

    .store-badge.active-badge {
        background-color: #e8f5e9;
        color: #2e7d32;
    }

    .store-item-saldo {
        display: flex;
        flex-direction: column;
        align-items: flex-end;
        gap: 2px;
        white-space: nowrap;
    }

    .saldo-label {
        font-size: 11px;
        color: #999;
        font-weight: 500;
    }

    .saldo-value {
        font-size: 14px;
        font-weight: 700;
        color: #667eea;
    }

    .store-item-location {
        display: flex;
        align-items: center;
        gap: 8px;
        margin-bottom: 12px;
        font-size: 12px;
        color: #666;
    }

    .location-icon {
        width: 14px;
        height: 14px;
        color: #667eea;
        flex-shrink: 0;
    }

    .btn-select-store {
        width: 100%;
        padding: 10px 12px;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        color: white;
        border: none;
        border-radius: 6px;
        font-size: 12px;
        font-weight: 600;
        cursor: pointer;
        transition: all 0.3s ease;
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }

    .btn-select-store:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    }

    .btn-select-store:active {
        transform: translateY(0);
    }

    .btn-select-store:disabled {
        opacity: 0.5;
        cursor: not-allowed;
    }

    .btn-select-store.loading {
        position: relative;
        color: transparent;
    }

    .btn-select-store.loading::after {
        content: '';
        position: absolute;
        width: 12px;
        height: 12px;
        top: 50%;
        left: 50%;
        margin-left: -6px;
        margin-top: -6px;
        border: 2px solid rgba(255, 255, 255, 0.3);
        border-radius: 50%;
        border-top-color: white;
        animation: spinner 0.6s linear infinite;
    }
}

/* ============================================
   MOBILE VERSION (.store-selector-mobile)
   ============================================ */

.store-selector-mobile {
    display: block !important;
    width: 100%;
    margin: 0 0 16px 0;
}

@media (min-width: 769px) {
    .store-selector-mobile {
        display: none !important;
    }
}

.store-selector-mobile-toggle {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 12px 16px;
    border-radius: 25px;
    border: none;
    cursor: pointer;
    color: white;
    font-size: 16px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    transition: all 0.3s ease;
    outline: none;
}

.store-selector-mobile-toggle:active {
    background: linear-gradient(135deg, #5568d3 0%, #6a3d8f 100%);
}

/* Quitar focus border azul en móvil */
.store-selector-mobile-toggle:focus {
    outline: none !important;
    box-shadow: none !important;
    border: none !important;
}

.store-selector-mobile-toggle:focus-visible {
    outline: none !important;
    box-shadow: none !important;
    border: none !important;
}

.store-icon-mobile {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}

.store-selector-mobile-title {
    flex: 1;
    text-align: left;
    margin: 0;
    padding: 0;
    font-size: 16px;
    font-weight: 700;
}

.collapse-icon-mobile {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    transition: transform 0.3s ease;
}

.store-selector-mobile[aria-expanded="true"] .collapse-icon-mobile,
.store-selector-mobile.open .collapse-icon-mobile {
    transform: rotate(180deg);
}

/* Contenido CERRADO por defecto */
.store-selector-mobile-content {
    display: none;
    background: white;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Contenido ABIERTO */
.store-selector-mobile[aria-expanded="true"] .store-selector-mobile-content,
.store-selector-mobile.open .store-selector-mobile-content {
    display: block;
    max-height: calc(100vh - 200px);
    overflow-y: auto;
}

.store-item-mobile {
    padding: 16px;
    border-bottom: 1px solid #f0f0f0;
    transition: all 0.2s ease;
    background: white;
}

.store-item-mobile:last-child {
    border-bottom: none;
}

.store-item-mobile:active {
    background-color: #f5f5f5;
}

.store-item-mobile.active {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.08) 0%, rgba(118, 75, 162, 0.08) 100%);
    border-left: 4px solid #667eea;
    padding-left: 12px;
}

.store-mobile-main {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.store-mobile-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.store-name-mobile {
    font-weight: 700;
    font-size: 15px;
    color: #333;
    line-height: 1.3;
}

.store-badge-mobile {
    display: inline-flex;
    align-items: center;
    font-size: 12px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    width: fit-content;
    background-color: #e8f5e9;
    color: #2e7d32;
}

.store-mobile-details {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding: 8px 0;
    border-top: 1px solid #f0f0f0;
    border-bottom: 1px solid #f0f0f0;
}

.store-mobile-saldo {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.saldo-label-mobile {
    font-size: 12px;
    color: #999;
    font-weight: 500;
}

.saldo-value-mobile {
    font-size: 15px;
    font-weight: 700;
    color: #667eea;
}

.store-mobile-location {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 12px;
    font-size: 13px;
    color: #666;
}

.location-icon-mobile {
    width: 16px;
    height: 16px;
    color: #667eea;
    flex-shrink: 0;
    margin-top: 2px;
}

.btn-select-store-mobile {
    width: 100%;
    padding: 12px 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    touch-action: manipulation;
}

.btn-select-store-mobile:active {
    transform: scale(0.98);
    opacity: 0.9;
}

.btn-select-store-mobile:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-select-store-mobile.loading {
    position: relative;
    color: transparent;
}

.btn-select-store-mobile.loading::after {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    top: 50%;
    left: 50%;
    margin-left: -7px;
    margin-top: -7px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spinner 0.6s linear infinite;
}

/* ============================================
   ANIMATIONS
   ============================================ */

@keyframes spinner {
    to { transform: rotate(360deg); }
}

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

/* ============================================
   UTILITY CLASSES
   ============================================ */

.store-selector-message {
    padding: 12px 16px;
    font-size: 13px;
    text-align: center;
    border-radius: 4px;
    margin: 8px 0 0 0;
}

.store-selector-message.error {
    color: #d32f2f;
    background-color: #ffebee;
    border-left: 4px solid #d32f2f;
}

.store-selector-message.success {
    color: #388e3c;
    background-color: #e8f5e9;
    border-left: 4px solid #388e3c;
}

.store-selector-message.info {
    color: #0066cc;
    background-color: #e7f3ff;
    border-left: 4px solid #0066cc;
}

.spinner-inline {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin-inline 0.8s linear infinite;
    margin-right: 8px;
    vertical-align: middle;
}

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

.btn-select-store.loading,
.btn-select-store-mobile.loading {
    background-color: #667eea;
    opacity: 0.8;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-select-store.success,
.btn-select-store-mobile.success {
    background-color: #28a745;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.success-icon {
    font-size: 18px;
    font-weight: bold;
}

/* ============================================
   SCROLLBAR CUSTOMIZATION
   ============================================ */

.store-selector-dropdown::-webkit-scrollbar,
.store-selector-mobile-content::-webkit-scrollbar {
    width: 6px;
}

.store-selector-dropdown::-webkit-scrollbar-track,
.store-selector-mobile-content::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.store-selector-dropdown::-webkit-scrollbar-thumb,
.store-selector-mobile-content::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 10px;
}

.store-selector-dropdown::-webkit-scrollbar-thumb:hover,
.store-selector-mobile-content::-webkit-scrollbar-thumb:hover {
    background: #764ba2;
}

/* ============================================
   ACCESSIBILITY
   ============================================ */

@media (prefers-reduced-motion: reduce) {
    .store-selector-wrapper,
    .store-selector-dropdown,
    .store-selector-mobile-content,
    .store-item,
    .store-item-mobile,
    .btn-select-store,
    .btn-select-store-mobile,
    .dropdown-icon,
    .collapse-icon-mobile {
        animation: none !important;
        transition: none !important;
    }
}

/* ============================================
   PRINT STYLES
   ============================================ */

@media print {
    .store-selector-wrapper {
        display: none !important;
    }
}

