/**
 * NewsSync Admin UI - Modern Redesign
 * Inspired by EmbedPress
 * Color Scheme: Blue #2563EB
 *
 * @package NewsSync
 * @version 1.0.0
 */

/* === CSS Variables === */
:root {
    /* Primary Colors */
    --ns-primary: #2563EB;
    --ns-primary-hover: #1E40AF;
    --ns-primary-light: #DBEAFE;
    --ns-primary-dark: #1E40AF;

    /* Sidebar Dark Theme */
    --ns-sidebar-bg: #1E293B;
    --ns-sidebar-hover: #334155;
    --ns-sidebar-active-bg: rgba(37, 99, 235, 0.15);
    --ns-sidebar-text: #94A3B8;
    --ns-sidebar-text-hover: #E2E8F0;
    --ns-sidebar-text-active: #60A5FA;
    --ns-sidebar-border: rgba(255, 255, 255, 0.1);

    /* Content Area Light Theme */
    --ns-content-bg: #F8FAFF;
    --ns-card-bg: #FFFFFF;
    --ns-border-light: #E5E7EB;
    --ns-border-medium: #CBD5E1;

    /* Text Colors */
    --ns-text-primary: #0F172A;
    --ns-text-secondary: #64748B;
    --ns-text-muted: #94A3B8;

    /* Status Colors */
    --ns-success: #10B981;
    --ns-success-bg: #D1FAE5;
    --ns-warning: #F59E0B;
    --ns-warning-bg: #FEF3C7;
    --ns-error: #EF4444;
    --ns-error-bg: #FEE2E2;
    --ns-info: #3B82F6;
    --ns-info-bg: #DBEAFE;
}

/* === Main Wrapper === */
.newssync-admin-wrap {
    display: flex;
    gap: 0;
    margin: 20px 20px 20px 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

/* === Sidebar === */
.newssync-sidebar {
    width: 260px;
    background: var(--ns-sidebar-bg);
    padding: 0;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 32px;
    height: calc(100vh - 32px);
    overflow-y: auto;
    flex-shrink: 0;
}

/* Sidebar Brand */
.newssync-sidebar-brand {
    padding: 24px 20px;
    border-bottom: 1px solid var(--ns-sidebar-border);
    display: flex;
    align-items: center;
    gap: 12px;
}

.newssync-brand-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--ns-primary), #3B82F6);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #FFFFFF;
    font-weight: 700;
    font-size: 18px;
    flex-shrink: 0;
}

.newssync-brand-text {
    color: #FFFFFF;
    font-size: 18px;
    font-weight: 700;
    margin: 0;
}

/* Sidebar Navigation */
.newssync-sidebar nav {
    padding: 16px 12px;
}

.newssync-sidebar nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.newssync-sidebar nav li {
    margin-bottom: 4px;
}

.newssync-sidebar nav a,
.newssync-sidebar nav button {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--ns-sidebar-text);
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.2s ease;
    font-size: 14px;
    font-weight: 500;
    width: 100%;
    background: none;
    border: none;
    cursor: pointer;
    text-align: left;
}

.newssync-sidebar nav a:hover,
.newssync-sidebar nav button:hover {
    background: var(--ns-sidebar-hover);
    color: var(--ns-sidebar-text-hover);
}

.newssync-sidebar nav a.active,
.newssync-sidebar nav button.active {
    background: var(--ns-sidebar-active-bg);
    color: var(--ns-sidebar-text-active);
    font-weight: 600;
    border-left: 3px solid var(--ns-primary);
    padding-left: 13px;
}

.newssync-sidebar nav .dashicons {
    font-size: 18px;
    width: 18px;
    height: 18px;
    opacity: 0.8;
}

.newssync-sidebar nav .active .dashicons {
    opacity: 1;
    color: var(--ns-primary);
}

/* === Content Area === */
.newssync-content {
    flex: 1;
    background: var(--ns-content-bg);
    padding: 0;
    min-height: calc(100vh - 72px);
}

/* Content Header */
.newssync-content-header {
    background: var(--ns-card-bg);
    padding: 24px 32px;
    border-bottom: 1px solid var(--ns-border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

.newssync-content-header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.newssync-content-header-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--ns-primary), #3B82F6);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 24px;
    flex-shrink: 0;
}

.newssync-content-header-title h1 {
    margin: 0;
    font-size: 24px;
    font-weight: 700;
    color: var(--ns-text-primary);
}

.newssync-content-header-subtitle {
    margin: 4px 0 0;
    font-size: 14px;
    color: var(--ns-text-secondary);
}

.newssync-content-header-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

/* Content Body */
.newssync-content-body {
    padding: 32px;
}

/* === Cards === */
.newssync-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.newssync-card {
    background: var(--ns-card-bg);
    border: 1px solid var(--ns-border-light);
    border-radius: 12px;
    padding: 24px;
    transition: all 0.3s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.newssync-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transform: translateY(-2px);
}

.newssync-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 12px;
}

.newssync-card-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.newssync-card-icon.primary {
    background: var(--ns-primary-light);
    color: var(--ns-primary);
}

.newssync-card-icon.success {
    background: var(--ns-success-bg);
    color: var(--ns-success);
}

.newssync-card-icon.warning {
    background: var(--ns-warning-bg);
    color: var(--ns-warning);
}

.newssync-card-icon.error {
    background: var(--ns-error-bg);
    color: var(--ns-error);
}

.newssync-card-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--ns-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 0 8px;
}

.newssync-card-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--ns-text-primary);
    margin: 0;
}

.newssync-card-description {
    font-size: 13px;
    color: var(--ns-text-secondary);
    margin: 8px 0 0;
}

/* === Sections === */
.newssync-section {
    background: var(--ns-card-bg);
    border: 1px solid var(--ns-border-light);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 24px;
    animation: fadeIn 0.3s ease;
}

.newssync-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--ns-border-light);
}

.newssync-section-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--ns-text-primary);
    margin: 0;
}

.newssync-section-subtitle {
    font-size: 14px;
    color: var(--ns-text-secondary);
    margin: 4px 0 0;
}

/* === Buttons === */
.newssync-btn,
.button.newssync-btn-primary,
.button.newssync-btn-secondary {
    padding: 10px 20px !important;
    border-radius: 8px !important;
    font-weight: 600 !important;
    transition: all 0.2s ease !important;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.newssync-btn-primary,
.button-primary {
    background: var(--ns-primary) !important;
    border-color: var(--ns-primary) !important;
    color: #FFFFFF !important;
    box-shadow: 0 1px 3px rgba(37, 99, 235, 0.2) !important;
}

.newssync-btn-primary:hover,
.button-primary:hover {
    background: var(--ns-primary-hover) !important;
    border-color: var(--ns-primary-hover) !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(37, 99, 235, 0.3) !important;
}

.newssync-btn-upgrade {
    background: linear-gradient(135deg, #F59E0B, #D97706) !important;
    border-color: #D97706 !important;
    color: #FFFFFF !important;
    box-shadow: 0 1px 3px rgba(217, 119, 6, 0.3) !important;
    font-weight: 700 !important;
}

.newssync-btn-upgrade:hover {
    background: linear-gradient(135deg, #FBBF24, #F59E0B) !important;
    border-color: #F59E0B !important;
    color: #FFFFFF !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(217, 119, 6, 0.4) !important;
}

.newssync-btn-secondary,
.button {
    background: transparent !important;
    border: 1px solid var(--ns-border-medium) !important;
    color: var(--ns-text-primary) !important;
}

.newssync-btn-secondary:hover,
.button:hover {
    background: var(--ns-content-bg) !important;
    border-color: var(--ns-primary) !important;
    color: var(--ns-primary) !important;
}

/* === Wizard Steps === */
.newssync-wizard {
    background: linear-gradient(135deg, #F0F9FF 0%, #E0F2FE 100%);
    border: 1px solid var(--ns-primary-light);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 24px;
}

.newssync-wizard-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--ns-text-primary);
    margin: 0 0 16px;
}

.newssync-step {
    display: flex;
    gap: 16px;
    padding: 16px 0;
    border-bottom: 1px solid var(--ns-border-light);
}

.newssync-step:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.newssync-step-number {
    width: 36px;
    height: 36px;
    background: var(--ns-primary);
    color: #FFFFFF;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    flex-shrink: 0;
}

.newssync-step-content {
    flex: 1;
}

.newssync-step-text {
    color: var(--ns-text-secondary);
    margin: 0;
    line-height: 1.6;
}

.newssync-step-link {
    color: var(--ns-primary);
    text-decoration: none;
    font-weight: 600;
}

.newssync-step-link:hover {
    text-decoration: underline;
}

/* === Badges === */
.newssync-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.newssync-badge.success {
    background: var(--ns-success-bg);
    color: var(--ns-success);
}

.newssync-badge.warning {
    background: var(--ns-warning-bg);
    color: var(--ns-warning);
}

.newssync-badge.error {
    background: var(--ns-error-bg);
    color: var(--ns-error);
}

.newssync-badge.info {
    background: var(--ns-info-bg);
    color: var(--ns-info);
}

.newssync-badge.primary {
    background: var(--ns-primary-light);
    color: var(--ns-primary);
}

/* === Form Elements === */
.newssync-section input[type="text"],
.newssync-section input[type="url"],
.newssync-section input[type="number"],
.newssync-section select,
.newssync-section textarea {
    border: 1px solid var(--ns-border-medium);
    border-radius: 6px;
    padding: 10px 14px;
    font-size: 14px;
    transition: border 0.2s ease, box-shadow 0.2s ease;
}

.newssync-section input:focus,
.newssync-section select:focus,
.newssync-section textarea:focus {
    border-color: var(--ns-primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* === Feed Items (preserve existing) === */
.rsp-feed-item {
    transition: box-shadow 120ms ease;
}

.rsp-feed-item:active,
.rsp-feed-item:focus-within {
    box-shadow: 0 6px 16px rgba(0,0,0,0.06);
}

.rsp-feed-item input[type="url"],
.rsp-feed-item input[type="text"] {
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
}

.rsp-feed-item .button {
    margin-left: 8px;
}

/* === Animations === */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* === Content Sections Visibility === */
.newssync-content-section {
    display: none;
}

.newssync-content-section.active {
    display: block;
}

/* === Responsive === */
@media (max-width: 1024px) {
    .newssync-admin-wrap {
        flex-direction: column;
    }

    .newssync-sidebar {
        width: 100%;
        position: relative;
        top: 0;
        height: auto;
        margin-bottom: 20px;
    }

    .newssync-content-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .newssync-cards-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .newssync-content-body {
        padding: 20px;
    }

    .newssync-content-header {
        padding: 20px;
    }

    .rsp-feed-item {
        flex-direction: column;
        gap: 8px;
    }

    .rsp-feed-item input {
        width: 100%;
    }
}

/* Ensure field descriptions render as block and sit below inputs in the settings UI */
.newssync-content-section .form-table td .description,
.newssync-content-section .form-table td p.description {
    display: block;
    margin-top: 8px;
    color: var(--ns-text-secondary);
    font-size: 13px;
    line-height: 1.4;
}

/* Make sure long descriptions wrap and don't sit inline with form controls */
.newssync-content-section .form-table td {
    vertical-align: top;
}

/* Stack controls and descriptions in settings tab panes so descriptions appear below inputs */
.ns-settings-tab-pane .form-table td,
.ns-settings-tab-pane .form-table td > div {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.ns-settings-tab-pane .form-table td .description {
    width: 100%;
}

/* === Hide old tabs on new UI === */
.newssync-admin-wrap .nav-tab-wrapper {
    display: none;
}

/* === Modern Notices (WordPress notices redesign) === */
.newssync-content-body .notice {
    background: var(--ns-card-bg);
    border-left: 4px solid var(--ns-primary);
    padding: 16px 20px;
    margin: 20px 0;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.newssync-content-body .notice.notice-success {
    border-left-color: var(--ns-success);
    background: linear-gradient(90deg, var(--ns-success-bg) 0%, var(--ns-card-bg) 15%);
}

.newssync-content-body .notice.notice-warning {
    border-left-color: var(--ns-warning);
    background: linear-gradient(90deg, var(--ns-warning-bg) 0%, var(--ns-card-bg) 15%);
}

.newssync-content-body .notice.notice-error {
    border-left-color: var(--ns-error);
    background: linear-gradient(90deg, var(--ns-error-bg) 0%, var(--ns-card-bg) 15%);
}

.newssync-content-body .notice.notice-info {
    border-left-color: var(--ns-info);
    background: linear-gradient(90deg, var(--ns-info-bg) 0%, var(--ns-card-bg) 15%);
}

.newssync-content-body .notice p {
    margin: 0;
    font-size: 14px;
    font-weight: 500;
    color: var(--ns-text-primary);
}

.newssync-content-body .notice strong {
    color: var(--ns-text-primary);
    font-weight: 600;
}

.newssync-content-body .notice.is-dismissible {
    padding-right: 40px;
}

/* Table status notice specific */
.newssync-content-body .notice.newssync-table-status-notice {
    background: linear-gradient(135deg, #FEF3C7 0%, #FFFBEB 100%);
    border-left-color: var(--ns-warning);
    padding: 20px 24px;
}

.newssync-content-body .notice.newssync-table-status-notice strong {
    color: var(--ns-warning);
    font-size: 15px;
}

/* === Documentation Section Styles === */
.newssync-content-section[data-section="documentation"] pre {
    background: #f0f0f0;
    padding: 18px;
    border-radius: 8px;
    font-size: 1.05em;
    overflow-x: auto;
}

.newssync-content-section[data-section="documentation"] pre code {
    background: transparent;
    padding: 0;
}

.newssync-content-section[data-section="documentation"] code {
    background: var(--ns-primary-light);
    color: var(--ns-primary-dark);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.95em;
    font-family: 'Courier New', monospace;
}

.newssync-content-section[data-section="documentation"] h3 {
    color: var(--ns-text-primary);
    font-size: 20px;
    font-weight: 600;
    margin-top: 30px;
    margin-bottom: 15px;
}

.newssync-content-section[data-section="documentation"] h4 {
    color: var(--ns-text-secondary);
    font-size: 16px;
    font-weight: 600;
    margin-top: 20px;
    margin-bottom: 12px;
}

.newssync-content-section[data-section="documentation"] table.widefat {
    border: 1px solid var(--ns-border-light);
    border-radius: 8px;
    overflow: hidden;
}

.newssync-content-section[data-section="documentation"] table.widefat thead th {
    background: var(--ns-content-bg);
    color: var(--ns-text-primary);
    font-weight: 600;
    padding: 12px 16px;
    border-bottom: 2px solid var(--ns-border-medium);
}

.newssync-content-section[data-section="documentation"] table.widefat tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--ns-border-light);
}

.newssync-content-section[data-section="documentation"] table.widefat tbody tr:last-child td {
    border-bottom: none;
}

.newssync-content-section[data-section="documentation"] table.widefat tbody tr:hover {
    background: var(--ns-content-bg);
}

/* === Tools Section Styles === */
.newssync-content-section[data-section="tools"] table.widefat {
    border: 1px solid var(--ns-border-light);
    border-radius: 8px;
    overflow: hidden;
}

.newssync-content-section[data-section="tools"] table.widefat thead th {
    background: var(--ns-content-bg);
    color: var(--ns-text-primary);
    font-weight: 600;
    padding: 12px 16px;
    border-bottom: 2px solid var(--ns-border-medium);
}

.newssync-content-section[data-section="tools"] table.widefat tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--ns-border-light);
}

.newssync-content-section[data-section="tools"] table.widefat tbody tr:last-child td {
    border-bottom: none;
}

.newssync-content-section[data-section="tools"] table.widefat tbody tr:hover {
    background: var(--ns-content-bg);
}
    background: #fff;
    font-size: 0.9rem;
    color: #000;
    border: 1px solid #ccd0d4;
    padding: 8px 14px;
    height: 38px;
    line-height: 1;
    border-radius: 4px;
}

/* === Settings inner tabs === */
.ns-settings-tabs-nav {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}
.ns-tab-button {
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid var(--ns-border-light);
    background: transparent;
    cursor: pointer;
}
.ns-tab-button.ns-tab-active {
    background: var(--ns-primary-light);
    border-color: var(--ns-primary);
    color: var(--ns-primary-dark);
}
.ns-settings-tab-pane { display: none; }
.ns-settings-tab-pane.ns-settings-tab-active { display: block; }
