/* Admin Optimizer Yoast-Style UI */
:root {
    --cdvao-primary: #a4286a;
    /* Yoast Purple */
    --cdvao-primary-hover: #8b225a;
    --cdvao-bg: #f0f0f1;
    /* WP Admin Grey / Yoast bg */
    --cdvao-sidebar-bg: #ffffff;
    --cdvao-card-bg: #ffffff;
    --cdvao-text: #1e1e1e;
    --cdvao-text-secondary: #a8a8a8;
    --cdvao-border: #dcdcde;
    --cdvao-success: #008a20;
    /* Yoast Green? Or standard green */
    --cdvao-danger: #d63638;
    --cdvao-radius: 4px;
    /* Yoast uses slightly squarer corners usually, or 4px */
    --cdvao-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --cdvao-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.025);
    --cdvao-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    /* Native WP font */
}

* {
    box-sizing: border-box;
}

.toplevel_page_admin-menu-optimizer .wrap {
    margin: 20px 20px 0 0;
    max-width: 1280px;
    font-family: var(--cdvao-font);
}

.toplevel_page_admin-menu-optimizer h1 {
    display: block;
    font-size: 2rem;
    font-weight: 700;
    margin: 20px 0 30px 0;
    color: #1e1e1e;
}

input[type=checkbox]:checked::before {
    display: none !important;
}

.description {
    font-style: italic;
    opacity: 0.8;
}

.cdvao-control-group {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

label.cdvao-control-label {
    font-size: 16px;
    font-weight: 500;
}

/* Main Container */
.cdvao-wrapper {
    display: flex;
    background: var(--cdvao-bg);
    border-radius: var(--cdvao-radius);
    box-shadow: var(--cdvao-shadow-lg);
    border: 1px solid var(--cdvao-border);
    overflow: hidden;
    min-height: 700px;
}

/* Sidebar */
.cdvao-sidebar {
    width: 280px;
    background: var(--cdvao-sidebar-bg);
    border-right: 1px solid var(--cdvao-border);
    display: flex;
    flex-direction: column;
    padding: 15px;
}

.cdvao-brand {
    padding: 30px;
    border-bottom: 1px solid var(--cdvao-border);
    margin-bottom: 10px;
}

.cdvao-brand h2 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--cdvao-primary) 0%, #818cf8 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.025em;
}

.cdvao-nav {
    padding: 10px 16px;
    flex: 1;
}

.cdvao-tab-link {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    margin-bottom: 4px;
    color: var(--cdvao-text-secondary);
    text-decoration: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 500;
    font-size: 0.95rem;
    border-radius: 8px;
    cursor: pointer;
}

.cdvao-tab-link:hover {
    color: var(--cdvao-primary);
    background: #f1f5f9;
    transform: translateX(2px);
}

.cdvao-tab-link.active {
    color: #ffffff;
    background: var(--cdvao-primary);
    box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.2);
}

.cdvao-tab-link.active .dashicons {
    color: #ffffff;
}

.cdvao-tab-link .dashicons {
    margin-right: 12px;
    font-size: 20px;
    width: 20px;
    height: 20px;
    color: #94a3b8;
    transition: color 0.2s;
}

/* Content Area */
.cdvao-content {
    flex: 1;
    padding: 40px 60px;
    background: #ffffff;
    overflow-y: auto;
    position: relative;
}

.cdvao-header {
    margin-bottom: 40px;
}

.cdvao-header h2 {
    font-size: 1.875rem;
    font-weight: 800;
    margin: 0 0 10px 0;
    color: var(--cdvao-text);
    letter-spacing: -0.025em;
}

.cdvao-header p {
    margin: 0;
    color: var(--cdvao-text-secondary);
    font-size: 14px;
    line-height: 1.6;
    font-weight: 300;
}

/* Tab Animation */
.cdvao-tab-content {
    display: none;
    animation: slideUpFade 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.cdvao-tab-content.active {
    display: block;
}

@keyframes slideUpFade {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Form Elements */
.form-table {
    margin-top: 0;
}

.form-table th {
    font-weight: 600;
    color: var(--cdvao-text);
    padding: 25px 10px 25px 0;
    width: 250px;
    font-size: 0.95rem;
}

.form-table td {
    padding: 20px 0;
}

.description {
    color: var(--cdvao-text-secondary);
    font-size: 0.9rem;
    margin-top: 8px;
    line-height: 1.5;
}

/* Modern Inputs */
input[type="text"],
input[type="number"],
input[type="email"],
input[type="url"],
input[type="password"],
textarea {
    background: #f8fafc;
    border: 1px solid var(--cdvao-border);
    border-radius: 8px;
    padding: 10px 16px;
    width: 100%;
    max-width: 480px;
    transition: all 0.2s ease;
    font-size: 0.95rem;
    color: var(--cdvao-text);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.02);
}

/* Modern Select Boxes - Yoast Style Detailed */
select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-color: #fff;
    /* Double arrow icon for better UX */
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%23757575"><path d="M7 10l5-5 5 5zM7 14l5 5 5-5z"/></svg>');
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 20px;
    padding: 12px 48px 12px 16px;
    border: 1px solid var(--cdvao-border);
    border-radius: 4px;
    /* Matches Yoast radius */
    font-size: 1rem;
    color: var(--cdvao-text);
    line-height: 1.5;
    cursor: pointer;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.02);
    min-width: 250px;
    min-height: 48px;
    /* Taller hit area */
}

select:focus {
    border-color: var(--cdvao-primary);
    box-shadow: 0 0 0 2px rgba(164, 40, 106, 0.1);
    /* Matches primary color glow */
    outline: none;
}

/* For multi-select (not currently used but safe to exclude) */
select[multiple] {
    background-image: none;
    padding: 10px;
}

input:focus,
textarea:focus {
    background: #fff;
    border-color: var(--cdvao-primary);
    box-shadow: 0 0 0 3px rgba(164, 40, 106, 0.1);
    outline: none;
}

textarea {
    max-width: 100%;
    line-height: 1.6;
}

/* Modern Yoast-Style Toggle Switch */
input[type="checkbox"] {
    -webkit-appearance: none;
    appearance: none;
    width: 48px;
    height: 24px;
    background: #cbd5e1;
    /* Off/Grey state */
    border-radius: 24px;
    position: relative;
    cursor: pointer;
    outline: none;
    border: none;
    transition: background 0.3s ease;
    vertical-align: middle;
    margin-right: 10px;
}

/* The Knob */
input[type="checkbox"]::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background-color: white;
    border-radius: 50%;
    transition: transform 0.3s cubic-bezier(0.3, 1.5, 0.7, 1);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);

    /* Cross Icon (Default/Unchecked) */
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%23555"><path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/></svg>');
    background-size: 12px;
    background-repeat: no-repeat;
    background-position: center;
}

/* Checked State */
input[type="checkbox"]:checked {
    background: var(--cdvao-primary);
}

/* knob moves right */
input[type="checkbox"]:checked::after {
    transform: translateX(24px);

    /* Check Icon (Checked) - Purple Color to match branding */
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%23a4286a"><path d="M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"/></svg>');
}

input[type="checkbox"]:hover {
    background: #94a3b8;
}

input[type="checkbox"]:checked:hover {
    background: var(--cdvao-primary-hover);
}

/* Specific override for Menu Editor visibility eye icons (hide checkbox logic) */
.cdvao-visibility-toggle input[type="checkbox"] {
    display: none;
}

.cdvao-visibility-toggle .dashicons {
    font-size: 20px;
    color: var(--cdvao-text-secondary);
    transition: color 0.2s;
    display: flex;
    /* Ensure vertical center */
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.cdvao-visibility-toggle input:not(:checked)+.dashicons {
    color: var(--cdvao-success);
}

.cdvao-visibility-toggle input:not(:checked)+.dashicons:before {
    content: "\f177";
    /* dashicons-visibility */
    font-family: dashicons;
}

.cdvao-visibility-toggle input:checked+.dashicons {
    color: var(--cdvao-danger);
}

.cdvao-visibility-toggle input:checked+.dashicons:before {
    content: "\f530";
    /* dashicons-hidden */
    font-family: dashicons;
}

/* Buttons */
.submit {
    margin-top: 50px;
    padding-top: 30px;
    border-top: 1px solid var(--cdvao-border);
    display: flex;
    justify-content: flex-end;
}

.button-primary {
    background: var(--cdvao-primary) !important;
    border: none !important;
    padding: 12px 32px !important;
    font-size: 1rem !important;
    font-weight: 600 !important;
    height: auto !important;
    border-radius: 8px !important;
    transition: all 0.2s !important;
    box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.2) !important;
    text-shadow: none !important;
}

.button-primary:hover {
    background: var(--cdvao-primary-hover) !important;
    transform: translateY(-1px);
    box-shadow: 0 6px 8px -1px rgba(79, 70, 229, 0.3) !important;
}

/* Menu Editor UI */
.cdvao-menu-list {
    list-style: none;
    padding: 0;
    margin: 20px 0;
    border: 1px solid var(--cdvao-border);
    border-radius: 8px;
    /* Slightly tighter radius for list */
    background: #fff;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    /* Subtle shadow */
}

.cdvao-menu-item {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    /* Reduced vertical padding for density */
    border-bottom: 1px solid var(--cdvao-border);
    background: #fff;
    transition: background 0.2s;
}

.cdvao-menu-item:last-child {
    border-bottom: none;
}

.cdvao-menu-item:hover {
    background: #f8fafc;
}

.cdvao-menu-handle {
    cursor: move;
    color: #cbd5e1;
    margin-right: 15px;
    padding: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cdvao-menu-handle:hover {
    color: var(--cdvao-text);
}

.cdvao-menu-icon {
    width: 30px;
    margin-right: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--cdvao-text-secondary);
}

.cdvao-menu-details {
    flex: 1;
    display: grid;
    /* Grid for perfect alignment */
    grid-template-columns: 180px 1fr;
    /* Fixed width for label, rest for input */
    align-items: center;
    /* Vertical alignment */
    gap: 20px;
}

.cdvao-menu-details .original-label {
    font-weight: 500;
    color: var(--cdvao-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Explicit Input Styling for Menu Editor */
.cdvao-menu-item input[type="text"] {
    background: #fff;
    border: 1px solid var(--cdvao-border);
    box-shadow: none;
    /* simple, clean */
    padding: 6px 12px;
    max-width: 100%;
    color: var(--cdvao-text);
    font-size: 0.9rem;
    height: 36px;
    /* consistent height */
}

.cdvao-menu-item input[type="text"]:focus {
    border-color: var(--cdvao-primary);
    box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.1);
}

.cdvao-menu-item input[type="text"]::placeholder {
    color: #94a3b8;
}

.cdvao-menu-actions {
    margin-left: 20px;
    display: flex;
    align-items: center;
    padding-left: 20px;
    border-left: 1px solid var(--cdvao-border);
    /* Separator line */
    height: 24px;
}

.original-label {
    min-width: 180px;
    color: var(--cdvao-text-secondary);
    font-size: 0.9rem;
}

.cdvao-visibility-toggle {
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    transition: background 0.2s;
}

.cdvao-visibility-toggle input {
    display: none;
}

.cdvao-visibility-toggle:hover {
    background: #f1f5f9;
}

.cdvao-visibility-toggle .dashicons {
    font-size: 20px;
}

/* Code Editor tweaks */
.CodeMirror {
    border: 1px solid var(--cdvao-border);
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.5;
}

/* Responsive */
@media (max-width: 960px) {
    .cdvao-wrapper {
        flex-direction: column;
    }

    .cdvao-sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--cdvao-border);
    }

    .cdvao-nav {
        display: flex;
        overflow-x: auto;
        padding-bottom: 0;
    }

    .cdvao-tab-link {
        white-space: nowrap;
        margin-right: 10px;
    }

    .cdvao-content {
        padding: 20px;
    }
}

/* Custom Select UI (Yoast Style) */
.cdvao-select-wrapper {
    position: relative;
    width: 100%;
    max-width: 480px;
    /* Match other inputs */
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

/* Hide default select when custom UI is active */
.cdvao-select-wrapper select {
    display: none !important;
}

/* Custom Select Button */
.cdvao-select-button {
    width: 100%;
    padding: 12px 40px 12px 16px;
    background: white;
    border: 1px solid var(--cdvao-border);
    border-radius: 4px;
    font-size: 14px;
    color: var(--cdvao-text);
    cursor: pointer;
    text-align: left;
    position: relative;
    transition: all 0.2s ease;
    min-height: 48px;
    /* consistent height */
    display: flex;
    align-items: center;
}

.cdvao-select-button:hover {
    border-color: #a7aaad;
}

.cdvao-select-button:focus,
.cdvao-select-button.active {
    outline: none;
    border-color: var(--cdvao-primary);
    box-shadow: 0 0 0 1px var(--cdvao-primary);
}

/* Dropdown Arrow */
.cdvao-select-button::after {
    content: "";
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid #646970;
    transition: transform 0.2s ease;
}

.cdvao-select-button.active::after {
    transform: translateY(-50%) rotate(180deg);
}

/* Dropdown Menu */
.cdvao-select-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--cdvao-border);
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
    z-index: 1000;
    overflow: hidden;
    max-height: 300px;
    overflow-y: auto;
}

.cdvao-select-dropdown.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Dropdown Options */
.cdvao-select-option {
    padding: 12px 16px;
    font-size: 14px;
    color: var(--cdvao-text);
    cursor: pointer;
    transition: background-color 0.15s ease;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.cdvao-select-option:hover {
    background-color: #f6f7f7;
}

/* Selected Option Style */
.cdvao-select-option.selected {
    background: var(--cdvao-primary);
    color: white;
    font-weight: 500;
}

.cdvao-select-option.selected:hover {
    background: var(--cdvao-primary-hover);
}

/* Checkmark for selected option */
.cdvao-select-option.selected::after {
    content: "✓";
    font-size: 18px;
    font-weight: bold;
    margin-left: auto;
}

/* Sidebar Recommendations */
.cdvao-recommend-section {
    margin-top: auto;
    padding: 20px 16px;
    border-top: 1px solid var(--cdvao-border);
}

.cdvao-recommend-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--cdvao-text-secondary);
    font-weight: 700;
    margin-bottom: 15px;
    letter-spacing: 0.05em;
}

.cdvao-recommend-card {
    background: #f8fafc;
    border: 1px solid var(--cdvao-border);
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 10px;
    transition: all 0.2s ease;
}

.cdvao-recommend-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--cdvao-shadow);
    border-color: var(--cdvao-primary);
    background: #fff;
}

.cdvao-recommend-card h4 {
    margin: 0 0 6px 0;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--cdvao-text);
}

.cdvao-recommend-card p {
    margin: 0 0 10px 0;
    font-size: 0.8rem;
    color: var(--cdvao-text-secondary);
    line-height: 1.4;
}

.cdvao-recommend-link {
    display: inline-flex;
    align-items: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--cdvao-primary);
    text-decoration: none;
}

.cdvao-recommend-link:hover {
    color: var(--cdvao-primary-hover);
}

.cdvao-recommend-link .dashicons {
    font-size: 14px;
    width: 14px;
    height: 14px;
    margin-left: 2px;
}