/* ============================================
   JOGALART - Sistema de Carrito
   Estilos del carrito y menu desplegable
   ============================================ */

/* ============================================
   BOTON DEL CARRITO EN NAVBAR
   ============================================ */

.cart-nav-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: var(--radius-xl);
    font-weight: 600;
    font-size: 0.85rem;
    text-decoration: none;
    transition: var(--transition);
    border: 2px solid var(--purple-primary);
    color: var(--purple-primary);
    background: transparent;
    cursor: pointer;
    position: relative;
}

.cart-nav-btn:hover {
    background: var(--purple-primary);
    color: white;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.cart-nav-btn.active {
    background: var(--purple-primary);
    color: white;
}

.cart-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    background: var(--color-secondary);
    color: #1f2937;
    border-radius: 9999px;
    font-size: 0.72rem;
    font-weight: 700;
    transition: var(--transition);
}

.cart-nav-btn:hover .cart-badge,
.cart-nav-btn.active .cart-badge {
    background: white;
    color: var(--purple-primary);
}

/* ============================================
   MENU DROPDOWN DEL CARRITO
   ============================================ */

.cart-dropdown-wrapper {
    position: relative;
}

.cart-dropdown {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 12px);
    width: 380px;
    max-width: calc(100vw - 32px);
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 50px rgba(0,0,0,0.15);
    z-index: 1000;
    overflow: hidden;
    animation: cartDropdownIn 0.25s ease;
}

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

.cart-dropdown.open {
    display: block;
}

/* Flecha del dropdown */
.cart-dropdown::before {
    content: '';
    position: absolute;
    top: -6px;
    right: 24px;
    width: 12px;
    height: 12px;
    background: white;
    transform: rotate(45deg);
    border-radius: 2px;
}

/* Header del dropdown */
.cart-dropdown-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--color-border);
    position: relative;
    z-index: 2;
    background: white;
}

.cart-dropdown-header h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--color-dark);
    display: flex;
    align-items: center;
    gap: 8px;
}

.cart-dropdown-header h3 svg {
    color: var(--purple-primary);
}

.cart-dropdown-count {
    font-size: 0.8rem;
    color: var(--color-text-light);
    font-weight: 500;
}

/* Lista de items en dropdown */
.cart-dropdown-items {
    max-height: 320px;
    overflow-y: auto;
    padding: 8px 0;
}

.cart-dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    transition: var(--transition);
    position: relative;
}

.cart-dropdown-item:hover {
    background: var(--color-bg-alt);
}

.cart-dropdown-item-image {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    flex-shrink: 0;
}

.cart-dropdown-item-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cart-dropdown-item-info {
    flex: 1;
    min-width: 0;
}

.cart-dropdown-item-title {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--color-dark);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cart-dropdown-item-meta {
    font-size: 0.75rem;
    color: var(--color-text-light);
    display: flex;
    align-items: center;
    gap: 8px;
}

.cart-dropdown-item-price {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--purple-primary);
    white-space: nowrap;
}

.cart-dropdown-item-remove {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--color-text-light);
    transition: var(--transition);
    flex-shrink: 0;
}

.cart-dropdown-item-remove:hover {
    background: #fee2e2;
    color: var(--color-error);
}

/* Footer del dropdown */
.cart-dropdown-footer {
    padding: 14px 16px;
    border-top: 1px solid var(--color-border);
    background: var(--color-bg);
    position: relative;
    z-index: 2;
}

.cart-dropdown-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    font-weight: 600;
}

.cart-dropdown-total-label {
    font-size: 0.9rem;
    color: var(--color-dark);
}

.cart-dropdown-total-amount {
    font-size: 1.15rem;
    color: var(--purple-primary);
}

.cart-dropdown-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.cart-dropdown-actions .btn {
    width: 100%;
    justify-content: center;
    padding: 11px 20px;
    font-size: 0.9rem;
}

/* Estado vacio del dropdown */
.cart-dropdown-empty {
    text-align: center;
    padding: 36px 20px;
    color: var(--color-text-light);
}

.cart-dropdown-empty svg {
    margin-bottom: 12px;
    opacity: 0.4;
}

.cart-dropdown-empty p {
    font-size: 0.9rem;
    margin-bottom: 16px;
}

/* ============================================
   PAGINA DEL CARRITO (cart.php)
   ============================================ */

.cart-page {
    min-height: calc(100vh - 72px);
    background: var(--color-bg);
    padding-bottom: 60px;
}

.cart-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 32px;
    flex-wrap: wrap;
    gap: 16px;
}

.cart-title {
    font-size: 1.7rem;
    font-weight: 800;
    color: var(--color-dark);
    margin-bottom: 4px;
}

.cart-subtitle {
    font-size: 0.95rem;
    color: var(--color-text-light);
}

.cart-subtitle strong {
    color: var(--purple-primary);
}

/* Layout principal */
.cart-layout {
    display: grid;
    grid-template-columns: 1fr 360px;
    gap: 32px;
    align-items: start;
}

/* Lista de items */
.cart-items-section {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.cart-items-header {
    display: grid;
    grid-template-columns: 1fr auto;
    padding: 14px 24px;
    background: var(--color-bg-alt);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--color-border);
}

.cart-items-list {
    padding: 8px 0;
}

.cart-item {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 20px;
    padding: 20px 24px;
    border-bottom: 1px solid var(--color-border);
    align-items: center;
    transition: var(--transition);
}

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

.cart-item:hover {
    background: rgba(123,31,162,0.02);
}

.cart-item-info {
    display: flex;
    gap: 16px;
    align-items: center;
}

.cart-item-image {
    width: 100px;
    height: 75px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
}

.cart-item-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cart-item-details {
    flex: 1;
    min-width: 0;
}

.cart-item-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--color-dark);
    margin-bottom: 4px;
    line-height: 1.3;
}

.cart-item-desc {
    font-size: 0.82rem;
    color: var(--color-text-light);
    line-height: 1.5;
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.cart-item-meta {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
}

.cart-item-meta span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.78rem;
    color: var(--color-text-light);
}

.cart-item-meta svg {
    color: var(--purple-primary);
}

.cart-item-price {
    text-align: right;
    white-space: nowrap;
}

.cart-price-current {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--purple-primary);
}

.cart-price-original {
    font-size: 0.85rem;
    color: var(--color-text-light);
    text-decoration: line-through;
}

.cart-item-remove {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 8px;
    padding: 6px 12px;
    border: none;
    background: transparent;
    color: var(--color-text-light);
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    cursor: pointer;
}

.cart-item-remove:hover {
    background: #fee2e2;
    color: var(--color-error);
}

/* Acciones inferiores */
.cart-actions-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    border-top: 1px solid var(--color-border);
    background: var(--color-bg-alt);
}

.btn-danger-ghost {
    color: var(--color-error) !important;
}

.btn-danger-ghost:hover {
    background: #fee2e2 !important;
    color: #dc2626 !important;
}

/* Resumen del pedido */
.cart-summary-section {
    position: sticky;
    top: 88px;
}

.cart-summary-card {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 24px;
}

.cart-summary-card h2 {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--color-dark);
    margin-bottom: 20px;
}

.cart-summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    font-size: 0.92rem;
    color: var(--color-text);
}

.cart-summary-savings {
    color: var(--color-success);
    font-weight: 500;
}

.cart-summary-savings span:last-child {
    font-weight: 700;
}

.cart-summary-divider {
    height: 1px;
    background: var(--color-border);
    margin: 8px 0;
}

.cart-summary-total {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--color-dark);
    padding: 12px 0;
}

.cart-summary-total span:last-child {
    font-size: 1.4rem;
    color: var(--purple-primary);
}

.cart-summary-note {
    font-size: 0.78rem;
    color: var(--color-text-light);
    text-align: center;
    margin-top: 4px;
}

.cart-checkout-form {
    margin-top: 16px;
}

.cart-payment-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--color-border);
    font-size: 0.78rem;
    color: var(--color-text-light);
}

.cart-payment-info svg {
    color: var(--color-success);
}

/* Garantia */
.cart-guarantee {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-top: 16px;
    padding: 16px 20px;
    background: #ecfdf5;
    border-radius: var(--radius-md);
    border: 1px solid #d1fae5;
}

.cart-guarantee-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--color-success);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
}

.cart-guarantee-text {
    display: flex;
    flex-direction: column;
}

.cart-guarantee-text strong {
    font-size: 0.88rem;
    color: var(--color-dark);
}

.cart-guarantee-text span {
    font-size: 0.8rem;
    color: var(--color-text-light);
}

/* ============================================
   BOTON AGREGAR AL CARRITO (en cards y curso)
   ============================================ */

.btn-add-cart {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius-md);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    border: 2px solid var(--purple-primary);
    background: var(--purple-primary);
    color: white;
    text-decoration: none;
    white-space: nowrap;
}

.btn-add-cart:hover {
    background: var(--purple-dark);
    border-color: var(--purple-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-add-cart svg {
    flex-shrink: 0;
}

.btn-add-cart.added {
    background: var(--color-success);
    border-color: var(--color-success);
}

.btn-add-cart.added:hover {
    background: #059669;
    border-color: #059669;
}

/* Boton grande para pagina de curso */
.btn-add-cart-lg {
    padding: 14px 28px;
    font-size: 1rem;
    border-radius: var(--radius-xl);
    width: 100%;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 992px) {
    .cart-layout {
        grid-template-columns: 1fr;
    }

    .cart-summary-section {
        position: static;
        order: -1;
    }

    .cart-summary-card {
        max-width: 100%;
    }

    .cart-dropdown {
        width: 340px;
    }

    .cart-item {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .cart-item-price {
        display: flex;
        align-items: center;
        justify-content: space-between;
        text-align: left;
    }
}

@media (max-width: 640px) {
    .cart-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .cart-item-info {
        flex-direction: column;
        align-items: flex-start;
    }

    .cart-item-image {
        width: 100%;
        height: 160px;
    }

    .cart-dropdown {
        position: fixed !important;
        top: 72px !important;
        left: 8px !important;
        right: 8px !important;
        width: auto !important;
        max-height: calc(100vh - 88px);
    }

    .cart-dropdown::before {
        display: none;
    }

    .cart-actions-bottom {
        flex-direction: column;
        gap: 8px;
    }

    .cart-actions-bottom .btn {
        width: 100%;
        justify-content: center;
    }
}
