/* Modern Settings Base CSS */
:root {
    --wesub-primary: #6366f1; /* More vibrant indigo */
    --wesub-primary-hover: #4f46e5;
    --wesub-primary-light: #e0e7ff;
    --wesub-bg: #f9fafb;
    --wesub-card-bg: rgba(255, 255, 255, 0.9);
    --wesub-text-main: #0f172a;
    --wesub-text-muted: #64748b;
    --wesub-border: #e2e8f0;
    --wesub-shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --wesub-shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.05), 0 2px 4px -2px rgb(0 0 0 / 0.05);
    --wesub-shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.05), 0 4px 6px -4px rgb(0 0 0 / 0.05);
    --wesub-shadow-glow: 0 0 20px rgba(99, 102, 241, 0.15);
    --wesub-radius: 16px;
    --wesub-transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Main Wrapper & Layout Reset */
.wesub-wrap {
    max-width: 1100px;
    margin: 30px auto;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: var(--wesub-text-main);
    animation: fadeSlideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

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

/* --- Modern Pill Navigation --- */
.wesub-header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 40px;
    background: var(--wesub-card-bg);
    padding: 16px 24px;
    border-radius: 20px;
    box-shadow: var(--wesub-shadow-md);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    flex-wrap: wrap;
    gap: 16px;
}

.wesub-nav-pill-wrapper {
    display: flex;
    gap: 12px;
}

.wesub-pill-tab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    color: var(--wesub-text-muted);
    text-decoration: none;
    background: transparent;
    transition: var(--wesub-transition);
}

.wesub-pill-tab:hover {
    background: var(--wesub-primary-light);
    color: var(--wesub-primary-hover);
}

.wesub-pill-tab.wesub-pill-active {
    background: var(--wesub-primary);
    color: #ffffff;
    box-shadow: 0 4px 10px rgba(99, 102, 241, 0.3);
}

.wesub-pill-tab .dashicons {
    font-size: 18px;
    width: 18px;
    height: 18px;
}

/* Header Actions */
.wesub-header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.wesub-support-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    color: #475569;
    background: #f1f5f9;
    text-decoration: none;
    transition: var(--wesub-transition);
}

.wesub-support-pill:hover {
    background: #e2e8f0;
    color: #0f172a;
}

.wesub-support-pill .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
}

.wesub-version-pill {
    font-size: 12px;
    font-weight: 600;
    color: #94a3b8;
    background: transparent;
    padding: 4px 0;
}

/* Forms and Cards */
#we-settings-form {
    max-width: 900px; /* Optimal width for two columns */
    margin: 0 auto;
    padding-bottom: 40px; /* Room for floating action bar */
}

.wesub-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 32px;
    align-items: stretch; /* Cards in the same row will match height for a cleaner look */
}

.wesub-card {
    background: var(--wesub-card-bg);
    border-radius: var(--wesub-radius);
    padding: 32px;
    box-shadow: var(--wesub-shadow-sm);
    border: 1px solid var(--wesub-border);
    transition: var(--wesub-transition);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.wesub-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
    background: transparent;
    transition: var(--wesub-transition);
}

.wesub-card:hover {
    box-shadow: var(--wesub-shadow-lg), var(--wesub-shadow-glow);
    transform: translateY(-2px);
    border-color: #cbd5e1;
}

.wesub-card:hover::before {
    background: linear-gradient(90deg, var(--wesub-primary), #a855f7);
}

.wesub-card h2 {
    font-size: 18px;
    font-weight: 700;
    color: var(--wesub-text-main);
    margin: 0 0 24px 0;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--wesub-border);
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Form Elements */
.wesub-form-group {
    margin-bottom: 24px;
}
.wesub-form-group:last-child { margin-bottom: 0; }

.wesub-description {
    font-size: 13px;
    color: var(--wesub-text-muted);
    margin-top: 8px;
    line-height: 1.5;
}

#we-settings-form label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--wesub-text-main);
}

#we-settings-form input[type="text"],
#we-settings-form select {
    width: 100%;
    padding: 12px 16px;
    height: 46px;
    border: 1px solid var(--wesub-border);
    border-radius: 10px;
    font-size: 14px;
    color: var(--wesub-text-main);
    background-color: #f8fafc;
    transition: var(--wesub-transition);
    box-shadow: inset 0 2px 4px 0 rgb(0 0 0 / 0.02);
}

#we-settings-form input[type="text"]:focus,
#we-settings-form select:focus {
    border-color: var(--wesub-primary);
    background-color: #ffffff;
    box-shadow: 0 0 0 4px var(--wesub-primary-light);
    outline: none;
}

/* Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 28px;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #cbd5e1;
    transition: .4s cubic-bezier(0.16, 1, 0.3, 1);
    border-radius: 34px;
}
.slider:before {
    position: absolute;
    content: "";
    height: 22px; width: 22px;
    left: 3px; bottom: 3px;
    background-color: white;
    transition: .4s cubic-bezier(0.16, 1, 0.3, 1);
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
input:checked + .slider { background-color: var(--wesub-primary); }
input:focus + .slider { box-shadow: 0 0 0 4px var(--wesub-primary-light); }
input:checked + .slider:before { transform: translateX(22px); }

/* Submit Button Action Bar */
.wesub-actions {
    margin-top: 40px;
    margin-left: auto;
    width: max-content;
    display: flex;
    position: sticky;
    bottom: 30px;
    z-index: 100;
    pointer-events: none; /* Let clicks pass through the container */
}
#we-settings-form .button {
    background: linear-gradient(135deg, var(--wesub-primary), #a855f7);
    color: white;
    padding: 14px 36px;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--wesub-transition);
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
    pointer-events: auto;
}
#we-settings-form .button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.6);
}
#we-settings-form .button:active {
    transform: translateY(0);
}

/* Modal and Badges */
.wesub-modal {
    display: none; position: fixed; z-index: 10000;
    left: 0; top: 0; width: 100%; height: 100%;
    background-color: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(8px);
}
.wesub-modal-content {
    background-color: white; margin: 10vh auto; padding: 40px;
    border-radius: 24px; box-shadow: 0 25px 50px -12px rgba(0,0,0,0.3);
    width: 90%; max-width: 600px;
    animation: fadeSlideUp 0.3s ease-out;
}
.wesub-close {
    color: #94a3b8; float: right; font-size: 28px; line-height: 1; transition: 0.2s;
}
.wesub-close:hover { color: #0f172a; cursor: pointer; }

.wesub-status-badge {
    display: inline-flex; align-items: center; padding: 6px 12px;
    border-radius: 999px; font-size: 12px; font-weight: 700;
    white-space: nowrap;
}
.wesub-status-badge.status-active, .wesub-status-badge.status-completed { background: #dcfce7; color: #166534; }
.wesub-status-badge.status-on-hold, .wesub-status-badge.status-processing { background: #ffedd5; color: #9a3412; }
.wesub-status-badge.status-cancelled, .wesub-status-badge.status-failed { background: #fee2e2; color: #991b1b; }
.wesub-status-badge.status-expired { background: #f1f5f9; color: #334155; }
.wesub-status-badge.status-pending, .wesub-status-badge.status-pending-payment { background: #fef9c3; color: #854d0e; }

/* --- Modern List Table --- */
.wesub-wrap .wp-list-table {
    background: var(--wesub-card-bg);
    border: 1px solid var(--wesub-border);
    border-radius: var(--wesub-radius);
    box-shadow: var(--wesub-shadow-sm);
    overflow: hidden;
    border-collapse: separate;
    border-spacing: 0;
    width: 100%;
    table-layout: auto;
}

.wesub-wrap .wp-list-table thead th,
.wesub-wrap .wp-list-table tfoot th {
    background: #f8fafc;
    color: var(--wesub-text-main);
    font-weight: 600;
    border-bottom: 1px solid var(--wesub-border);
    padding: 14px 16px;
}

.wesub-wrap .wp-list-table tbody td,
.wesub-wrap .wp-list-table tbody th {
    padding: 14px 16px;
    border-bottom: 1px solid #f1f5f9;
    color: var(--wesub-text-muted);
    vertical-align: middle;
}

.wesub-wrap .wp-list-table tbody tr:last-child td,
.wesub-wrap .wp-list-table tbody tr:last-child th {
    border-bottom: none;
}

.wesub-wrap .wp-list-table tbody tr:hover {
    background: rgba(99, 102, 241, 0.03);
}

/* Modals Modern Table override */
.wesub-modal-content .wp-list-table {
    border: 1px solid var(--wesub-border);
    border-radius: 12px;
    box-shadow: none;
    margin-top: 20px;
}

/* --- Search Box & TableNav Layout Fixes --- */
.wesub-wrap .search-box {
    margin-bottom: 16px;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    align-items: center;
    float: right;
    clear: both;
}

.wesub-wrap .search-box input[type="search"] {
    padding: 8px 12px;
    border: 1px solid var(--wesub-border);
    border-radius: 8px;
    font-size: 14px;
    box-shadow: none;
}

.wesub-wrap .search-box input[type="search"]:focus {
    border-color: var(--wesub-primary);
    box-shadow: 0 0 0 3px var(--wesub-primary-light);
}

.wesub-wrap .search-box input[type="submit"] {
    background: var(--wesub-primary-light);
    color: var(--wesub-primary-hover);
    border: none;
    border-radius: 8px;
    padding: 8px 16px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--wesub-transition);
}

.wesub-wrap .search-box input[type="submit"]:hover {
    background: var(--wesub-primary);
    color: white;
}

.wesub-wrap .tablenav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    clear: both;
    padding-top: 10px;
}

.wesub-wrap .tablenav.bottom {
    margin-top: 16px;
    margin-bottom: 0;
}

.wesub-wrap .tablenav .actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.wesub-wrap .tablenav select {
    padding: 6px 12px;
    border-radius: 8px;
    border: 1px solid var(--wesub-border);
    height: auto;
    line-height: normal;
}

.wesub-wrap .tablenav input[type="submit"] {
    background: white;
    border: 1px solid var(--wesub-border);
    border-radius: 8px;
    padding: 6px 16px;
    color: var(--wesub-text-main);
    cursor: pointer;
    transition: var(--wesub-transition);
    height: auto;
    line-height: normal;
}

.wesub-wrap .tablenav input[type="submit"]:hover {
    border-color: var(--wesub-primary);
    color: var(--wesub-primary);
}

.wesub-wrap .tablenav .displaying-num {
    color: var(--wesub-text-muted);
    font-weight: 500;
    font-size: 13px;
    margin: 0;
}

.wesub-wrap .tablenav .tablenav-pages {
    display: flex;
    align-items: center;
    margin: 0 0 0 auto; /* Push to the right edge regardless of middle empty divs */
}

/* Modernize WP internal layout elements like the View Renewals button */
.wesub-wrap .wp-list-table .button {
    white-space: nowrap;
    border-radius: 8px;
    padding: 4px 12px;
    font-size: 13px;
    font-weight: 600;
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    color: #334155;
    transition: var(--wesub-transition);
}

.wesub-wrap .wp-list-table .button:hover {
    background: #e2e8f0;
    border-color: #94a3b8;
    color: #0f172a;
}

/* Remove default WP borders/shadows */
.wesub-wrap td, .wesub-wrap th { box-shadow: none !important; }

/* Prevent Expiry and Renewals columns from overlapping */
.wesub-wrap .wp-list-table th.column-renewals,
.wesub-wrap .wp-list-table td.column-renewals {
    min-width: 140px;
}
.wesub-wrap .wp-list-table th.column-expiry,
.wesub-wrap .wp-list-table td.column-expiry,
.wesub-wrap .wp-list-table th.column-next_renewal,
.wesub-wrap .wp-list-table td.column-next_renewal {
    min-width: 120px;
    white-space: nowrap;
}