/**
 * YOOAdmin Extensions Store
 * Professional extension cards with license tags
 * 
 * @package YOOAdmin_Extended
 * @since 2.0.0
 */

/* ========== Variant Switcher ========== */
.yp-ext-version-wrapper {
    position: relative;
    display: flex !important;
    align-items: center;
    gap: 8px;
}

.yp-ext-title-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 8px;
}

.yp-ext-title {
    margin: 0;
    flex: 1;
}

.yp-variant-switcher {
    position: relative;
    display: inline-block;
    flex-shrink: 0;
}

.yp-variant-toggle {
    background: transparent;
    border: none;
    padding: 4px 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    min-width: 24px;
    height: 24px;
	margin: 0 12px 0 0;
}

.yp-variant-toggle:hover {
    background: transparent;
}

.yp-variant-toggle .dashicons {
    font-size: 16px;
    font-weight: 600;
    height: 16px;
    color: var(--yp-text);
    padding: 0 5px 0 0;
}

.yp-variant-dropdown {
    position: absolute;
    top: 100%;
    right: 22px;
    left: auto;
    margin-top: 4px;
    background: #fff;
    border: 1px solid #dcdcde;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    min-width: 200px;
    z-index: 1000;
    overflow: hidden;
}

/* Dropdown in popup - different positioning */
.yp-ext-popup .yp-variant-dropdown {
    right: -102px;
    left: auto;
    min-width: 250px;
}

.yp-variant-option {
    padding: 10px 12px;
    cursor: pointer;
    transition: background 0.2s ease;
    border-bottom: 1px solid #f0f0f1;
    font-size: 13px;
    color: var(--yp-text);
}

.yp-variant-option:last-child {
    border-bottom: none;
}

.yp-variant-option:hover {
    background: #f6f7f7;
}

.yp-variant-option.selected {
    background: #fff9f0;
    color: #eda934;
    font-weight: 600;
}

.yp-variant-option.locked {
    color: #a7aaad;
    cursor: not-allowed;
    opacity: 0.7;
}

.yp-variant-option.locked:hover {
    background: #fff;
}

.yp-variant-option .dashicons {
    margin-right: 4px;
    vertical-align: middle;
}

/* Variant switcher in popup */
.yp-ext-popup-meta .yp-ext-version-wrapper {
    display: inline-flex !important;
    align-items: center;
    gap: 8px;
}

.yp-ext-popup-meta .yp-variant-switcher {
    display: inline-block;
    vertical-align: middle;
}

/* ========== Store Header ========== */
.yp-store-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid #dcdcde;
}

.yp-store-header-content {
    flex: 1;
}

.yp-store-title {
    font-size: 28px;
    font-weight: 600;
    color: var(--yp-text);
    margin: 0 0 8px 0;
    line-height: 1.3;
    display: flex;
    align-items: center;
    gap: 10px;
}

.yp-store-title .dashicons {
    font-size: 32px;
    color: #2271b1;
}

.yp-store-subtitle {
    font-size: 14px;
    color: var(--yp-text);
    margin: 0;
    line-height: 1.6;
	padding: 0 0 0 35px;
}

.yp-license-link {
    color: #2271b1;
    text-decoration: none;
    font-weight: 600;
    margin-left: 4px;
}

.yp-license-link:hover {
    color: #135e96;
    text-decoration: underline;
}

/* ========== Toolbar ========== */
.yp-store-toolbar {
    display: flex;
    gap: 10px;
    align-items: center;
}

.yp-store-search {
    position: relative;
    width: 250px;
}

.yp-store-search .dashicons {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--yp-text);
    font-size: 18px;
    z-index: 1;
    pointer-events: none;
}

.yp-store-search input {
    width: 100%;
    padding: 8px 12px 8px 36px;
    border: 1px solid #dcdcde;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
    box-sizing: border-box;
}

.yp-store-search input:hover {
    border-color: #8c8f94;
}

.yp-store-search input:focus {
    border-color: var(--yooadmin-primary, #EFB54D);
    outline: none;
    box-shadow: 0 0 0 1px var(--yooadmin-primary, #EFB54D);
}

.yp-store-toolbar .button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    height: auto;
}

/* ========== Old Toolbar (Remove) ========== */
.yp-extensions-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 20px 0;
    padding: 0 0 15px 0;
    border-bottom: 2px solid #e0e0e0;
}

.yp-extensions-toolbar h2 {
    margin: 0;
    font-size: 24px;
    font-weight: 600;
    color: var(--yp-text);
}

.yp-extensions-toolbar .button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* ========== Grid Layout ========== */
.yp-extensions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

/* ========== Extension Card ========== */
.yp-extension-card {
    background: #fff;
    border: 1px solid #dcdcde;
    border-radius: 4px;
    padding: 0;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

.yp-extension-card:hover {
    border-color: #999;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* ========== Card Header ========== */
.yp-ext-header {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
    margin-bottom: 12px;
    position: relative;
}

.yp-ext-icon {
    width: 100%;
    height: 180px;
    object-fit: cover;
    border-radius: 4px 4px 0 0;
    background: #f7f7f7;
    margin: 0 0 12px 0;
    flex-shrink: 0;
}

.yp-ext-info {
    width: 100%;
    padding: 0 16px;
}

.yp-ext-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--yp-text);
    margin: 0 0 3px 0;
    line-height: 1.4;
}

.yp-ext-author {
    font-size: 12px;
    color: var(--yp-text);
    margin: 0 0 6px 0;
    font-weight: 400;
}

.yp-ext-rating {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px 16px 12px 16px;
}

.yp-ext-rating .stars {
    color: #ffa500;
    font-size: 17px;
    letter-spacing: 1px;
}

.yp-ext-rating .rating-count {
    font-size: 12px;
    color: var(--yp-text);
}

/* ========== License Tags ========== */
.yp-ext-tags {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    z-index: 10;
}

.yp-ext-tag {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 3px 8px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

/* Free Tag */
.yp-ext-tag.tag-free {
    background: #e7f5ff;
    color: #1971c2;
}

/* Basic Tag */
.yp-ext-tag.tag-basic {
    background: #fff3e0;
    color: #e65100;
}

/* Premium Tag */
.yp-ext-tag.tag-premium {
    background: #f3e5f5;
    color: #6a1b9a;
}

/* PRO Available Tag */
.yp-ext-tag.tag-pro-available {
    background: #737070;
    color: #fff;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.yp-ext-tag.tag-pro-available:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px #eda9344f;
}

/* Client Tag */
.yp-ext-tag.tag-client {
    background: #fce4ec;
    color: #c2185b;
}

/* Included with License Tag */
.yp-ext-tag.tag-included {
    background: #e8f5e9;
    color: #2e7d32;
}

/* Not Included Tag */
.yp-ext-tag.tag-not-included {
    background: #ffebee;
    color: #c62828;
}

/* Price Tag */
.yp-ext-tag.tag-price {
    background: #fff9c4;
    color: #f57f17;
}

/* PRO Badge */
.yp-ext-tag.tag-pro {
    background: #2271b1;
    color: #fff;
    font-weight: 700;
}

/* ========== Description ========== */
.yp-ext-description {
    color: #50575e;
    font-size: 13px;
    line-height: 1.5;
    margin-bottom: 10px;
    padding: 0 16px;
    min-height: 36px;
    max-height: 58px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    text-align: left;
    font-weight: 400;
}

/* ========== Meta Info ========== */
.yp-ext-meta {
    display: flex;
    gap: 16px;
    padding: 9px 0 0 7px;
    border-top: 1px solid #dcdcde;
    font-size: 13px;
    color: var(--yp-text);
    justify-content: center;
}

.yp-ext-meta-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.yp-ext-meta-item .dashicons {
    font-size: 19px;
    color: var(--yp-text);
}

/* ========== Actions ========== */
.yp-ext-actions {
    margin-top: auto;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    padding: 0 16px 16px 16px;
}

/* View Details - Full width in separate row when Uninstall or Update button exists */
.yp-ext-actions .button-danger ~ .yp-ext-details,
.yp-ext-actions .button-update ~ .yp-ext-details {
    flex: 1 1 100%;
    text-align: center;
    order: 10;
    margin-top: 0;
}

.yp-ext-actions .button {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 1px 16px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 4px;
    transition: all 0.2s ease;
    text-decoration: none;
    overflow: visible;
    position: relative;
}

.yp-ext-actions .button .spinner {
    float: none;
    margin: 0;
    vertical-align: middle;
    display: inline-block;
}

.yp-ext-actions .button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.yp-ext-actions .button:not(:disabled):hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

/* Install Button */
.yp-ext-actions .button-primary {
    background: var(--yooadmin-primary, #eda934);
    border-color: var(--yooadmin-primary, #eda934);
    color: #fff;
}

.yp-ext-actions .button-primary:hover {
    background: var(--yooadmin-primary-dark, #d88a2f);
    border-color: var(--yooadmin-primary-dark, #d88a2f);
}

/* Activate Button */
.yp-ext-actions .button-activate {
    border-color: #2e7d32;
    color: #2e7d32;
}

.yp-ext-actions .button-activate:hover {
    background: var(--yooadmin-primary-dark, #d88a2f);
    border-color: var(--yooadmin-primary-dark, #d88a2f);
}

/* Deactivate Button */
.yp-ext-actions .button-secondary {
    background: #fff;
    border-color: #ddd;
    color: #555;
}

.yp-ext-actions .button-secondary:hover {
    background: #f7f7f7;
    border-color: #999;
}

/* Get Free License Button */
.yp-ext-actions .button-get-license {
    background: #f0f0f1;
    border-color: #c3c4c7;
    color: #2c3338;
    font-weight: 600;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    padding: 8px 16px;
    border-radius: 4px;
}

.yp-ext-actions .button-get-license:hover {
    background: #f6f7f7;
    border-color: #8c8f94;
    color: var(--yp-text);
}

.yp-ext-actions .button-get-license:focus {
    background: #f6f7f7;
    border-color: #2271b1;
    color: var(--yp-text);
    box-shadow: 0 0 0 1px #fff, 0 0 0 3px #2271b1;
}

.yp-ext-actions .button-get-license::before {
    content: "🔑";
    margin-right: 6px;
}

/* ========== Loading State ========== */
.yp-extensions-loading {
    text-align: center;
    padding: 60px 20px;
}

.yp-extensions-loading .spinner {
    float: none;
    margin: 0 auto 15px;
}

/* ========== Empty State ========== */
.yp-extensions-empty {
    text-align: center;
    padding: 60px 20px;
    color: #757575;
}

.yp-extensions-empty .dashicons {
    font-size: 64px;
    width: 64px;
    height: 64px;
    color: #ddd;
    margin-bottom: 15px;
}

.yp-extensions-empty h3 {
    font-size: 18px;
    color: #555;
    margin: 0 0 8px 0;
}

.yp-extensions-empty p {
    font-size: 14px;
    color: #757575;
    margin: 0;
}

/* ========== Responsive ========== */
@media (max-width: 1200px) {
    .yp-extensions-grid {
        grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    }
}

@media (max-width: 782px) {
    /* Store Header */
    .yp-store-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
        margin-bottom: 20px;
        padding-bottom: 16px;
    }
    
    .yp-store-title {
        font-size: 22px;
    }
    
    .yp-store-title .dashicons {
        font-size: 28px;
    }
    
    .yp-store-subtitle {
        font-size: 13px;
        padding: 0;
    }
    
    /* Toolbar */
    .yp-store-toolbar {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    
    .yp-store-search {
        width: 100%;
    }
    
    .yp-store-toolbar .button {
        width: 100%;
        justify-content: center;
    }
    
    /* Extensions Grid */
    .yp-extensions-grid {
        grid-template-columns: 1fr;
    }
    
    /* Extensions Toolbar */
    .yp-extensions-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    
    .yp-extensions-toolbar .button {
        width: 100%;
        justify-content: center;
    }
}
