/* ================================================
   Course Manager - Frontend Styles
   ================================================ */

/* === FILTERS === */
.cm-filters {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
    margin-bottom: 30px;
    padding: 20px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
}

.cm-filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.cm-filter-group label {
    font-weight: 600;
    font-size: 14px;
    color: #374151;
}

.cm-filter-select {
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    background: #fff;
    min-width: 200px;
}

/* === BUTTONS === */
.cm-btn {
    display: inline-block;
    padding: 10px 24px;
    font-size: 14px;
    font-weight: 600;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: all 0.2s ease;
    line-height: 1.4;
}

.cm-btn-primary {
    background: #166534;
    color: #fff;
}

.cm-btn-primary:hover {
    background: #14532d;
    color: #fff;
}

.cm-btn-secondary {
    background: #e5e7eb;
    color: #374151;
}

.cm-btn-secondary:hover {
    background: #d1d5db;
    color: #374151;
}

.cm-btn-maps {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #166534;
    color: #fff;
    padding: 8px 18px;
    border-radius: 20px;
    font-size: 13px;
}

.cm-btn-maps:hover {
    background: #14532d;
    color: #fff;
}

.cm-btn-large {
    width: 100%;
    padding: 14px 24px;
    font-size: 16px;
    border-radius: 8px;
}

/* === COURSE GRID === */
.cm-course-grid {
    display: grid;
    gap: 24px;
}

.cm-cols-4 { grid-template-columns: repeat(4, 1fr); }
.cm-cols-3 { grid-template-columns: repeat(3, 1fr); }
.cm-cols-2 { grid-template-columns: repeat(2, 1fr); }

@media (max-width: 1024px) {
    .cm-cols-4 { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 768px) {
    .cm-cols-4,
    .cm-cols-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 480px) {
    .cm-cols-4,
    .cm-cols-3,
    .cm-cols-2 { grid-template-columns: 1fr; }

    .cm-filters {
        flex-direction: column;
        align-items: stretch;
    }

    .cm-filter-select { min-width: auto; width: 100%; }
}

/* === COURSE CARD === */
.cm-course-card {
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    position: relative;
    display: flex;
    flex-direction: column;
}

.cm-course-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

.cm-course-card.cm-sold-out {
    opacity: 0.8;
}

.cm-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 2;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.cm-badge-soldout {
    background: #ef4444;
    color: #fff;
}

/* Card Image */
.cm-card-image {
    position: relative;
    aspect-ratio: 16 / 10;
    overflow: hidden;
    background: linear-gradient(135deg, #0d9488, #166534);
}

.cm-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.cm-placeholder-img {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #0d9488, #166534);
}

.cm-date-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    background: #166534;
    color: #fff;
    border-radius: 8px;
    padding: 6px 10px;
    text-align: center;
    line-height: 1.2;
    z-index: 2;
    display: flex;
    flex-direction: column;
}

.cm-date-day {
    font-size: 20px;
    font-weight: 700;
    display: block;
}

.cm-date-month {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Card Content */
.cm-card-content {
    padding: 16px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.cm-card-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 8px;
    line-height: 1.4;
}

.cm-card-title a {
    color: #1f2937;
    text-decoration: none;
}

.cm-card-title a:hover {
    color: #166534;
}

.cm-card-price {
    color: #166534;
    font-size: 14px;
    margin-bottom: 6px;
}

.cm-card-price strong {
    font-size: 16px;
}

.cm-card-venue {
    color: #6b7280;
    font-size: 13px;
    margin-bottom: 6px;
}

.cm-card-date {
    display: flex;
    align-items: center;
    gap: 5px;
    color: #6b7280;
    font-size: 13px;
    margin-bottom: 12px;
}

.cm-card-date svg {
    flex-shrink: 0;
}

.cm-book-btn {
    margin-top: auto;
    font-size: 13px;
    padding: 8px 18px;
}

/* === SINGLE COURSE PAGE === */
.cm-single-course {
    max-width: 1100px;
    margin: 0 auto;
}

.cm-course-header {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 40px;
    margin-bottom: 30px;
}

@media (max-width: 768px) {
    .cm-course-header {
        grid-template-columns: 1fr;
    }
}

.cm-course-title {
    font-size: 28px;
    font-weight: 700;
    color: #1f2937;
    margin: 0 0 20px;
}

.cm-course-description {
    color: #4b5563;
    line-height: 1.7;
    margin-bottom: 24px;
}

.cm-course-details-grid {
    display: grid;
    gap: 16px;
}

.cm-detail-box {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 16px;
}

.cm-detail-box h4 {
    font-size: 15px;
    font-weight: 600;
    color: #374151;
    margin: 0 0 10px;
}

.cm-status-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    background: #22c55e;
    border-radius: 50%;
    margin-right: 6px;
}

.cm-course-price-large strong {
    color: #166534;
    font-size: 18px;
}

.cm-available {
    color: #16a34a;
    font-size: 13px;
}

/* Sidebar */
.cm-course-sidebar {
    position: sticky;
    top: 30px;
    align-self: start;
}

.cm-course-image {
    margin-bottom: 20px;
    border-radius: 12px;
    overflow: hidden;
}

.cm-course-image img {
    width: 100%;
    height: auto;
    display: block;
}

.cm-sold-out-msg {
    text-align: center;
    color: #dc2626;
    font-weight: 600;
    padding: 15px;
    background: #fef2f2;
    border-radius: 8px;
}

/* === MODAL === */
.cm-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.cm-modal-content {
    background: #fff;
    border-radius: 16px;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    padding: 30px;
}

.cm-modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: #9ca3af;
    line-height: 1;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
}

.cm-modal-close:hover {
    background: #f3f4f6;
    color: #374151;
}

/* === REGISTRATION FORM === */
.cm-registration-form h3 {
    font-size: 20px;
    font-weight: 700;
    margin: 0 0 20px;
    color: #1f2937;
}

.cm-form-field {
    margin-bottom: 16px;
}

.cm-form-field label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 6px;
}

.cm-required {
    color: #dc2626;
}

.cm-form-field input[type="text"],
.cm-form-field input[type="email"],
.cm-form-field input[type="number"],
.cm-form-field input[type="date"],
.cm-form-field select,
.cm-form-field textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.cm-form-field input:focus,
.cm-form-field select:focus,
.cm-form-field textarea:focus {
    outline: none;
    border-color: #166534;
    box-shadow: 0 0 0 3px rgba(22, 101, 52, 0.1);
}

.cm-checkbox-label,
.cm-radio-label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    font-size: 14px;
    cursor: pointer;
}

.cm-form-legal {
    margin: 20px 0;
    padding: 12px;
    background: #f9fafb;
    border-radius: 8px;
}

.cm-form-legal a {
    color: #166534;
    text-decoration: underline;
}

.cm-submit-registration {
    width: 100%;
    margin-top: 10px;
}

/* === ADD-ONS (FRONTEND) === */
.cm-course-addons {
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid #e5e7eb;
}

.cm-course-addons h4 {
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 12px;
}

.cm-addon-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: border-color 0.2s;
}

.cm-addon-item:hover {
    border-color: #166534;
}

.cm-addon-name {
    flex: 1;
    font-size: 14px;
}

.cm-addon-price {
    font-weight: 600;
    color: #166534;
    font-size: 14px;
}

/* === MAP POPUP === */
.cm-map-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 99998;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.cm-map-popup-content {
    background: #fff;
    border-radius: 16px;
    width: 100%;
    max-width: 700px;
    padding: 25px;
    position: relative;
}

.cm-map-close {
    position: absolute;
    top: 10px;
    right: 15px;
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: #9ca3af;
}

.cm-map-popup-content h3 {
    margin: 0 0 5px;
}

.cm-map-popup-content iframe {
    border-radius: 8px;
    margin-top: 10px;
}

/* === PAGINATION === */
.cm-pagination {
    margin: 30px 0;
    text-align: center;
}

.cm-pagination .page-numbers {
    display: inline-block;
    padding: 8px 14px;
    margin: 0 3px;
    border-radius: 6px;
    text-decoration: none;
    background: #fff;
    border: 1px solid #d1d5db;
    color: #374151;
}

.cm-pagination .page-numbers.current {
    background: #166534;
    color: #fff;
    border-color: #166534;
}

.cm-no-courses {
    text-align: center;
    color: #6b7280;
    padding: 40px;
    font-size: 16px;
}

/* === LOADING STATE === */
.cm-loading {
    text-align: center;
    padding: 30px;
}

.cm-loading::after {
    content: '';
    display: inline-block;
    width: 30px;
    height: 30px;
    border: 3px solid #e5e7eb;
    border-top-color: #166534;
    border-radius: 50%;
    animation: cm-spin 0.6s linear infinite;
}

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

/* === FORM MESSAGES === */
.cm-message {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 15px;
    font-size: 14px;
}

.cm-message-error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.cm-message-success {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}

/* Self-paced course access panel (v1.1.0) */
.cm-access-panel {
    margin: 24px 0;
    padding: 20px 24px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    background: #fafafa;
}
.cm-access-panel h3 { margin-top: 0; }
.cm-access-form input[type="password"] {
    padding: 8px 10px;
    border: 1px solid #ccc;
    border-radius: 6px;
    margin-right: 8px;
    min-width: 220px;
}
.cm-access-error { color: #b32d2e; margin-top: 8px; }
.cm-access-unlocked { font-weight: 600; }

/* Single course page layout (v1.7.2) */
.cm-single-course { max-width: 1100px; margin: 0 auto; }
.cm-course-top {
    display: flex;
    gap: 32px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 28px;
}
.cm-course-top-main { flex: 1 1 380px; min-width: 280px; }
.cm-course-top .cm-course-title { margin: 0; font-size: 2rem; line-height: 1.2; }
.cm-course-top-image { flex: 0 1 380px; }
.cm-course-top-image img { width: 100%; height: auto; border-radius: 10px; display: block; }
.cm-course-details-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 28px;
}
.cm-course-details-grid .cm-detail-box {
    background: #f7f7f8;
    border: 1px solid #e6e6e8;
    border-radius: 8px;
    padding: 16px 18px;
}
.cm-course-details-grid .cm-detail-box h4 { margin: 0 0 10px; }
.cm-course-description { margin: 0 0 28px; }
.cm-course-book { margin: 8px 0 4px; }
.cm-course-book .cm-btn-large { font-size: 1.05rem; padding: 12px 28px; }
@media (max-width: 782px) {
    .cm-course-details-grid { grid-template-columns: 1fr; }
    .cm-course-top { gap: 20px; }
    .cm-course-top-image { flex-basis: 100%; }
}

/* Mobile cart/checkout fix for bare themes (e.g. Hello Elementor) — v1.9.6
   Forces the cart & checkout to REFLOW (stack) on phones instead of running
   off the screen. No clipping — content stays reachable. */
@media (max-width: 768px) {

    /* --- Cart table: stack each row so nothing is cut off --- */
    .woocommerce table.shop_table_responsive thead,
    .woocommerce-cart table.cart thead {
        display: none;
    }
    .woocommerce table.shop_table_responsive tbody tr,
    .woocommerce-cart table.cart tbody tr {
        display: block;
        width: 100%;
        margin: 0 0 16px;
        padding: 10px 0;
        border-bottom: 2px solid #eaeaea;
    }
    .woocommerce table.shop_table_responsive tbody td,
    .woocommerce-cart table.cart tbody td {
        display: block;
        width: 100% !important;
        text-align: right !important;
        padding: 8px 4px !important;
        border: 0 !important;
        box-sizing: border-box;
    }
    .woocommerce table.shop_table_responsive tbody td::before,
    .woocommerce-cart table.cart tbody td::before {
        content: attr(data-title);
        float: left;
        font-weight: 600;
        text-align: left;
        padding-right: 10px;
    }
    /* Remove/thumbnail cells shouldn't have a label or take a full row awkwardly */
    .woocommerce-cart table.cart td.product-remove::before,
    .woocommerce-cart table.cart td.product-thumbnail::before {
        content: "";
    }
    .woocommerce-cart table.cart td.product-thumbnail img {
        max-width: 80px;
        display: inline-block;
    }
    .woocommerce-cart table.cart td.actions {
        text-align: left !important;
    }
    .woocommerce-cart table.cart td.actions .coupon input,
    .woocommerce-cart table.cart td.actions .button {
        width: 100% !important;
        margin: 4px 0 !important;
        box-sizing: border-box;
    }

    /* --- Checkout: single column, full-width fields --- */
    .woocommerce .col2-set,
    .woocommerce .col2-set .col-1,
    .woocommerce .col2-set .col-2,
    #customer_details.col2-set,
    #customer_details .col-1,
    #customer_details .col-2 {
        width: 100% !important;
        max-width: 100% !important;
        float: none !important;
        margin: 0 !important;
    }
    .woocommerce form .form-row,
    .woocommerce-checkout .form-row {
        width: 100% !important;
        float: none !important;
        box-sizing: border-box !important;
    }
    .woocommerce .input-text,
    .woocommerce input,
    .woocommerce select,
    .woocommerce textarea {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

    /* Checkout order-review table: stack the same way */
    .woocommerce-checkout-review-order-table thead { display: none; }
    .woocommerce-checkout-review-order-table tr { display: block; width: 100%; }
    .woocommerce-checkout-review-order-table td,
    .woocommerce-checkout-review-order-table th {
        display: block;
        width: 100% !important;
        text-align: right !important;
        box-sizing: border-box;
    }
}
