/**
 * ACT Countries Frontend Styles
 * Modern, responsive design for country display
 */

/* CSS Reset for Plugin Scope */
.act-countries-display * {
    box-sizing: border-box;
}

.act-countries-display a {
    text-decoration: none;
}

.act-countries-display img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Main Container */
.act-countries-display {
    clear: both;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 20px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    background-color: #f6f2fe;
    min-height: 100vh;
}

/* Header Section */
.act-countries-header {
    text-align: center;
    margin-bottom: 48px;
    position: relative;
}

.act-countries-title {
    font-size: 48px;
    font-weight: 900;
    margin: 0 0 16px 0;
    background: linear-gradient(135deg, var(--act-branding-color, #2f1667) 0%, var(--act-branding-color-hover, #1f0e47) 50%, var(--act-branding-color, #2f1667) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.1;
    letter-spacing: -1px;
    animation: gradient-shift 3s ease infinite;
    background-size: 200% auto;
}

@keyframes gradient-shift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.act-countries-description {
    font-size: 20px;
    color: #555;
    margin: 0;
    font-weight: 400;
}

/* Search Bar */
.act-countries-search {
    position: relative;
    max-width: 650px;
    margin: 0 auto 40px;
}

.act-countries-search__input {
    width: 100%;
    padding: 18px 56px 18px 28px;
    font-size: 17px;
    border: 3px solid transparent;
    border-radius: 50px;
    outline: none;
    transition: all 0.3s ease;
    background: linear-gradient(#fff, #fff) padding-box,
                linear-gradient(135deg, var(--act-branding-color, #2f1667), var(--act-branding-color-hover, #1f0e47)) border-box;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.act-countries-search__input:focus {
    box-shadow: 0 8px 30px rgba(47, 22, 103, 0.2);
    transform: translateY(-2px);
}

.act-countries-search__input::placeholder {
    color: #999;
}

.act-countries-search__icon {
    position: absolute;
    right: 28px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--act-branding-color, #2f1667);
    pointer-events: none;
    display: flex;
    align-items: center;
    transition: transform 0.3s ease;
}

.act-countries-search:focus-within .act-countries-search__icon {
    transform: translateY(-50%) scale(1.1);
}

/* Results Info */
.act-countries-results-info {
    margin-bottom: 24px;
    text-align: center;
}

.act-countries-count {
    font-size: 14px;
    color: #666;
    font-weight: 500;
}

/* Countries Grid */
.act-countries-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 24px;
    margin-bottom: 40px;
}

/* Country Card - Compact List Style */
.act-country-card {
    background: #ffffff;
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s ease;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    border: 1px solid #e5e7eb;
    position: relative;
    text-decoration: none;
}

.act-country-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    border-color: #d1d5db;
}

.act-country-card__flag-container {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.act-country-card__flag {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}

.act-country-card__content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.act-country-card__name {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
    color: #1f2937;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.act-country-card__codes {
    display: flex;
    gap: 6px;
    align-items: center;
}

.act-country-card__code {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    background: #f3f4f6;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    color: #6b7280;
    font-family: 'Courier New', monospace;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

.act-country-card__link {
    display: none;
}

/* Pagination */
.act-countries-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.act-countries-pagination__button {
    min-width: 40px;
    height: 40px;
    padding: 8px 12px;
    border: 2px solid #e0e0e0;
    background: #fff;
    color: #333;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    font-size: 14px;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.act-countries-pagination__button:hover:not(.act-countries-pagination__button--disabled):not(.act-countries-pagination__button--active) {
    border-color: var(--act-branding-color, #2f1667);
    color: var(--act-branding-color, #2f1667);
    background: rgba(47, 22, 103, 0.05);
}

.act-countries-pagination__button--active {
    background-color: var(--act-branding-color, #2f1667);
    border-color: var(--act-branding-color, #2f1667);
    color: #ffffff;
    cursor: default;
}

.act-countries-pagination__button--disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.act-countries-pagination__ellipsis {
    padding: 8px;
    color: #999;
}

/* Skeleton Loading States */
.act-countries-grid.act-countries-skeleton {
    /* Skeleton is visible by default, no animation needed */
}

.act-countries-skeleton__card {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    overflow: hidden;
    height: 80px;
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 16px;
    position: relative;
}

.act-countries-skeleton__card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -150%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(0, 0, 0, 0.03),
        transparent
    );
    animation: skeleton-loading 2s infinite ease-in-out;
}

@keyframes skeleton-loading {
    0% {
        left: -150%;
        opacity: 0;
    }
    50% {
        opacity: 1;
    }
    100% {
        left: 150%;
        opacity: 0;
    }
}

.act-countries-skeleton__flag {
    width: 48px;
    height: 48px;
    background: #f3f4f6;
    border-radius: 8px;
    flex-shrink: 0;
    animation: pulse 1.5s ease-in-out infinite;
}

.act-countries-skeleton__content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.act-countries-skeleton__text {
    height: 16px;
    background: #e5e7eb;
    border-radius: 4px;
    animation: pulse 1.5s ease-in-out infinite;
}

.act-countries-skeleton__text--short {
    width: 60%;
}

.act-countries-skeleton__codes {
    display: flex;
    gap: 6px;
}

.act-countries-skeleton__code {
    width: 40px;
    height: 18px;
    background: #e5e7eb;
    border-radius: 4px;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.6;
    }
}

/* No Results */
.act-countries-no-results {
    text-align: center;
    padding: 60px 20px;
    color: #666;
    grid-column: 1 / -1;
    width: 100%;
}

.act-countries-no-results__icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.act-countries-no-results__text {
    font-size: 18px;
    margin: 0;
}

/* Error State */
.act-countries-error {
    text-align: center;
    padding: 40px 20px;
    background: #fee;
    border-radius: 8px;
    color: #c33;
    grid-column: 1 / -1;
    width: 100%;
}

/* No JavaScript Fallback */
.act-countries-no-js {
    text-align: center;
    padding: 40px 20px;
    background: #fef8e7;
    border-radius: 8px;
    color: #856404;
    grid-column: 1 / -1;
    width: 100%;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .act-countries-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .act-countries-display {
        padding: 30px 16px;
    }

    .act-countries-title {
        font-size: 36px;
    }

    .act-countries-description {
        font-size: 17px;
    }

    .act-countries-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }

    .act-country-card__name {
        font-size: 20px;
    }

    .act-country-card__flag-container {
        height: 160px;
    }

    .act-countries-pagination__button {
        min-width: 36px;
        height: 36px;
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .act-countries-display {
        padding: 24px 16px;
    }

    .act-countries-title {
        font-size: 28px;
        letter-spacing: -0.5px;
    }

    .act-countries-description {
        font-size: 14px;
        line-height: 1.5;
    }

    .act-countries-search {
        margin: 0 auto 24px;
    }

    .act-countries-search__input {
        padding: 14px 48px 14px 20px;
        font-size: 15px;
    }

    .act-countries-results-info {
        margin-bottom: 16px;
    }

    .act-countries-count {
        font-size: 13px;
    }

    .act-countries-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .act-country-card {
        padding: 16px;
        gap: 12px;
        flex-direction: row;
        text-align: left;
        align-items: center;
        position: relative;
    }

    .act-country-card::after {
        content: '›';
        position: absolute;
        right: 16px;
        top: 50%;
        transform: translateY(-50%);
        font-size: 24px;
        color: #9ca3af;
        font-weight: 300;
    }

    .act-country-card__flag-container {
        width: 40px;
        height: 40px;
        margin: 0;
        flex-shrink: 0;
    }

    .act-country-card__content {
        padding: 0;
        align-items: flex-start;
        flex: 1;
        min-width: 0;
        padding-right: 24px;
    }

    .act-country-card__name {
        font-size: 15px;
        font-weight: 600;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        line-height: 1.4;
        text-align: left;
        min-height: auto;
        display: block;
        width: 100%;
    }

    .act-country-card__codes {
        justify-content: flex-start;
        flex-wrap: nowrap;
        gap: 4px;
        margin-top: 2px;
    }

    .act-country-card__code {
        font-size: 11px;
        padding: 2px 6px;
        display: none;
    }

    .act-countries-pagination {
        gap: 4px;
    }

    .act-countries-pagination__button {
        min-width: 32px;
        height: 32px;
        font-size: 12px;
        padding: 6px 10px;
    }

    .act-countries-skeleton__card {
        flex-direction: row;
        height: 72px;
        padding: 16px;
        text-align: left;
    }

    .act-countries-skeleton__flag {
        width: 40px;
        height: 40px;
        margin: 0;
    }

    .act-countries-skeleton__content {
        align-items: flex-start;
        flex: 1;
    }

    .act-countries-skeleton__text {
        width: 60%;
        margin: 0;
    }

    .act-countries-skeleton__codes {
        justify-content: flex-start;
        display: none;
    }
}

/* Filter Section */
.act-countries-filters-wrapper {
    margin-bottom: 24px;
    position: relative;
    overflow: hidden;
}

.act-countries-filters {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 8px; /* For scrollbar space */
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    mask-image: linear-gradient(to right, black 90%, transparent 100%);
    -webkit-mask-image: linear-gradient(to right, black 90%, transparent 100%);
}

.act-countries-filters::-webkit-scrollbar {
    display: none;
}

/* Filter Chips */
.act-filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 50px;
    font-size: 14px;
    font-weight: 500;
    color: #4b5563;
    white-space: nowrap;
    transition: all 0.2s ease;
    cursor: pointer;
    text-decoration: none !important;
    user-select: none;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.act-filter-chip:hover {
    border-color: var(--act-branding-color, #2f1667);
    color: var(--act-branding-color, #2f1667);
    background: #fdfcff;
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(47, 22, 103, 0.08);
}

.act-filter-chip.act-filter-active {
    background: var(--act-branding-color, #2f1667);
    border-color: var(--act-branding-color, #2f1667);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(47, 22, 103, 0.2);
}

.act-filter-chip .count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    background: #f3f4f6;
    border-radius: 10px;
    font-size: 11px;
    color: #6b7280;
    font-weight: 600;
}

.act-filter-chip.act-filter-active .count {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

/* Spinner */
.act-spinner-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.7);
    display: flex;
    justify-content: center;
    align-items: center; 
    z-index: 10;
    backdrop-filter: blur(2px);
    border-radius: 12px;
}

.act-spinner {
    display: block;
    width: 24px;
    height: 24px;
    margin: 0 auto;
    border: 3px solid #e5e7eb;
    border-radius: 50%;
    border-top-color: #2f1667;
    border-top-color: var(--act-branding-color, #2f1667);
    animation: act-spin 0.8s linear infinite;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

@keyframes act-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Mobile Scroll Hint Animation */
@keyframes scroll-hint {
    0% { transform: translateX(0); }
    30% { transform: translateX(-20px); }
    60% { transform: translateX(0); }
    100% { transform: translateX(0); }
}

.act-scroll-hint {
    animation: scroll-hint 1.5s ease-out 1;
}

/* Product Grid Transitions */
ul.products {
    transition: opacity 0.3s ease;
}
ul.products.loading {
    opacity: 0.5;
    pointer-events: none;
}
