/**
 * Training Catalog Pro — Frontend Styles
 *
 * All colors use CSS custom properties (--tcp-*) set dynamically
 * from plugin settings. Fully responsive, Divi-compatible.
 *
 * @package Training_Catalog_Pro
 * @since   1.0.0
 */

/* ========================================================================
   Reset & base — scoped to .tcp- prefix to avoid Divi conflicts
   ======================================================================== */

[class^="tcp-"],
[class*=" tcp-"] {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ========================================================================
   Search bar
   ======================================================================== */

.tcp-search-wrapper {
    width: 100%;
    margin-bottom: 24px;
}

.tcp-search-inner {
    position: relative;
    display: flex;
    align-items: center;
    background: var(--tcp-search-bg, #1e293b);
    border-radius: var(--tcp-search-radius, 12px);
    padding: 0 20px;
    transition: box-shadow 0.2s ease;
}

.tcp-search-inner:focus-within {
    box-shadow: 0 0 0 3px rgba(234, 88, 12, 0.3);
}

.tcp-search-icon {
    flex-shrink: 0;
    color: var(--tcp-search-placeholder, #94a3b8);
    width: 20px;
    height: 20px;
}

.tcp-search-input {
    width: 100%;
    background: transparent !important;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    color: var(--tcp-search-text, #ffffff) !important;
    font-size: 16px;
    line-height: 1.5;
    padding: 16px 12px !important;
    -webkit-appearance: none;
    appearance: none;
}

.tcp-search-input::placeholder {
    color: var(--tcp-search-placeholder, #94a3b8);
    opacity: 1;
}

.tcp-search-input::-webkit-search-cancel-button {
    display: none;
}

.tcp-search-clear {
    flex-shrink: 0;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--tcp-search-placeholder, #94a3b8);
    padding: 4px;
    border-radius: 4px;
    transition: color 0.15s, background 0.15s;
    line-height: 0;
}

.tcp-search-clear:hover {
    color: var(--tcp-search-text, #ffffff);
    background: rgba(255, 255, 255, 0.1);
}

/* ========================================================================
   Filters
   ======================================================================== */

.tcp-filters-wrapper {
    margin-bottom: 24px;
}

.tcp-filters-inner {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-start;
}

.tcp-filters--vertical .tcp-filters-inner {
    flex-direction: column;
}

.tcp-filter-group {
    position: relative;
}

/* Select */
.tcp-filter-select {
    appearance: none;
    -webkit-appearance: none;
    background: var(--tcp-card-bg, #ffffff);
    border: 1px solid var(--tcp-card-border, #e5e7eb);
    border-radius: 8px;
    padding: 10px 36px 10px 14px;
    font-size: 14px;
    color: var(--tcp-title-text, #111827);
    cursor: pointer;
    min-width: 160px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.tcp-filter-select:focus {
    outline: none;
    border-color: var(--tcp-primary, #ea580c);
    box-shadow: 0 0 0 3px rgba(234, 88, 12, 0.15);
}

/* Dropdown toggle */
.tcp-filter-dropdown-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--tcp-card-bg, #ffffff);
    border: 1px solid var(--tcp-card-border, #e5e7eb);
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 14px;
    color: var(--tcp-title-text, #111827);
    cursor: pointer;
    min-width: 160px;
    transition: border-color 0.15s, box-shadow 0.15s;
    justify-content: space-between;
}

.tcp-filter-dropdown-toggle:hover {
    border-color: var(--tcp-primary, #ea580c);
}

.tcp-filter-dropdown-toggle[aria-expanded="true"] {
    border-color: var(--tcp-primary, #ea580c);
    box-shadow: 0 0 0 3px rgba(234, 88, 12, 0.15);
}

.tcp-filter-dropdown-toggle[aria-expanded="true"] svg {
    transform: rotate(180deg);
}

.tcp-filter-dropdown-toggle svg {
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

/* Dropdown panel */
.tcp-filter-dropdown-panel {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    z-index: 50;
    background: var(--tcp-card-bg, #ffffff);
    border: 1px solid var(--tcp-card-border, #e5e7eb);
    border-radius: 10px;
    padding: 8px;
    min-width: 200px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    animation: tcpDropIn 0.15s ease-out;
}

.tcp-filter-dropdown-panel--open {
    display: block;
}

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

/* Checkbox & Radio labels */
.tcp-filter-checkbox-label,
.tcp-filter-radio-label {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 14px;
    color: var(--tcp-title-text, #111827);
    cursor: pointer;
    transition: background 0.1s;
    user-select: none;
}

.tcp-filter-checkbox-label:hover,
.tcp-filter-radio-label:hover {
    background: #f9fafb;
}

.tcp-filter-checkbox-label input,
.tcp-filter-radio-label input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.tcp-filter-checkbox-mark {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    border: 2px solid var(--tcp-card-border, #d1d5db);
    border-radius: 4px;
    position: relative;
    transition: background 0.15s, border-color 0.15s;
}

.tcp-filter-checkbox-label input:checked + .tcp-filter-checkbox-mark {
    background: var(--tcp-primary, #ea580c);
    border-color: var(--tcp-primary, #ea580c);
}

.tcp-filter-checkbox-label input:checked + .tcp-filter-checkbox-mark::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 5px;
    width: 5px;
    height: 9px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.tcp-filter-radio-mark {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    border: 2px solid var(--tcp-card-border, #d1d5db);
    border-radius: 50%;
    position: relative;
    transition: border-color 0.15s;
}

.tcp-filter-radio-label input:checked + .tcp-filter-radio-mark {
    border-color: var(--tcp-primary, #ea580c);
}

.tcp-filter-radio-label input:checked + .tcp-filter-radio-mark::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--tcp-primary, #ea580c);
}

/* Range filter */
.tcp-filter-range-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
}

.tcp-filter-range-label {
    font-size: 14px;
    color: var(--tcp-meta-text, #6b7280);
    white-space: nowrap;
}

.tcp-filter-range-inputs {
    display: flex;
    align-items: center;
    gap: 6px;
}

.tcp-filter-range-min,
.tcp-filter-range-max {
    width: 90px;
    padding: 8px 10px;
    border: 1px solid var(--tcp-card-border, #e5e7eb);
    border-radius: 6px;
    font-size: 14px;
    text-align: center;
    transition: border-color 0.15s;
}

.tcp-filter-range-min:focus,
.tcp-filter-range-max:focus {
    outline: none;
    border-color: var(--tcp-primary, #ea580c);
    box-shadow: 0 0 0 3px rgba(234, 88, 12, 0.15);
}

.tcp-filter-range-sep {
    color: var(--tcp-meta-text, #6b7280);
}

/* Clear filters button */
.tcp-filters-clear {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: transparent;
    border: none;
    color: var(--tcp-primary, #ea580c);
    font-size: 13px;
    cursor: pointer;
    padding: 10px 8px;
    border-radius: 6px;
    transition: background 0.15s;
}

.tcp-filters-clear:hover {
    background: rgba(234, 88, 12, 0.06);
}

/* Mobile filter toggle */
.tcp-filters-mobile-toggle {
    display: none;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 12px 16px;
    background: var(--tcp-card-bg, #ffffff);
    border: 1px solid var(--tcp-card-border, #e5e7eb);
    border-radius: 10px;
    font-size: 15px;
    font-weight: 500;
    color: var(--tcp-title-text, #111827);
    cursor: pointer;
}

.tcp-filters-active-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--tcp-primary, #ea580c);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
}

/* ========================================================================
   Catalog toolbar (count + sort)
   ======================================================================== */

.tcp-catalog-wrapper {
    position: relative;
}

.tcp-catalog-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.tcp-catalog-count {
    font-size: 16px;
    font-weight: 500;
    color: var(--tcp-count-text, #6b7280);
}

.tcp-catalog-sort select {
    appearance: none;
    -webkit-appearance: none;
    padding: 8px 32px 8px 12px;
    border: 1px solid var(--tcp-card-border, #e5e7eb);
    border-radius: 8px;
    font-size: 14px;
    color: var(--tcp-title-text, #111827);
    background: var(--tcp-card-bg, #ffffff);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    cursor: pointer;
}

/* ========================================================================
   Card grid
   ======================================================================== */

.tcp-catalog-grid {
    display: grid;
    gap: 24px;
}

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

/* ========================================================================
   Card
   ======================================================================== */

.tcp-card {
    display: flex;
    flex-direction: column;
    background: var(--tcp-card-bg, #ffffff);
    border: 1px solid var(--tcp-card-border, #e5e7eb);
    border-radius: var(--tcp-card-radius, 12px);
    overflow: hidden;
    transition: box-shadow 0.25s ease, transform 0.25s ease;
}

.tcp-card:hover {
    box-shadow: 0 8px 30px var(--tcp-card-hover-shadow, rgba(0,0,0,0.12));
    transform: translateY(-2px);
}

/* Card image */
.tcp-card__image {
    position: relative;
    overflow: hidden;
    aspect-ratio: 16 / 9;
    background: #f3f4f6;
}

.tcp-card__image a {
    display: block;
    width: 100%;
    height: 100%;
}

.tcp-card__img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}

.tcp-card:hover .tcp-card__img {
    transform: scale(1.04);
}

/* Card body */
.tcp-card__body {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 24px;
    gap: 12px;
}

/* Badges */
.tcp-card__badges {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tcp-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.4;
    color: var(--tcp-badge-text, #ffffff);
    white-space: nowrap;
}

/* Title */
.tcp-card__title {
    font-size: 20px !important;
    font-weight: 700 !important;
    line-height: 1.3 !important;
    color: var(--tcp-title-text, #111827) !important;
    margin: 0 !important;
    padding: 0 !important;
}

.tcp-card__title a {
    color: inherit !important;
    text-decoration: none !important;
    transition: color 0.15s;
}

.tcp-card__title a:hover {
    color: var(--tcp-primary, #ea580c) !important;
}

/* Excerpt */
.tcp-card__excerpt {
    font-size: 14px;
    line-height: 1.6;
    color: var(--tcp-desc-text, #4b5563);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin: 0;
}

/* Meta */
.tcp-card__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

.tcp-card__meta-item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 13px;
    color: var(--tcp-meta-text, #6b7280);
    white-space: nowrap;
}

.tcp-card__meta-item svg {
    flex-shrink: 0;
    opacity: 0.7;
}

/* Tags */
.tcp-card__tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tcp-tag {
    display: inline-block;
    padding: 4px 10px;
    background: var(--tcp-tag-bg, #f3f4f6);
    color: var(--tcp-tag-text, #374151);
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    border: 1px solid transparent;
    transition: border-color 0.15s;
}

.tcp-tag:hover {
    border-color: var(--tcp-card-border, #e5e7eb);
}

/* Footer */
.tcp-card__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid var(--tcp-card-border, #e5e7eb);
    gap: 12px;
}

/* Price */
.tcp-card__price {
    display: flex;
    align-items: baseline;
    gap: 4px;
    min-height: 28px;
}

.tcp-card__price-prefix {
    font-size: 13px;
    color: var(--tcp-meta-text, #6b7280);
    font-weight: 400;
}

.tcp-card__price-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--tcp-price-text, #111827);
}

.tcp-card__price-suffix {
    font-size: 14px;
    font-weight: 600;
    color: var(--tcp-price-text, #111827);
}

/* ========================================================================
   Buttons
   ======================================================================== */

.tcp-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: var(--tcp-button-radius, 8px);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: background 0.2s, box-shadow 0.2s, transform 0.1s;
    white-space: nowrap;
    line-height: 1.4;
}

.tcp-btn--primary {
    background: var(--tcp-primary, #ea580c);
    color: #ffffff !important;
}

.tcp-btn--primary:hover {
    background: var(--tcp-primary-hover, #c2410c);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(234, 88, 12, 0.3);
}

.tcp-btn--primary:active {
    transform: translateY(0);
}

.tcp-btn--outline {
    background: transparent;
    color: var(--tcp-primary, #ea580c);
    border: 1px solid var(--tcp-primary, #ea580c);
}

.tcp-btn--outline:hover {
    background: rgba(234, 88, 12, 0.06);
}

.tcp-card__btn svg {
    width: 16px;
    height: 16px;
    transition: transform 0.2s;
}

.tcp-card__btn:hover svg {
    transform: translateX(3px);
}

/* ========================================================================
   Loading, Empty state
   ======================================================================== */

.tcp-catalog-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 40px 20px;
    color: var(--tcp-meta-text, #6b7280);
    font-size: 15px;
}

.tcp-spinner {
    width: 28px;
    height: 28px;
}

.tcp-spinner-ring {
    width: 100%;
    height: 100%;
    border: 3px solid var(--tcp-card-border, #e5e7eb);
    border-top-color: var(--tcp-primary, #ea580c);
    border-radius: 50%;
    animation: tcpSpin 0.7s linear infinite;
}

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

.tcp-catalog-empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--tcp-meta-text, #6b7280);
}

.tcp-catalog-empty svg {
    margin-bottom: 16px;
    opacity: 0.4;
}

.tcp-catalog-empty p {
    font-size: 16px;
    margin-bottom: 20px;
}

/* ========================================================================
   Pagination
   ======================================================================== */

.tcp-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 32px;
    flex-wrap: wrap;
}

.tcp-page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 0 10px;
    border: 1px solid var(--tcp-card-border, #e5e7eb);
    border-radius: 8px;
    background: var(--tcp-card-bg, #ffffff);
    color: var(--tcp-title-text, #111827);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}

.tcp-page-btn:hover:not(:disabled) {
    border-color: var(--tcp-primary, #ea580c);
    color: var(--tcp-primary, #ea580c);
}

.tcp-page-btn--active {
    background: var(--tcp-primary, #ea580c) !important;
    border-color: var(--tcp-primary, #ea580c) !important;
    color: #ffffff !important;
}

.tcp-page-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.tcp-page-dots {
    padding: 0 4px;
    color: var(--tcp-meta-text, #6b7280);
}

/* Load more */
.tcp-loadmore-wrapper {
    text-align: center;
    margin-top: 32px;
}

.tcp-btn--loadmore {
    padding: 14px 40px;
    font-size: 15px;
}

/* ========================================================================
   Card animation
   ======================================================================== */

.tcp-card {
    animation: tcpCardIn 0.35s ease-out both;
}

@keyframes tcpCardIn {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.tcp-catalog-grid .tcp-card:nth-child(1) { animation-delay: 0ms; }
.tcp-catalog-grid .tcp-card:nth-child(2) { animation-delay: 60ms; }
.tcp-catalog-grid .tcp-card:nth-child(3) { animation-delay: 120ms; }
.tcp-catalog-grid .tcp-card:nth-child(4) { animation-delay: 180ms; }
.tcp-catalog-grid .tcp-card:nth-child(5) { animation-delay: 240ms; }
.tcp-catalog-grid .tcp-card:nth-child(6) { animation-delay: 300ms; }
.tcp-catalog-grid .tcp-card:nth-child(7) { animation-delay: 360ms; }
.tcp-catalog-grid .tcp-card:nth-child(8) { animation-delay: 420ms; }
.tcp-catalog-grid .tcp-card:nth-child(9) { animation-delay: 480ms; }

/* ========================================================================
   Responsive
   ======================================================================== */

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

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

    .tcp-filters-inner {
        display: none;
        flex-direction: column;
        gap: 8px;
        padding: 16px;
        background: var(--tcp-card-bg, #ffffff);
        border: 1px solid var(--tcp-card-border, #e5e7eb);
        border-radius: 12px;
        margin-top: 12px;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
    }

    .tcp-filters-inner--open {
        display: flex;
    }

    .tcp-filters-mobile-toggle {
        display: flex;
    }

    .tcp-filter-select,
    .tcp-filter-dropdown-toggle {
        width: 100%;
    }

    .tcp-filter-dropdown-panel {
        position: static;
        box-shadow: none;
        border: 1px solid var(--tcp-card-border, #e5e7eb);
        margin-top: 6px;
        animation: none;
    }

    .tcp-card__body {
        padding: 18px;
    }

    .tcp-card__title {
        font-size: 17px !important;
    }
}

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

    .tcp-catalog-toolbar {
        flex-direction: column;
        align-items: flex-start;
    }

    .tcp-card__footer {
        flex-direction: column;
        align-items: flex-start;
    }

    .tcp-card__btn {
        width: 100%;
        justify-content: center;
    }

    .tcp-filter-range-wrapper {
        flex-direction: column;
        align-items: stretch;
    }
}
