/*
 * public/css/frontend-cards-cart.css
 *
 * Este archivo contiene los estilos prefijados del backend para las tarjetas de cursos y el sistema de carrito,
 * adaptados para el frontend. Se recomienda cargar este archivo CSS después de los archivos CSS existentes
 * del frontend para asegurar la precedencia de los estilos.
 *
 * Para evitar conflictos, se han prefijado con 'fe-' las clases e IDs personalizados que no pertenecen a Bootstrap.
 * Las variables CSS :root se han tomado de style-new.css del backend para una consistencia de diseño.
 */

/* ------------------------------------------- */
/* 1. Root Variables (Backend Consolidated)    */
/* ------------------------------------------- */
:root {
    --primary-color: #1a7b88;
    --primary-hover: #135c66;
    --secondary-color: #10b981;
    --secondary-hover: #059669;
    --dark-color: #1e293b;
    --light-color: #f8fafc;
    /* General light background for body/wrapper */
    --gray-color: #64748b;
    --light-gray: #e2e8f0;
    --border-color: #e2e8f0;
    --text-color: #334155;
    --text-light: #94a3b8;
    --danger-color: #ef4444;
    /* Used for cart remove, notifications */
    --warning-color: #f59e0b;
    /* Used for notifications */
    --success-color: #10b981;
    /* Used for cart indicator, notifications */
    --info-color: #3b82f6;
    /* Used for course badge */

    --primary-dark: #146570;
    /* Used in gradients, hover states */
    --primary-light: #e8f4f5;
    /* Used for background of selected card, etc. */
    --accent-color: #f47c3c;
    /* Used for buy now button, cart count badge */

    --border-radius: 8px;
    /* General border radius */
    --border-radius-sm: 0.25rem;
    --border-radius-md: 0.75rem;
    --border-radius-lg: 1rem;

    --box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    /* General box shadow */
    --box-shadow-md: 0 0.5rem 1rem rgba(0, 0, 0, 0.08);
    /* Medium box shadow */
    --box-shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
    /* Large box shadow */

    --transition: all 0.3s ease;
    /* General transition duration */

    /* Specific values from backend's style-new.css (may override frontend defaults) */
    --sidebar-width: 230px;
    --sidebar-collapsed-width: 60px;
    --header-height: 60px;
}

/* ------------------------------------------- */
/* 2. General Styles (from style-new.css)      */
/* ------------------------------------------- */
/* General body font and color (assuming Poppins from frontend ai.css is kept, Inter from backend is overridden if loaded later) */
body {
    /* font-family: Inter, sans-serif; /* Keep frontend's Poppins for global consistency unless specified */
    color: var(--text-color);
    line-height: 1.6;
}

a {
    text-decoration: none;
    color: var(--primary-color);
    transition: var(--transition);
}

a:hover {
    color: var(--primary-hover);
}

ul {
    list-style: none;
}

img {
    max-width: 100%;
    height: auto;
}

.fe-wrapper,
body {
    min-height: 100vh;
}

.fe-content,
body {
    background-color: var(--light-color);
    /* Backend's body background */
}

.fe-main {
    display: flex;
    /* Assuming it's part of layout, not just cards */
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

.fe-content {
    flex: 1;
    padding: 2rem 1.5rem;
}

/* Content padding, adjust as needed for frontend layout */


/* ------------------------------------------- */
/* 3. Course Cards (from bkdcoursecardsnstyles.css & style-new.css) */
/* ------------------------------------------- */

/* Section containing available courses */
.fe-available-courses-section {
    background-color: var(--light-color);
    /* Background for the entire section */
    border-radius: var(--border-radius-lg);
    padding: 2rem;
    /* margin-bottom: 2rem; */
    box-shadow: var(--box-shadow);
}

.fe-category-section {
    margin-bottom: 3rem;
}

.fe-category-title {
    font-size: 1.5rem;
    color: var(--primary-dark);
    margin-bottom: 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--accent-color);
    display: inline-block;
}

/* Base course card styling */
.fe-course-card {
    position: relative;
    overflow: hidden;
    background: var(--white);
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    height: 100%;
    z-index: 1;
    border: 2px solid transparent;
    animation: 0.6s forwards feFadeInUp;
    /* Prefixed animation */
    transition: var(--transition);
    /* For hover effect */
}

/* Course card hover effects */
.fe-course-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--box-shadow-md);
}

/* Course card states */
.fe-course-card.fe-selected {
    border-color: var(--primary-color);
    background-color: var(--primary-light);
}

/* Course Image Container */
.fe-course-image {
    position: relative;
    overflow: hidden;
    height: 302px;
    /* Altura fija para todas las cards */
    background-color: #f8f9fa;
    /* Color de fondo para espacios vacíos */
    display: flex;
    align-items: center;
    justify-content: center;
}

.fe-course-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    /* Muestra la imagen completa sin recortar */
    transition: transform 0.5s ease;
}

.fe-course-card:hover .fe-course-image img {
    transform: scale(1.05);
}

/* In-Cart Indicator on course image */
.fe-in-cart-indicator {
    position: absolute;
    top: 10px;
    left: 10px;
    /* Aligned left for frontend */
    background: var(--success-color);
    color: var(--white);
    padding: 5px 10px;
    /* Adjusted padding for better fit */
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    display: none;
    /* Hidden by default, shown when in cart */
    z-index: 5;
}

.fe-course-card.in-cart .fe-in-cart-indicator {
    display: flex !important;
    /* Force display when course is in cart */
    align-items: center;
}

/* Course Tags (if needed) */
.fe-course-tag {
    position: absolute;
    top: 10px;
    right: 10px;
    background: var(--accent-color);
    color: var(--white);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
}

/* Course Content */
.fe-course-content {
    padding: 1.5rem;
    position: relative;
}

.fe-course-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    line-height: 1.4;
    min-height: 2.8rem;
    /* Ensure consistent height for titles across cards */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    /* Limit title to 2 lines */
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Course Rating */
.fe-course-rating {
    display: flex;
    align-items: center;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.fe-course-rating i {
    color: gold;
    /* Using gold directly as text-warning from Bootstrap */
}

.fe-rating-count {
    margin-left: 0.5rem;
    color: var(--text-light);
}

/* Course Price */
.fe-course-price {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 1rem;
}

/* Course Actions (Add to Cart / Buy Now buttons) */
.fe-course-actions {
    display: flex;
    gap: 0.5rem;
}

.fe-btn-add-cart,
.fe-btn-buy-now {
    padding: 8px 12px;
    border-radius: var(--border-radius);
    font-size: 0.9rem;
    transition: var(--transition);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    /* Make buttons take equal width */
}

/* Add to Cart button specific styles */
.fe-btn-add-cart {
    background: var(--primary-color);
    color: var(--white);
}

.fe-btn-add-cart:hover {
    background: var(--primary-hover);
}

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

.fe-btn-add-cart.in-cart:hover {
    background: #38a169;
    /* Darker success */
    border-color: #38a169;
}

/* Buy Now button specific styles */
.fe-btn-buy-now {
    background: var(--accent-color);
    color: var(--white);
}

.fe-btn-buy-now:hover {
    background: #e56f30;
    /* Darker accent */
}

/* Course Footer (View Details button) */
.fe-course-footer {
    margin-top: 1rem;
}

/* ------------------------------------------- */
/* 4. Cart System (from bkdcart.css & certificatencart.css) */
/* ------------------------------------------- */

/* Floating Cart Toggle Button */
.fe-cart-toggle {
    position: fixed;
    top: 50%;
    right: 20px;
    transform: translateY(-50%);
    background: var(--primary-color);
    border: none;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    font-size: 1.5rem;
    box-shadow: var(--box-shadow);
    z-index: 999;
    display: none;
    /* Hidden by default, shown when items are added */
    color: var(--white);
    transition: var(--transition);
    cursor: pointer;
}

.fe-cart-toggle:hover {
    background: var(--primary-dark);
    transform: translateY(-50%) scale(1.1);
}

.fe-cart-toggle.active {
    display: flex !important;
    /* Force display when active/items in cart */
    align-items: center;
    justify-content: center;
}

/* Cart Count Badge */
.fe-cart-count {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--accent-color);
    border-radius: 50%;
    width: 25px;
    height: 25px;
    display: none;
    /* Hidden by default, shown when > 0 items */
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--white);
}

/* Cart Backdrop (overlay when sidebar is open) */
.fe-cart-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    /* Higher z-index than sidebar */
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.fe-cart-backdrop.active {
    opacity: 1 !important;
    visibility: visible !important;
}

/* Cart Sidebar */
.fe-cart-sidebar {
    position: fixed;
    top: 0;
    right: 0;
    width: 400px;
    height: 100vh;
    background: var(--white);
    box-shadow: -4px 0 15px rgba(0, 0, 0, 0.1);
    transform: translateX(100%);
    /* Off-screen by default */
    z-index: 10000;
    /* Higher than backdrop */
    display: flex;
    flex-direction: column;
    transition: var(--transition);
}

.fe-cart-sidebar.active {
    transform: translateX(0) !important;
    /* Slide in */
}

@media (max-width: 768px) {
    .fe-cart-sidebar {
        width: 100%;
    }
}

/* Cart Header */
.fe-cart-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--gray-200);
    background: var(--primary-color);
    color: var(--white);
}

.fe-cart-header h3 {
    margin: 0;
    font-size: 1.2rem;
    color: inherit;
    /* Inherit color from parent */
}

/* Ensure btn-close is white */
.fe-cart-header .btn-close {
    filter: brightness(0) invert(1);
    /* Makes Bootstrap's close icon white */
    opacity: 1;
}


/* Cart Items Container */
.fe-cart-items {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

/* Empty Cart State */
.fe-empty-cart {
    text-align: center;
    padding: 2rem;
    color: var(--text-light);
    display: none;
    /* Hidden by default, shown when empty */
}

.fe-empty-cart i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* Individual Cart Item */
.fe-cart-item {
    display: flex;
    align-items: center;
    padding: 1rem;
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius);
    margin-bottom: 1rem;
    background: var(--gray-100);
    transition: var(--transition);
}

.fe-cart-item:hover {
    background-color: var(--gray-200);
    /* Lighter hover effect */
}

.fe-cart-item-info {
    flex: 1;
    margin-left: 1rem;
    /* Adjust as needed */
}

.fe-cart-item-title {
    font-weight: 600;
    margin-bottom: 0.25rem;
    font-size: 0.9rem;
    color: var(--text-color);
    line-height: 1.3;
}

.fe-cart-item-price {
    color: var(--primary-color);
    font-weight: 700;
    font-size: 1rem;
}

/* Remove Item Button */
.fe-remove-item {
    background: none;
    border: none;
    color: var(--danger-color);
    /* Red for remove action */
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 50%;
    transition: var(--transition);
    font-size: 1rem;
}

.fe-remove-item:hover {
    background: rgba(220, 53, 69, 0.1);
    /* Light red background on hover */
    color: var(--danger-color);
}

/* Cart Footer */
.fe-cart-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--gray-200);
    background: var(--gray-100);
    display: none;
    /* Hidden by default, shown when items are present */
}

.fe-cart-summary {
    font-size: 0.9rem;
}

.fe-cart-total {
    display: flex;
    justify-content: space-between;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 1rem;
}

/* Discount Section */
.fe-discount-section {
    background: var(--white);
    border-radius: var(--border-radius);
    padding: 1rem;
    margin-bottom: 1rem;
    display: none;
    /* Hidden by default, shown with 2+ courses */
}

.fe-discount-section.active {
    display: block;
}

.fe-discount-section h6 {
    margin-bottom: 0.5rem;
}

.fe-discount-input {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.fe-discount-applied {
    background: var(--success-color);
    color: var(--white);
    padding: 0.5rem;
    border-radius: var(--border-radius);
    font-size: 0.85rem;
    display: none;
    align-items: center;
}

/* Checkout Actions */
.fe-checkout-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.fe-btn-proceed-checkout,
.fe-btn-continue-shopping {
    padding: 12px 24px;
    border-radius: var(--border-radius);
    font-weight: 600;
    transition: var(--transition);
    width: 100%;
}

.fe-btn-proceed-checkout {
    background: var(--primary-color);
    border: none;
    color: var(--white);
}

.fe-btn-proceed-checkout:hover {
    background: var(--primary-dark);
}

.fe-btn-continue-shopping {
    background: none;
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
}

.fe-btn-continue-shopping:hover {
    background: var(--primary-color);
    color: var(--white);
}

/* ------------------------------------------- */
/* 5. Notifications (from bkdcart.css)         */
/* ------------------------------------------- */
.fe-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--success-color);
    /* Default to success */
    color: white;
    padding: 1rem 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow-lg);
    z-index: 10000;
    transform: translateX(100%);
    /* Off-screen by default */
    transition: transform 0.3s ease, opacity 0.3s ease;
    font-size: 14px;
    /* Ensure font size is defined */
    font-weight: 500;
    opacity: 0;
}

.fe-notification.show {
    transform: translateX(0);
    opacity: 1;
}

.fe-notification.fe-warning {
    background: var(--warning-color);
}

.fe-notification.fe-error {
    background: var(--danger-color);
}

/* ------------------------------------------- */
/* 6. Animations (Prefixed from backend)       */
/* ------------------------------------------- */
@keyframes feFadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fePulse {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(244, 124, 60, 0.7);
    }

    70% {
        transform: scale(1);
        box-shadow: 0 0 0 6px rgba(244, 124, 60, 0);
    }

    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(244, 124, 60, 0);
    }
}

/* Animation for new items in cart */
@keyframes feNewNotification {
    0% {
        background-color: rgba(79, 70, 229, 0.1);
        /* light purple */
    }

    100% {
        background-color: transparent;
    }
}

.fe-cart-item.fe-new {
    animation: 1s feNewNotification;
}