/**
 * Smidl Cart Grouping - Unified Cart Design
 * Plugin: smidl-bulk-variation
 *
 * Kurzy se zobrazují jako řádky uvnitř WooCommerce cart tabulky,
 * takže tvoří jeden vizuální seznam s běžnými produkty.
 */

/* =============================================
   CSS Variables
   ============================================= */
:root {
    --smidl-cart-primary: #c9a227;
    --smidl-cart-primary-dark: #a68620;
    --smidl-cart-text: #1a1a1a;
    --smidl-cart-text-muted: #666666;
    --smidl-cart-bg: #ffffff;
    --smidl-cart-bg-light: #f8f9fa;
    --smidl-cart-border: #e0e0e0;
    --smidl-cart-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    --smidl-cart-radius: 8px;
}

/* =============================================
   Hide WooCommerce thead when only courses
   ============================================= */
body.smidl-courses-only .woocommerce table.shop_table_responsive thead,
body.smidl-courses-only .woocommerce-page table.shop_table_responsive thead,
body.smidl-courses-only table.shop_table.cart thead {
    display: none !important;
}

/* =============================================
   Course Row inside WooCommerce Cart Table
   ============================================= */
.smidl-cart-row {
    border-bottom: 1px solid var(--smidl-cart-border);
}

/* Course row product-name - use theme's flex layout via .product-name-inner */
.smidl-cart-row .product-name .product-info {
    display: flex !important;
    flex-direction: column !important;
    gap: 2px !important;
}

.smidl-cart-row .product-name .product-info > a {
    font-weight: 500;
}

/* Subtitle - date range */
.smidl-cart-course__subtitle {
    display: block;
    font-size: 0.8125rem;
    color: var(--smidl-cart-text-muted);
    line-height: 1.4;
    margin-top: 2px;
}

/* Lessons info container */
.smidl-cart-course__lessons-info {
    display: block;
    margin-top: 6px;
}

/* Toggle button - filled pill with primary color */
button.smidl-cart-course__toggle,
.smidl-cart-course__toggle {
    display: inline-flex !important;
    align-items: center !important;
    gap: 5px !important;
    padding: 4px 12px !important;
    margin: 0 !important;
    border: 1px solid var(--smidl-cart-primary) !important;
    border-radius: 14px !important;
    background: var(--smidl-cart-primary) !important;
    color: #fff !important;
    cursor: pointer;
    font-size: 0.75rem !important;
    font-weight: 500 !important;
    line-height: 1.4 !important;
    width: auto !important;
    height: auto !important;
    min-width: 0 !important;
    min-height: 0 !important;
    max-width: none !important;
    max-height: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
    text-decoration: none !important;
    transition: all 0.2s ease;
    letter-spacing: 0.01em !important;
}

button.smidl-cart-course__toggle:hover,
.smidl-cart-course__toggle:hover {
    color: #fff !important;
    background: var(--smidl-cart-primary-dark) !important;
    border-color: var(--smidl-cart-primary-dark) !important;
}

button.smidl-cart-course__toggle[aria-expanded="true"],
.smidl-cart-course__toggle[aria-expanded="true"] {
    color: #fff !important;
    background: var(--smidl-cart-primary-dark) !important;
    border-color: var(--smidl-cart-primary-dark) !important;
}

button.smidl-cart-course__toggle[aria-expanded="true"] .smidl-cart-course__toggle-icon,
.smidl-cart-course__toggle[aria-expanded="true"] .smidl-cart-course__toggle-icon {
    transform: rotate(180deg);
}

.smidl-cart-course__toggle-icon {
    width: 12px !important;
    height: 12px !important;
    min-width: 12px !important;
    color: currentColor;
    transition: transform 0.2s ease;
    display: inline-block !important;
    flex-shrink: 0;
    vertical-align: middle;
}

/* Lessons count text inside toggle */
.smidl-cart-course__lessons-count-text {
    font-size: 0.8125rem;
    font-weight: 500;
}

/* Course quantity input - match WooCommerce style */
.smidl-cart-row .product-quantity .smidl-course-qty {
    width: 3.631em;
    text-align: center;
}

/* Hide lesson hidden qty inputs */
.smidl-cart-row .product-quantity input.smidl-course-lesson-qty {
    display: none;
}

/* =============================================
   Lessons Detail Row (expandable)
   ============================================= */
.smidl-cart-row--lessons,
.smidl-order-course-row--lessons {
    background: var(--smidl-cart-bg-light);
}

/* Override Choreo theme border between order table rows */
.shop_table_order_details table.shop_table tr.smidl-order-course-row--lessons,
.smidl-order-course-row--lessons {
    border-top: none !important;
}

.smidl-cart-row--lessons > td,
.smidl-order-course-row--lessons > td {
    padding: 0 !important;
    border-top: none !important;
}

/* Lessons cell - override Choreo theme styles */
.smidl-cart-course__lessons-cell {
    padding: 0 !important;
    text-align: left !important;
    width: 100% !important;
}

/* High specificity override for Choreo theme order details */
.shop_table_order_details table.shop_table td.smidl-cart-course__lessons-cell,
.shop_table_order_details .smidl-cart-course__lessons-cell {
    padding: 0 !important;
    text-align: left !important;
}

/* Ensure lessons row spans full table width */
.smidl-order-course-row--lessons > td[colspan],
.smidl-cart-row--lessons > td[colspan] {
    width: 100% !important;
    padding: 0 !important;
}

.smidl-cart-course__lessons {
    padding: 0.5rem 1rem;
    border-top: 1px solid var(--smidl-cart-border);
}

.smidl-cart-course__lessons-table {
    width: 100% !important;
    border-collapse: collapse;
    font-size: 0.8125rem;
    table-layout: auto;
}

/* Reset all cells - override Choreo theme's .shop_table_order_details td { text-align: right; padding: 25px 0 } */
.smidl-cart-course__lessons-table th,
.smidl-cart-course__lessons-table td {
    padding: 0.35rem 0.5rem !important;
    border-bottom: 1px solid #eee !important;
    border-top: none !important;
    background: transparent !important;
    text-align: left !important;
    font-size: 0.8125rem !important;
    line-height: 1.4 !important;
}

/* Extra specificity for Choreo theme order details page */
.shop_table_order_details table.shop_table .smidl-cart-course__lessons-table th,
.shop_table_order_details table.shop_table .smidl-cart-course__lessons-table td {
    padding: 0.35rem 0.5rem !important;
    text-align: left !important;
    font-size: 0.8125rem !important;
    border-top: none !important;
}

.smidl-cart-course__lessons-table thead th {
    color: var(--smidl-cart-text-muted) !important;
    border-bottom-color: var(--smidl-cart-border) !important;
    font-weight: 500;
    font-size: 0.6875rem !important;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.shop_table_order_details table.shop_table .smidl-cart-course__lessons-table thead th {
    font-size: 0.6875rem !important;
}

.smidl-cart-course__lessons-table tbody td {
    color: var(--smidl-cart-text);
}

.smidl-cart-course__lessons-table tbody tr:last-child td {
    border-bottom: none !important;
}

.smidl-cart-course__lesson-name {
    font-weight: 500;
}

.smidl-cart-course__lesson-date {
    color: var(--smidl-cart-text-muted);
}

.smidl-cart-course__lesson-price {
    font-weight: 500;
    white-space: nowrap;
    text-align: right !important;
}

.shop_table_order_details table.shop_table .smidl-cart-course__lesson-price {
    text-align: right !important;
}

.smidl-cart-course__lesson-remove .remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    color: #bbb;
    font-size: 1.125rem;
    line-height: 1;
    text-decoration: none;
    transition: all 0.2s ease;
}

.smidl-cart-course__lesson-remove .remove:hover {
    background: #fee;
    color: #c62828;
}

/* =============================================
   Checkout & Order - Course detail text
   ============================================= */
.smidl-checkout-course-row .product-name,
.smidl-order-course-row .product-name {
    line-height: 1.4;
}

.smidl-checkout-course-detail {
    display: block;
    font-size: 0.8125rem;
    color: var(--smidl-cart-text-muted);
    font-weight: 400;
    margin-top: 2px;
}

/* Mini cart - zmenšit mezeru mezi názvem a detailem kurzu */
.woocommerce-mini-cart-item .smidl-checkout-course-detail {
    margin-top: -2px;
    line-height: 1.3;
}

/* Order page - lessons info toggle */
.smidl-order-course__lessons-info {
    display: block !important;
    margin-top: 6px;
}

/* Order & Cart lessons rows - display when .is-open (JS removes inline display:none) */
.smidl-cart-row--lessons.is-open,
.smidl-order-course-row--lessons.is-open {
    display: table-row !important;
}

/* =============================================
   Responsive - Mobile
   ============================================= */
@media (max-width: 640px) {
    /* ---- Cart course row ---- */
    /* Course row now uses same 6-column structure as WooCommerce,
       so theme's responsive layout (data-title labels etc.) works natively.
       We only need to style our custom elements. */

    .smidl-cart-row .product-name .product-name-inner {
        flex-wrap: wrap;
    }

    /* Lessons row hidden TD with colspan - no padding */
    .smidl-cart-row td[colspan] {
        padding: 0 !important;
    }

    /* Cart lessons row - block layout only when open (JS adds .is-open class) */
    .smidl-cart-row--lessons.is-open {
        display: block !important;
        width: 100% !important;
    }

    .smidl-cart-row--lessons.is-open > td[colspan] {
        display: block !important;
        width: 100% !important;
        padding: 0 !important;
    }

    /* ---- Lessons detail table ---- */
    .smidl-cart-course__lessons {
        padding: 0.5rem 0.75rem;
    }

    /* Prevent WooCommerce/theme responsive data-title labels on lesson cells */
    .smidl-cart-course__lessons-table td::before,
    .smidl-cart-course__lessons-table th::before {
        display: none !important;
        content: none !important;
    }

    /* Keep lessons table as real table on mobile (not stacked) */
    .smidl-cart-course__lessons-table,
    .smidl-cart-course__lessons-table thead,
    .smidl-cart-course__lessons-table tbody,
    .smidl-cart-course__lessons-table tr,
    .smidl-cart-course__lessons-table th,
    .smidl-cart-course__lessons-table td {
        display: revert !important;
    }

    .smidl-cart-course__lessons-table {
        width: 100% !important;
        table-layout: auto !important;
    }

    .smidl-cart-course__lessons-table thead {
        display: table-header-group !important;
    }

    .smidl-cart-course__lessons-table th,
    .smidl-cart-course__lessons-table td {
        padding: 0.3rem 0.4rem !important;
        font-size: 0.75rem !important;
    }

    .smidl-cart-course__lessons-table thead th {
        font-size: 0.625rem !important;
    }

    .smidl-cart-course__lesson-remove .remove {
        width: 18px;
        height: 18px;
        font-size: 0.875rem;
    }

    /* ---- Checkout & Mini cart course detail ---- */
    .smidl-checkout-course-detail {
        font-size: 0.75rem;
    }

    /* ---- Order page course rows ---- */
    .smidl-order-course-row > td.product-total {
        font-weight: 600;
    }

    /* Order lessons row - keep table-row display (not block) so it inherits full table width */
    .smidl-order-course-row--lessons.is-open {
        display: table-row !important;
        width: 100% !important;
    }

    .smidl-order-course-row--lessons.is-open > td[colspan] {
        display: table-cell !important;
        width: 100% !important;
        padding: 0 !important;
    }

}

/* =============================================
   Responsive - Very Small Screens
   ============================================= */
@media (max-width: 380px) {
    .smidl-cart-course__lessons {
        padding: 0.375rem 0.5rem;
    }
}
