/* ═══════════════════════════════════════════════════════════
   NEWSLETTER DASHBOARD — Stage 4
   Preferences center integrated into the dashboard
   ═══════════════════════════════════════════════════════════ */

/* ─── Section Container ─── */
.newsletter-dash-section {
    margin-top: 0.75rem;
}

/* ─── Wrapper ─── */
.nld-wrapper {
    padding: 0.5rem 0;
}

/* ─── Tab Navigation ─── */
.nld-tabs {
    display: flex;
    gap: 0.25rem;
    background: rgba(15, 42, 42, 0.5);
    border-radius: var(--radius-md, 12px);
    padding: 4px;
    margin-bottom: 1.25rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.nld-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.6rem 0.8rem;
    border: none;
    background: transparent;
    color: var(--text-secondary, #C0C0C0);
    font-size: 0.82rem;
    font-weight: 500;
    border-radius: var(--radius-sm, 8px);
    cursor: pointer;
    transition: var(--transition-fast, 0.2s ease);
    white-space: nowrap;
    min-width: 0;
}

.nld-tab:hover {
    background: rgba(127, 255, 0, 0.08);
    color: var(--text-primary, #fff);
}

.nld-tab.active {
    background: rgba(127, 255, 0, 0.15);
    color: var(--accent-primary, #7FFF00);
    font-weight: 600;
}

.nld-tab-icon {
    font-size: 1rem;
}

/* ─── Tab Panels ─── */
.nld-panel {
    display: none;
    animation: nldFadeIn 0.3s ease;
}

.nld-panel.active {
    display: block;
}

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

/* ═══════════════════════════════
   CHANNELS TAB
   ═══════════════════════════════ */

.nld-channels-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.nld-channel-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    padding: 1rem 1.1rem;
    background: var(--card-glass-bg, rgba(31, 85, 85, 0.4));
    border: 1.5px solid rgba(127, 255, 0, 0.1);
    border-radius: var(--radius-md, 12px);
    cursor: pointer;
    transition: var(--transition-fast, 0.2s ease);
    user-select: none;
}

.nld-channel-card:hover {
    border-color: rgba(127, 255, 0, 0.3);
    background: rgba(31, 85, 85, 0.55);
    transform: translateY(-1px);
}

.nld-channel-card.active {
    border-color: rgba(127, 255, 0, 0.5);
    background: rgba(127, 255, 0, 0.08);
    box-shadow: 0 0 16px rgba(127, 255, 0, 0.08);
}

.nld-channel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.nld-channel-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
}

.nld-channel-icon {
    font-size: 1.3rem;
    flex-shrink: 0;
}

.nld-channel-label {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-primary, #fff);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nld-channel-desc {
    font-size: 0.76rem;
    color: var(--text-tertiary, #8892A6);
    line-height: 1.4;
    margin: 0;
}

/* Toggle switch */
.nld-toggle {
    position: relative;
    width: 40px;
    height: 22px;
    flex-shrink: 0;
}

.nld-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.nld-toggle-slider {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 11px;
    transition: 0.25s ease;
    cursor: pointer;
}

.nld-toggle-slider::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    background: #fff;
    border-radius: 50%;
    transition: 0.25s ease;
}

.nld-toggle input:checked + .nld-toggle-slider {
    background: var(--accent-primary, #7FFF00);
}

.nld-toggle input:checked + .nld-toggle-slider::before {
    transform: translateX(18px);
    background: #0A1A1A;
}

/* ─── Channel Actions ─── */
.nld-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-top: 0.5rem;
    padding-top: 0.75rem;
    border-top: 1px solid rgba(127, 255, 0, 0.08);
}

.nld-btn-save {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 1.4rem;
    background: linear-gradient(135deg, #7FFF00 0%, #6DE800 100%);
    color: #0A1A1A;
    font-weight: 700;
    font-size: 0.82rem;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    transition: 0.2s ease;
}

.nld-btn-save:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(127, 255, 0, 0.25);
}

.nld-btn-save:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.nld-btn-reset {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 1.2rem;
    background: transparent;
    color: var(--text-secondary, #C0C0C0);
    font-weight: 500;
    font-size: 0.82rem;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 20px;
    cursor: pointer;
    transition: 0.2s ease;
}

.nld-btn-reset:hover {
    border-color: rgba(255, 255, 255, 0.3);
    color: #fff;
}

.nld-btn-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: none;
    border: none;
    color: var(--accent-primary, #7FFF00);
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    padding: 0.3rem 0;
    transition: 0.2s ease;
}

.nld-btn-link:hover {
    text-decoration: underline;
}

/* ═══════════════════════════════
   SCHEDULE TAB
   ═══════════════════════════════ */

.nld-schedule-form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.nld-form-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.nld-form-group.full-width {
    grid-column: 1 / -1;
}

.nld-form-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary, #C0C0C0);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.nld-form-hint {
    font-size: 0.72rem;
    color: var(--text-tertiary, #8892A6);
    margin-top: 0.1rem;
}

.nld-select,
.nld-input {
    padding: 0.6rem 0.8rem;
    background: rgba(15, 42, 42, 0.6);
    border: 1px solid rgba(127, 255, 0, 0.12);
    border-radius: var(--radius-sm, 8px);
    color: var(--text-primary, #fff);
    font-size: 0.84rem;
    transition: 0.2s ease;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
}

.nld-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23C0C0C0' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.7rem center;
    padding-right: 2rem;
}

.nld-select option {
    background: #0A1A1A;
    color: #fff;
}

.nld-select:focus,
.nld-input:focus {
    border-color: rgba(127, 255, 0, 0.4);
    box-shadow: 0 0 0 2px rgba(127, 255, 0, 0.08);
}

/* ─── Tags Input ─── */
.nld-tags-wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    padding: 0.45rem 0.6rem;
    background: rgba(15, 42, 42, 0.6);
    border: 1px solid rgba(127, 255, 0, 0.12);
    border-radius: var(--radius-sm, 8px);
    min-height: 38px;
    transition: 0.2s ease;
}

.nld-tags-wrapper:focus-within {
    border-color: rgba(127, 255, 0, 0.4);
}

.nld-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.2rem 0.55rem;
    background: rgba(127, 255, 0, 0.12);
    border-radius: 12px;
    font-size: 0.76rem;
    color: var(--accent-primary, #7FFF00);
}

.nld-tag-remove {
    cursor: pointer;
    opacity: 0.6;
    font-size: 0.9rem;
    line-height: 1;
}

.nld-tag-remove:hover {
    opacity: 1;
}

.nld-tag-input {
    border: none;
    background: transparent;
    color: #fff;
    font-size: 0.82rem;
    outline: none;
    flex: 1;
    min-width: 80px;
    padding: 0.15rem 0;
}

.nld-tag-input::placeholder {
    color: var(--text-tertiary, #8892A6);
}

/* ═══════════════════════════════
   HISTORY TAB
   ═══════════════════════════════ */

.nld-history-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nld-history-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 0.9rem;
    background: var(--card-glass-bg, rgba(31, 85, 85, 0.4));
    border: 1px solid rgba(127, 255, 0, 0.06);
    border-radius: var(--radius-sm, 8px);
    transition: 0.15s ease;
}

.nld-history-item:hover {
    border-color: rgba(127, 255, 0, 0.15);
}

.nld-history-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
    background: rgba(127, 255, 0, 0.08);
}

.nld-history-info {
    flex: 1;
    min-width: 0;
}

.nld-history-subject {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-primary, #fff);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nld-history-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.72rem;
    color: var(--text-tertiary, #8892A6);
    margin-top: 0.15rem;
}

.nld-history-status {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.72rem;
    flex-shrink: 0;
}

.nld-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}

.nld-status-dot.sent    { background: #7FFF00; }
.nld-status-dot.opened  { background: #00BFFF; }
.nld-status-dot.clicked { background: #FFD700; }
.nld-status-dot.bounced { background: #FF4444; }

.nld-history-empty {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-tertiary, #8892A6);
    font-size: 0.85rem;
}

.nld-history-empty-icon {
    font-size: 2.5rem;
    display: block;
    margin-bottom: 0.5rem;
    opacity: 0.5;
}

.nld-load-more {
    display: block;
    width: 100%;
    padding: 0.6rem;
    margin-top: 0.5rem;
    background: rgba(127, 255, 0, 0.06);
    border: 1px solid rgba(127, 255, 0, 0.1);
    border-radius: var(--radius-sm, 8px);
    color: var(--text-secondary, #C0C0C0);
    font-size: 0.78rem;
    cursor: pointer;
    transition: 0.2s ease;
}

.nld-load-more:hover {
    background: rgba(127, 255, 0, 0.12);
    color: #fff;
}

/* ═══════════════════════════════
   STATS TAB (mini stat cards)
   ═══════════════════════════════ */

.nld-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.6rem;
    margin-bottom: 1.25rem;
}

.nld-stat-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    padding: 0.9rem 0.6rem;
    background: var(--card-glass-bg, rgba(31, 85, 85, 0.4));
    border: 1px solid rgba(127, 255, 0, 0.08);
    border-radius: var(--radius-md, 12px);
    text-align: center;
}

.nld-stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-primary, #7FFF00);
    line-height: 1.1;
}

.nld-stat-label {
    font-size: 0.7rem;
    color: var(--text-tertiary, #8892A6);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* ─── GDPR Note ─── */
.nld-gdpr-note {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    margin-top: 1rem;
    padding: 0.7rem 0.9rem;
    background: rgba(127, 255, 0, 0.04);
    border: 1px solid rgba(127, 255, 0, 0.08);
    border-radius: var(--radius-sm, 8px);
    font-size: 0.72rem;
    color: var(--text-tertiary, #8892A6);
    line-height: 1.5;
}

.nld-gdpr-note a {
    color: var(--accent-primary, #7FFF00);
    text-decoration: none;
}

.nld-gdpr-note a:hover {
    text-decoration: underline;
}

/* ─── Loading spinner ─── */
.nld-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding: 2rem;
    color: var(--text-tertiary, #8892A6);
    font-size: 0.82rem;
}

.nld-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid rgba(127, 255, 0, 0.15);
    border-top-color: var(--accent-primary, #7FFF00);
    border-radius: 50%;
    animation: nldSpin 0.8s linear infinite;
}

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

/* ─── Toast notification ─── */
.nld-toast {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    padding: 0.7rem 1.4rem;
    border-radius: 20px;
    font-size: 0.82rem;
    font-weight: 500;
    z-index: 9999;
    opacity: 0;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

.nld-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.nld-toast.success {
    background: rgba(127, 255, 0, 0.9);
    color: #0A1A1A;
}

.nld-toast.error {
    background: rgba(255, 68, 68, 0.9);
    color: #fff;
}

/* ═══════════════════════════════
   RESPONSIVE
   ═══════════════════════════════ */

@media (max-width: 768px) {
    .nld-tabs {
        gap: 0.15rem;
    }
    .nld-tab {
        padding: 0.5rem 0.5rem;
        font-size: 0.75rem;
    }
    .nld-tab-label {
        display: none;
    }
    .nld-tab-icon {
        font-size: 1.1rem;
    }
    .nld-channels-grid {
        grid-template-columns: 1fr;
    }
    .nld-schedule-form {
        grid-template-columns: 1fr;
    }
    .nld-stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .nld-actions {
        flex-wrap: wrap;
    }
}

@media (max-width: 480px) {
    .nld-stats-grid {
        grid-template-columns: 1fr 1fr;
    }
}
