/**
 * Custom Toggle Button Styles
 * 
 * @package Dark_Reader_Pro
 * @since 1.1.2
 */

/* Custom Toggle Button Editor Modal */
.dark-reader-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dark-reader-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(34, 113, 177, 0.95) 0%, rgba(99, 102, 241, 0.95) 100%);
    backdrop-filter: blur(8px);
}

.dark-reader-modal-content {
    position: relative;
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.4);
    max-width: 1200px;
    width: 90%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    animation: modalSlideIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-40px) scale(0.9);
    }

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

.dark-reader-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 28px 36px;
    background: linear-gradient(135deg, #2271b1 0%, #5b86e5 100%);
    border-bottom: none;
}

.dark-reader-modal-header h2 {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 14px;
    color: #ffffff;
    letter-spacing: -0.3px;
}

.dark-reader-modal-header svg {
    color: rgba(255, 255, 255, 0.9);
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.dark-reader-modal-close {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    padding: 10px;
    cursor: pointer;
    border-radius: 10px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: #ffffff;
    backdrop-filter: blur(10px);
}

.dark-reader-modal-body {
    flex: 1;
    overflow: hidden;
    padding: 0;
}

.dark-reader-custom-toggle-editor {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 0;
    height: 100%;
    max-height: calc(90vh - 160px);
    /* Subtract header and footer height */
}

/* Editor Settings (Left Panel) */
.dark-reader-editor-settings {
    padding: 36px;
    overflow-y: auto;
    background: #fafbfc;
    border-right: 1px solid #e5e7eb;
    max-height: calc(90vh - 160px);
}

.dark-reader-setting-group {
    margin-bottom: 36px;
    padding: 24px;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    border: 1px solid #e5e7eb;
}

.dark-reader-setting-group.button-size-settings {
    margin-bottom: 100px;
}

.dark-reader-setting-group h3 {
    margin: 0 0 20px 0;
    font-size: 13px;
    font-weight: 700;
    color: #2271b1;
    text-transform: uppercase;
    letter-spacing: 1px;
    position: relative;
    padding-bottom: 12px;
}

.dark-reader-setting-group h3::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 40px;
    height: 3px;
    background: linear-gradient(90deg, #2271b1, #5b86e5);
    border-radius: 2px;
}

/* Setting Header with Reset Button */
.setting-header-with-reset {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.setting-header-with-reset h3 {
    margin: 0;
    padding-bottom: 0;
}

.setting-header-with-reset h3::after {
    display: none;
}

.dark-reader-reset-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(34, 113, 177, 0.1);
    color: #2271b1;
    border: 1px solid rgba(34, 113, 177, 0.2);
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.dark-reader-reset-btn:hover {
    background: rgba(34, 113, 177, 0.2);
    border-color: #2271b1;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(34, 113, 177, 0.2);
}

.dark-reader-reset-btn:active {
    transform: translateY(0);
}

.dark-reader-reset-btn svg {
    width: 14px;
    height: 14px;
}

/* Emoji Settings */
.emoji-settings {
    margin-bottom: 24px;
}

.emoji-setting-row {
    margin-bottom: 16px;
}

.emoji-setting-row:last-child {
    margin-bottom: 0;
}

.emoji-setting-row label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #ffffff;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}

.emoji-input-group {
    display: flex;
    gap: 12px;
    align-items: center;
}

.dark-reader-emoji-input {
    flex: 1;
    padding: 14px 18px;
    border: 2px solid #374151;
    border-radius: 8px;
    font-size: 32px;
    text-align: center;
    transition: all 0.2s;
    background: rgba(0, 0, 0, 0.3);
    color: #ffffff;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dark-reader-emoji-input:focus {
    outline: none;
    border-color: #2271b1;
    background: rgba(0, 0, 0, 0.4);
}

.dark-reader-emoji-picker-btn {
    padding: 14px 24px;
    background: linear-gradient(135deg, #2271b1 0%, #5b86e5 100%);
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(34, 113, 177, 0.3);
    white-space: nowrap;
    min-height: 60px;
}

.dark-reader-emoji-picker-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(34, 113, 177, 0.4);
}

.dark-reader-emoji-picker-btn:active {
    transform: translateY(0);
}

/* Color Settings */
.dark-reader-color-settings {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.color-setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 0;
}

.color-setting-row label {
    font-size: 14px;
    font-weight: 500;
    color: #000000;
    min-width: 180px;
    flex-shrink: 0;
}

.dark-reader-color-picker-wrapper {
    display: flex;
    gap: 12px;
    align-items: center;
    flex: 1;
    justify-content: flex-end;
}

.dark-reader-color-input {
    width: 50px;
    height: 40px;
    border: 2px solid #374151;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    background: transparent;
}

.dark-reader-color-input:hover {
    border-color: #2271b1;
    transform: scale(1.05);
}

.dark-reader-color-text {
    width: 180px;
    padding: 10px 14px;
    border: 2px solid #374151;
    border-radius: 8px;
    font-family: 'Monaco', 'Courier New', monospace;
    font-size: 13px;
    font-weight: 500;
    background: rgba(0, 0, 0, 0.2);
    color: #ffffff;
    text-align: center;
    transition: all 0.2s;
}

.dark-reader-color-text:focus {
    outline: none;
    border-color: #2271b1;
    background: rgba(0, 0, 0, 0.3);
}

/* Size Settings */
.dark-reader-size-settings {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.size-setting-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.size-setting-row label {
    font-size: 13px;
    font-weight: 500;
    color: #4b5563;
}

.dark-reader-slider-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
}

.dark-reader-size-slider {
    flex: 1;
    height: 8px;
    border-radius: 4px;
    background: linear-gradient(90deg, #e5e7eb 0%, #f3f4f6 100%);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.dark-reader-size-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2271b1 0%, #5b86e5 100%);
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(34, 113, 177, 0.4);
    transition: all 0.2s;
}

.dark-reader-size-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 3px 12px rgba(34, 113, 177, 0.5);
}

.dark-reader-size-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2271b1 0%, #5b86e5 100%);
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 8px rgba(34, 113, 177, 0.4);
    transition: all 0.2s;
}

.dark-reader-size-slider::-moz-range-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 3px 12px rgba(34, 113, 177, 0.5);
}

.size-value {
    min-width: 55px;
    text-align: right;
    font-size: 14px;
    font-weight: 700;
    color: #2271b1;
    background: rgba(34, 113, 177, 0.1);
    padding: 4px 12px;
    border-radius: 8px;
}

/* Editor Preview (Right Panel) */
.dark-reader-editor-preview {
    padding: 36px;
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    align-self: start;
    max-height: calc(90vh - 160px);
    overflow: hidden;
}

.preview-header {
    margin-bottom: 28px;
}

.preview-header h3 {
    margin: 0 0 20px 0;
    font-size: 13px;
    font-weight: 700;
    color: #2271b1;
    text-transform: uppercase;
    letter-spacing: 1px;
    position: relative;
    padding-bottom: 12px;
}

.preview-header h3::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 40px;
    height: 3px;
    background: linear-gradient(90deg, #2271b1, #5b86e5);
    border-radius: 2px;
}

.preview-mode-toggle {
    display: flex;
    gap: 10px;
    background: #e5e7eb;
    padding: 4px;
    border-radius: 12px;
}

.preview-mode-btn {
    flex: 1;
    padding: 10px 20px;
    border: none;
    background: transparent;
    border-radius: 10px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: #6b7280;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.preview-mode-btn.active {
    background: linear-gradient(135deg, #2271b1 0%, #5b86e5 100%);
    color: #fff;
    box-shadow: 0 4px 12px rgba(34, 113, 177, 0.3);
}

.preview-mode-btn:hover:not(.active) {
    color: #374151;
    background: rgba(255, 255, 255, 0.5);
}

.preview-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 16px;
    padding: 60px;
    position: relative;
    overflow: hidden;
    transition: background 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    margin-bottom: 20px;
    box-shadow: inset 0 2px 20px rgba(0, 0, 0, 0.2);
}

.preview-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg width="40" height="40" xmlns="http://www.w3.org/2000/svg"><rect width="20" height="20" fill="rgba(255,255,255,0.03)"/><rect x="20" y="20" width="20" height="20" fill="rgba(255,255,255,0.03)"/></svg>');
    opacity: 0.5;
}

.preview-container[data-preview-mode="dark"] {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

.custom-toggle-preview {
    position: relative;
}

.custom-toggle-btn {
    background: var(--custom-bg-color, #ffffff);
    border: var(--custom-border-width, 0px) solid var(--custom-border-color, transparent);
    border-radius: var(--custom-border-radius, 8px);
    width: var(--custom-button-size, 50px);
    height: var(--custom-button-size, 50px);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    z-index: 1;
    overflow: hidden;
}

.custom-toggle-btn .custom-toggle-icon {
    font-size: var(--custom-icon-size, 24px);
    color: var(--custom-icon-color, #000000);
    transition: all 0.4s;
    line-height: 1;
}

/* Modal Footer */
.dark-reader-modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 14px;
    padding: 24px 36px;
    border-top: 1px solid #e5e7eb;
    background: linear-gradient(180deg, #fafbfc 0%, #f3f4f6 100%);
}

.dark-reader-btn {
    padding: 12px 24px;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.dark-reader-btn-secondary {
    background: #ffffff;
    color: #374151;
    border: 2px solid #d1d5db;
}

.dark-reader-btn-secondary:hover {
    background: #f9fafb;
    border-color: #9ca3af;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.dark-reader-btn-primary {
    background: linear-gradient(135deg, #2271b1 0%, #5b86e5 100%);
    color: #fff;
    box-shadow: 0 4px 12px rgba(34, 113, 177, 0.3);
}

.dark-reader-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(34, 113, 177, 0.4);
}

.dark-reader-btn-primary:active {
    transform: translateY(0);
}

/* Emoji Picker Popup - Enhanced with Categories */
.dark-reader-emoji-popup {
    position: fixed;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
    padding: 20px;
    z-index: 100002;
    width: 500px;
    max-width: 90vw;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    animation: emojiPickerSlideIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes emojiPickerSlideIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(-10px);
    }

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

.emoji-picker-body {
    overflow-y: auto;
    flex: 1;
    padding-right: 8px;
}

.emoji-picker-body::-webkit-scrollbar {
    width: 10px;
}

.emoji-picker-body::-webkit-scrollbar-track {
    background: #f3f4f6;
    border-radius: 10px;
}

.emoji-picker-body::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #2271b1, #5b86e5);
    border-radius: 10px;
}

.emoji-picker-body::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #135e96, #4a75d4);
}

.emoji-category {
    margin-bottom: 24px;
}

.emoji-category:last-child {
    margin-bottom: 0;
}

.emoji-category-title {
    font-size: 11px;
    font-weight: 700;
    color: #2271b1;
    margin: 0 0 10px 0;
    padding: 6px 12px;
    background: linear-gradient(135deg, rgba(34, 113, 177, 0.1) 0%, rgba(91, 134, 229, 0.1) 100%);
    border-radius: 8px;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-left: 3px solid #2271b1;
}

.emoji-picker-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 6px;
}

.emoji-item {
    background: #f9fafb;
    border: 2px solid transparent;
    font-size: 26px;
    padding: 10px;
    cursor: pointer;
    border-radius: 10px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.emoji-item:hover {
    background: linear-gradient(135deg, rgba(34, 113, 177, 0.1) 0%, rgba(91, 134, 229, 0.1) 100%);
    border-color: #2271b1;
    transform: scale(1.25);
    box-shadow: 0 4px 12px rgba(34, 113, 177, 0.2);
    z-index: 1;
}

.emoji-item:active {
    transform: scale(1.15);
}

/* Custom Toggle Button Styles (Frontend) */
.dark-reader-toggle.style-custom button,
.dark-reader-toggle-inline.style-custom button {
    background: var(--custom-bg-color-light, #ffffff);
    border: var(--custom-border-width, 0px) solid var(--custom-border-color-light, transparent);
    border-radius: var(--custom-border-radius, 8px);
    width: var(--custom-button-size, 50px);
    height: var(--custom-button-size, 50px);
    padding: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.dark-reader-toggle.style-custom button:hover,
.dark-reader-toggle-inline.style-custom button:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.dark-reader-toggle.style-custom .custom-icon,
.dark-reader-toggle-inline.style-custom .custom-icon {
    font-size: var(--custom-icon-size, 24px);
    color: #000000;
    transition: all 0.3s;
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dark-reader-toggle.style-custom .custom-icon.light-icon,
.dark-reader-toggle-inline.style-custom .custom-icon.light-icon {
    opacity: 1;
}

.dark-reader-toggle.style-custom .custom-icon.dark-icon,
.dark-reader-toggle-inline.style-custom .custom-icon.dark-icon {
    opacity: 0;
}

/* Dark mode active state */
body.dark-mode .dark-reader-toggle.style-custom button,
body.dark-mode .dark-reader-toggle-inline.style-custom button {
    background: var(--custom-bg-color-dark, #1a1a1a);
    border-color: var(--custom-border-color-dark, transparent);
}

body.dark-mode .dark-reader-toggle.style-custom .custom-icon,
body.dark-mode .dark-reader-toggle-inline.style-custom .custom-icon {
    color: #ffffff;
}

body.dark-mode .dark-reader-toggle.style-custom .custom-icon.light-icon,
body.dark-mode .dark-reader-toggle-inline.style-custom .custom-icon.light-icon {
    opacity: 0;
}

body.dark-mode .dark-reader-toggle.style-custom .custom-icon.dark-icon,
body.dark-mode .dark-reader-toggle-inline.style-custom .custom-icon.dark-icon {
    opacity: 1;
}

/* Custom Toggle Settings Button */
.dark-reader-custom-toggle-section {
    margin-top: 16px;
    padding: 20px;
    background: #f0f6fc;
    border-radius: 8px;
    border-left: 4px solid #2271b1;
}

.dark-reader-custom-toggle-settings {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #d1d5db;
}

.dark-reader-open-custom-toggle-editor {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: #2271b1;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.dark-reader-open-custom-toggle-editor:hover {
    background: #135e96;
}

.dark-reader-open-custom-toggle-editor svg {
    width: 16px;
    height: 16px;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .dark-reader-custom-toggle-editor {
        grid-template-columns: 1fr;
    }

    .dark-reader-editor-preview {
        border-top: 1px solid #e5e7eb;
        border-left: none;
    }

    .dark-reader-emoji-popup {
        width: 360px;
    }

    .emoji-picker-grid {
        grid-template-columns: repeat(6, 1fr);
    }
}

@media (max-width: 768px) {
    .dark-reader-modal-content {
        width: 95%;
        max-height: 95vh;
    }

    .dark-reader-editor-settings,
    .dark-reader-editor-preview {
        padding: 20px;
    }

    .dark-reader-emoji-popup {
        width: 320px;
    }

    .emoji-picker-grid {
        grid-template-columns: repeat(5, 1fr);
    }
}