// ============================================
// ADMIN NEWSLETTER - Component-Specific Styles
// ============================================
@import '../admin-shared.scss';

// ============================================
// TAB NAVIGATION
// ============================================
.tab-navigation {
    display: flex;
    gap: $admin-space-2xs;
    margin-bottom: $admin-space-md;
    padding: $admin-space-2xs;
    background: $glass-bg;
    backdrop-filter: blur(20px);
    border: 1px solid $glass-border;
    border-radius: $radius-md;
    animation: fadeIn 0.3s ease-out;

    @media (max-width: 480px) {
        flex-direction: column;
    }
}

.tab-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: $admin-space-xs;
    padding: $admin-space-xs $admin-space-sm;
    background: transparent;
    border: none;
    border-radius: $radius-sm;
    font-size: 0.8125rem;
    font-weight: 600;
    color: $color-text-secondary;
    cursor: pointer;
    transition: all $transition-fast;

    .material-symbols-outlined {
        font-size: 1.125rem;
        opacity: 0.7;
    }

    .tab-label {
        @media (max-width: 360px) {
            display: none;
        }
    }

    .tab-count {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 1.25rem;
        height: 1.125rem;
        padding: 0 $admin-space-2xs;
        background: $color-gray-100;
        border-radius: $radius-full;
        font-size: 0.625rem;
        font-weight: 700;
        color: $color-text-tertiary;
        transition: all $transition-fast;
    }

    &:hover:not(.active) {
        background: $color-gray-50;
        color: $color-text-primary;

        .material-symbols-outlined {
            opacity: 1;
        }
    }

    &.active {
        background: $gradient-primary;
        color: white;
        box-shadow: 0 2px 8px rgba($color-brand-primary, 0.25);

        .material-symbols-outlined {
            opacity: 1;
        }

        .tab-count {
            background: rgba(white, 0.25);
            color: white;
        }
    }
}

// ============================================
// TAB CONTENT
// ============================================
.tab-content {
    animation: fadeIn 0.25s ease-out;
}

// ============================================
// FILTER BAR
// ============================================
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: $admin-space-sm;
    justify-content: space-between;
    align-items: center;
    margin-bottom: $admin-space-md;
    padding: $admin-space-sm;
    background: $glass-bg;
    border: 1px solid $glass-border;
    border-radius: $radius-md;
    animation: fadeIn 0.3s ease-out 0.1s backwards;

    @media (max-width: 640px) {
        flex-direction: column;
        align-items: stretch;
    }
}

.filter-bar__left {
    display: flex;
    flex-wrap: wrap;
    gap: $admin-space-sm;
    align-items: center;
    flex: 1;

    @media (max-width: 480px) {
        flex-direction: column;
        align-items: stretch;
    }
}

.filter-bar__right {
    display: flex;
    gap: $admin-space-xs;

    @media (max-width: 640px) {
        justify-content: flex-end;
    }

    @media (max-width: 480px) {
        flex-wrap: wrap;
    }
}

// ============================================
// SEARCH INPUT
// ============================================
.search-input {
    display: flex;
    align-items: center;
    gap: $admin-space-xs;
    padding: $admin-space-xs $admin-space-sm;
    background: white;
    border: 1px solid $border-default;
    border-radius: $radius-sm;
    min-width: 200px;
    transition: all $transition-fast;

    &:focus-within {
        border-color: $color-brand-primary;
        box-shadow: 0 0 0 3px rgba($color-brand-primary, 0.1);
    }

    .material-symbols-outlined {
        font-size: 1rem;
        color: $color-text-tertiary;
    }

    input {
        flex: 1;
        border: none;
        background: transparent;
        font-size: 0.8125rem;
        color: $color-text-primary;
        outline: none;
        min-width: 0;

        &::placeholder {
            color: $color-text-tertiary;
        }
    }

    .clear-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 18px;
        height: 18px;
        background: $color-gray-100;
        border: none;
        border-radius: $radius-sm;
        color: $color-text-tertiary;
        cursor: pointer;
        transition: all $transition-fast;

        .material-symbols-outlined {
            font-size: 0.875rem;
        }

        &:hover {
            background: $color-gray-200;
            color: $color-text-primary;
        }
    }

    @media (max-width: 480px) {
        min-width: 100%;
    }
}

// ============================================
// FILTER CHIPS
// ============================================
.filter-chips {
    display: flex;
    gap: $admin-space-2xs;
    flex-wrap: wrap;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: $admin-space-2xs $admin-space-xs;
    background: white;
    border: 1px solid $border-default;
    border-radius: $radius-full;
    font-size: 0.6875rem;
    font-weight: 600;
    color: $color-text-secondary;
    cursor: pointer;
    transition: all $transition-fast;

    &:hover {
        border-color: $color-brand-primary;
        color: $color-brand-primary;
    }

    &.active {
        background: $color-brand-primary;
        border-color: $color-brand-primary;
        color: white;

        .dot {
            border-color: white;
        }
    }
}

.dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    border: 1.5px solid currentColor;

    &--success {
        background: $accent-green;
        border-color: $accent-green;
    }

    &--muted {
        background: $color-gray-400;
        border-color: $color-gray-400;
    }
}

// ============================================
// SUBSCRIBERS GRID
// ============================================
.subscribers-grid {
    display: grid;
    gap: $admin-space-xs;
    animation: fadeIn 0.3s ease-out 0.15s backwards;
}

.subscriber-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: $admin-space-sm;
    padding: $admin-space-sm;
    background: $glass-bg;
    border: 1px solid $glass-border;
    border-radius: $radius-md;
    transition: all $transition-fast;
    animation: staggerFade 0.3s ease-out backwards;

    @for $i from 1 through 30 {
        &:nth-child(#{$i}) {
            animation-delay: #{$i * 25}ms;
        }
    }

    &:hover {
        border-color: rgba($color-brand-primary, 0.3);
        box-shadow: $shadow-sm;
    }

    &.inactive {
        opacity: 0.6;

        .email {
            color: $color-text-tertiary;
        }
    }

    &.user-card {
        border-left: 3px solid $accent-blue;
    }

    @media (max-width: 640px) {
        flex-direction: column;
        align-items: stretch;
    }
}

.card__main {
    flex: 1;
    min-width: 0;
}

.card__email-row {
    display: flex;
    align-items: center;
    gap: $admin-space-sm;
    margin-bottom: $admin-space-2xs;

    @media (max-width: 480px) {
        flex-direction: column;
        align-items: flex-start;
        gap: $admin-space-2xs;
    }
}

.email {
    font-size: 0.875rem;
    font-weight: 600;
    color: $color-text-primary;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: $radius-full;
    font-size: 0.625rem;
    font-weight: 700;
    text-transform: uppercase;
    flex-shrink: 0;

    &.status--active {
        background: rgba($accent-green, 0.12);
        color: $accent-green;
    }

    &.status--inactive {
        background: rgba($color-gray-400, 0.12);
        color: $color-gray-500;
    }

    &.status--user {
        background: rgba($accent-blue, 0.12);
        color: $accent-blue;

        .material-symbols-outlined {
            font-size: 0.75rem;
        }
    }
}

.card__meta {
    display: flex;
    flex-wrap: wrap;
    gap: $admin-space-sm;
}

.meta-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.6875rem;
    color: $color-text-tertiary;

    .material-symbols-outlined {
        font-size: 0.875rem;
    }
}

.card__actions {
    display: flex;
    gap: $admin-space-2xs;
    flex-shrink: 0;

    @media (max-width: 640px) {
        padding-top: $admin-space-xs;
        border-top: 1px solid $border-default;
        justify-content: flex-end;
    }
}

.action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: transparent;
    border: 1px solid $border-default;
    border-radius: $radius-sm;
    color: $color-text-tertiary;
    cursor: pointer;
    transition: all $transition-fast;
    text-decoration: none;

    .material-symbols-outlined {
        font-size: 1rem;
    }

    &:hover {
        background: rgba($color-brand-primary, 0.08);
        border-color: $color-brand-primary;
        color: $color-brand-primary;
    }

    &.active {
        color: $accent-green;
        border-color: $accent-green;

        &:hover {
            background: rgba($accent-green, 0.08);
        }
    }

    &--danger:hover {
        background: rgba($accent-red, 0.08);
        border-color: $accent-red;
        color: $accent-red;
    }
}

// ============================================
// RESULT COUNT
// ============================================
.result-count {
    margin-top: $admin-space-sm;
    padding: $admin-space-xs;
    text-align: center;
    font-size: 0.75rem;
    color: $color-text-tertiary;
}

// ============================================
// INFO BOX
// ============================================
.info-box {
    display: flex;
    align-items: flex-start;
    gap: $admin-space-sm;
    margin-top: $admin-space-md;
    padding: $admin-space-sm $admin-space-md;
    background: rgba($accent-blue, 0.08);
    border: 1px solid rgba($accent-blue, 0.2);
    border-radius: $radius-md;
    animation: fadeIn 0.3s ease-out 0.2s backwards;

    .material-symbols-outlined {
        font-size: 1.25rem;
        color: $accent-blue;
        flex-shrink: 0;
    }

    p {
        margin: 0;
        font-size: 0.75rem;
        color: $color-text-secondary;
        line-height: 1.5;

        strong {
            color: $color-text-primary;
        }
    }
}

// ============================================
// LOADING STATE
// ============================================
.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: $admin-space-sm;
    padding: $admin-space-2xl;
    color: $color-text-secondary;

    .spinner {
        width: 40px;
        height: 40px;
        border: 3px solid rgba($color-brand-primary, 0.2);
        border-top-color: $color-brand-primary;
        border-radius: 50%;
        animation: spin 1s linear infinite;
    }

    p {
        font-size: 0.875rem;
        margin: 0;
    }
}

// ============================================
// EMPTY & ERROR STATES
// ============================================
.empty-state,
.error-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: $admin-space-2xl;
    text-align: center;
    background: $glass-bg;
    border: 1px solid $glass-border;
    border-radius: $radius-md;
    animation: fadeIn 0.3s ease-out;

    .material-symbols-outlined {
        font-size: 2.5rem;
        color: $color-gray-300;
        margin-bottom: $admin-space-sm;
    }

    h3 {
        font-size: 1rem;
        font-weight: 700;
        color: $color-text-primary;
        margin: 0 0 $admin-space-2xs;
    }

    p {
        font-size: 0.8125rem;
        color: $color-text-tertiary;
        margin: 0 0 $admin-space-md;
    }
}

.error-state {
    .material-symbols-outlined {
        color: $accent-red;
    }
}

// ============================================
// TOAST
// ============================================
.toast {
    position: fixed;
    bottom: 5rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: $admin-space-xs;
    padding: $admin-space-sm $admin-space-md;
    background: $color-gray-900;
    color: white;
    border-radius: $radius-md;
    font-size: 0.8125rem;
    font-weight: 500;
    box-shadow: $shadow-lg;
    z-index: 1000;
    animation: popIn 0.3s ease-out;

    .material-symbols-outlined {
        font-size: 1.125rem;
    }

    &--success {
        background: $accent-green;
    }

    &--error {
        background: $accent-red;
    }

    &--info {
        background: $accent-blue;
    }

    @media (min-width: 768px) {
        bottom: $admin-space-lg;
    }
}

// ============================================
// BUTTON LABEL (responsive)
// ============================================
.btn-label {
    @media (max-width: 480px) {
        display: none;
    }
}

// ============================================
// UTILITIES
// ============================================
.spinning {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

// ============================================
// RESPONSIVE
// ============================================
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
