/* Widget Page Styles */

.widget-page {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
}

.widget-page .back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #667eea;
    text-decoration: none;
    font-size: 14px;
    margin-bottom: 20px;
}

.widget-page .back-link svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.widget-page .back-link:hover {
    text-decoration: underline;
}

/* Header */
.widget-header {
    text-align: center;
    margin-bottom: 30px;
}

.widget-header h1 {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    font-size: 28px;
    margin-bottom: 10px;
    color: #333;
}

.widget-header h1 svg {
    color: #667eea;
}

.widget-subtitle {
    color: #666;
    font-size: 16px;
}

/* Search Section */
.widget-search-section {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 30px;
}

.widget-search-section h2 {
    font-size: 18px;
    margin-bottom: 15px;
    color: #333;
}

.search-form {
    display: flex;
    gap: 10px;
}

.server-input {
    flex: 1;
    padding: 12px 16px;
    font-size: 16px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    outline: none;
    transition: border-color 0.2s;
}

.server-input:focus {
    border-color: #667eea;
}

.search-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.2s;
}

.search-btn:hover {
    background: #5a6fd6;
}

.search-hint {
    margin-top: 10px;
    font-size: 13px;
    color: #888;
}

/* Server Preview */
.widget-preview-section {
    margin-bottom: 30px;
}

.widget-preview-section h2 {
    font-size: 18px;
    margin-bottom: 15px;
    color: #333;
}

.server-preview-card {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.preview-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 15px;
}

.preview-header .country-flag {
    width: 28px;
    height: 21px;
    border-radius: 3px;
}

.preview-header h3 {
    font-size: 18px;
    color: #333;
    margin: 0;
}

.preview-info {
    display: grid;
    gap: 8px;
}

.preview-info .info-row {
    display: flex;
    gap: 10px;
}

.preview-info .label {
    color: #888;
    min-width: 80px;
}

.preview-info .value {
    color: #333;
    font-weight: 500;
}

/* Widget Styles Section */
.widget-styles-section {
    margin-bottom: 30px;
}

.widget-styles-section h2 {
    font-size: 18px;
    margin-bottom: 15px;
    color: #333;
}

.style-options {
    display: flex;
    gap: 20px;
}

.style-option {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.style-option input[type="radio"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.style-label {
    font-size: 15px;
    color: #333;
}

/* Embed Section */
.widget-embed-section {
    margin-bottom: 30px;
}

.widget-embed-section h2 {
    font-size: 18px;
    margin-bottom: 20px;
    color: #333;
}

.embed-option {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
}

.embed-option h3 {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
    margin-bottom: 10px;
    color: #333;
}

.embed-option h3 svg {
    color: #667eea;
}

.embed-desc {
    font-size: 14px;
    color: #666;
    margin-bottom: 15px;
}

/* Widget Notice */
.widget-notice {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 16px;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.08), rgba(118, 75, 162, 0.08));
    border-left: 3px solid #667eea;
    border-radius: 6px;
    margin-bottom: 15px;
    font-size: 13px;
    color: #555;
    line-height: 1.5;
}

.widget-notice svg {
    color: #667eea;
    margin-top: 2px;
}

/* Preview Container */
.preview-container {
    background: #f5f5f5;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 15px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.preview-container.iframe-preview {
    min-height: 180px;
}

.widget-image-preview {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
}

/* Code Tabs */
.code-tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 10px;
    border-bottom: 1px solid #e0e0e0;
    padding-bottom: 10px;
}

.code-tab {
    padding: 8px 16px;
    background: none;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    color: #666;
    transition: all 0.2s;
}

.code-tab:hover {
    border-color: #667eea;
    color: #667eea;
}

.code-tab.active {
    background: #667eea;
    border-color: #667eea;
    color: white;
}

/* Code Content */
.code-content {
    position: relative;
    background: #1e1e1e;
    border-radius: 8px;
    padding: 15px;
}

.code-content pre {
    margin: 0;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 13px;
    color: #d4d4d4;
    white-space: pre-wrap;
    word-break: break-all;
    line-height: 1.5;
    overflow-x: auto;
}

.copy-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 4px;
    color: #fff;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.2s;
}

.copy-btn:hover {
    background: rgba(255,255,255,0.2);
}

.copy-btn svg {
    fill: currentColor;
}

/* Error & Empty States */
.error-message,
.no-server-message {
    text-align: center;
    padding: 60px 20px;
    color: #666;
}

.error-message svg,
.no-server-message svg {
    color: #999;
    margin-bottom: 15px;
}

.error-message p,
.no-server-message p {
    font-size: 16px;
}

/* Dark Mode Support */
[data-theme="dark"] .widget-page {
    background: var(--dark-bg-secondary, #121212);
}

[data-theme="dark"] .widget-header h1 {
    color: var(--dark-text-primary, #e0e0e0);
}

[data-theme="dark"] .widget-subtitle {
    color: var(--dark-text-secondary, #aaa);
}

[data-theme="dark"] .widget-search-section {
    background: var(--dark-bg-card, #1e1e1e);
}

[data-theme="dark"] .widget-search-section h2,
[data-theme="dark"] .widget-preview-section h2,
[data-theme="dark"] .widget-styles-section h2,
[data-theme="dark"] .widget-embed-section h2 {
    color: var(--dark-text-primary, #e0e0e0);
}

[data-theme="dark"] .server-input {
    background: var(--dark-bg-tertiary, #2d2d2d);
    border-color: var(--dark-border-color, #333);
    color: var(--dark-text-primary, #e0e0e0);
}

[data-theme="dark"] .server-preview-card,
[data-theme="dark"] .embed-option {
    background: var(--dark-bg-card, #1e1e1e);
    border-color: var(--dark-border-color, #333);
}

[data-theme="dark"] .preview-header h3,
[data-theme="dark"] .embed-option h3,
[data-theme="dark"] .style-label {
    color: var(--dark-text-primary, #e0e0e0);
}

[data-theme="dark"] .preview-info .value {
    color: var(--dark-text-primary, #e0e0e0);
}

[data-theme="dark"] .preview-info .label {
    color: var(--dark-text-secondary, #aaa);
}

[data-theme="dark"] .embed-desc {
    color: var(--dark-text-secondary, #aaa);
}

[data-theme="dark"] .widget-notice {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.15), rgba(118, 75, 162, 0.15));
    color: #ccc;
}

[data-theme="dark"] .preview-container {
    background: var(--dark-bg-tertiary, #2d2d2d);
}

[data-theme="dark"] .code-tabs {
    border-bottom-color: var(--dark-border-color, #333);
}

[data-theme="dark"] .code-tab {
    border-color: var(--dark-border-color, #333);
    color: var(--dark-text-secondary, #aaa);
}

[data-theme="dark"] .code-tab:hover {
    border-color: #667eea;
    color: #667eea;
}

[data-theme="dark"] .error-message,
[data-theme="dark"] .no-server-message {
    color: var(--dark-text-secondary, #aaa);
}

/* Responsive */
@media (max-width: 768px) {
    .widget-page {
        padding: 15px;
    }
    
    .widget-header h1 {
        font-size: 22px;
    }
    
    .search-form {
        flex-direction: column;
    }
    
    .search-btn {
        justify-content: center;
    }
    
    .style-options {
        flex-direction: column;
        gap: 10px;
    }
    
    .code-tabs {
        flex-wrap: wrap;
    }
    
    .preview-container.iframe-preview iframe {
        max-width: 100%;
    }
}

/* Widget Options Row */
.widget-options-row {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 15px;
    padding: 12px 16px;
    background: rgba(102, 126, 234, 0.05);
    border-radius: 8px;
    border: 1px solid rgba(102, 126, 234, 0.1);
}

.widget-option-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #555;
    cursor: pointer;
}

.widget-option-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #667eea;
}

.widget-option-item select {
    padding: 6px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 13px;
    background: white;
    cursor: pointer;
}

[data-theme="dark"] .widget-options-row {
    background: rgba(102, 126, 234, 0.1);
    border-color: rgba(102, 126, 234, 0.2);
}

[data-theme="dark"] .widget-option-item {
    color: #ccc;
}

[data-theme="dark"] .widget-option-item select {
    background: #333;
    border-color: #444;
    color: #e0e0e0;
}

/* Modern preview container with transparency grid */
.preview-container {
    background: repeating-conic-gradient(#e0e0e0 0% 25%, #f5f5f5 0% 50%) 50% / 16px 16px;
}

[data-theme="dark"] .preview-container {
    background: repeating-conic-gradient(#333 0% 25%, #2d2d2d 0% 50%) 50% / 16px 16px;
}

/* Widget Customization Section */
.widget-customize-section {
    margin-bottom: 30px;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.05) 0%, rgba(118, 75, 162, 0.05) 100%);
    border: 1px solid rgba(102, 126, 234, 0.2);
    border-radius: 12px;
    padding: 25px;
}

.widget-customize-section h2 {
    font-size: 20px;
    margin-bottom: 20px;
    color: #333;
    display: flex;
    align-items: center;
    gap: 10px;
}

.widget-customize-section h2::before {
    content: '🎨';
}

.customize-option {
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(102, 126, 234, 0.1);
}

.customize-option:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.customize-option h3 {
    font-size: 16px;
    margin-bottom: 8px;
    color: #333;
    font-weight: 600;
}

.customize-desc {
    font-size: 13px;
    color: #666;
    margin-bottom: 15px;
}

/* Color Presets */
.color-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 15px;
}

.color-preset {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.color-preset:hover {
    transform: scale(1.1);
}

.color-preset.selected {
    transform: scale(1.15);
    box-shadow: 0 0 0 3px #667eea, 0 4px 8px rgba(0,0,0,0.2);
}

/* Color Input Row */
.color-input-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.color-input-row label {
    font-size: 14px;
    color: #555;
    font-weight: 500;
}

.color-input-row input[type="text"] {
    width: 100px;
    padding: 8px 12px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-family: monospace;
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
}

.color-input-row input[type="text"]:focus {
    border-color: #667eea;
    outline: none;
}

.color-input-row input[type="color"] {
    width: 40px;
    height: 40px;
    padding: 0;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    overflow: hidden;
}

.color-input-row input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

.color-input-row input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: 6px;
}

/* Language Select */
#widget-lang-select {
    width: 100%;
    max-width: 300px;
    padding: 10px 14px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    background: white;
    cursor: pointer;
}

#widget-lang-select:focus {
    border-color: #667eea;
    outline: none;
}

/* Primary Embed Option (Highlighted) */
.embed-option-primary {
    border: 2px solid #667eea;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.05) 0%, rgba(118, 75, 162, 0.03) 100%);
    position: relative;
}

.embed-option-primary::before {
    content: '⭐';
    position: absolute;
    top: -10px;
    right: 20px;
    background: #667eea;
    color: white;
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 10px;
}

.embed-option-primary h3 {
    color: #667eea;
}

/* JS Widget Preview Container */
.widget-js-preview {
    min-height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Dark Mode */
[data-theme="dark"] .widget-customize-section {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
    border-color: rgba(102, 126, 234, 0.3);
}

[data-theme="dark"] .widget-customize-section h2,
[data-theme="dark"] .customize-option h3 {
    color: #e0e0e0;
}

[data-theme="dark"] .customize-desc {
    color: #aaa;
}

[data-theme="dark"] .customize-option {
    border-bottom-color: rgba(102, 126, 234, 0.2);
}

[data-theme="dark"] .color-input-row label {
    color: #ccc;
}

[data-theme="dark"] .color-input-row input[type="text"] {
    background: #2d2d2d;
    border-color: #444;
    color: #e0e0e0;
}

[data-theme="dark"] #widget-lang-select {
    background: #2d2d2d;
    border-color: #444;
    color: #e0e0e0;
}

[data-theme="dark"] .embed-option-primary {
    border-color: #667eea;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.15) 0%, rgba(118, 75, 162, 0.1) 100%);
}

/* Responsive */
@media (max-width: 768px) {
    .color-presets {
        justify-content: center;
    }
    
    .color-input-row {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .color-input-row input[type="text"] {
        width: 100%;
        max-width: 200px;
    }
    
    #widget-lang-select {
        max-width: 100%;
    }
}

/* Toggle Switch for Auto Refresh */
.toggle-switch {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}

.toggle-switch input {
    display: none;
}

.toggle-slider {
    position: relative;
    width: 48px;
    height: 24px;
    background-color: #ccc;
    border-radius: 24px;
    transition: background-color 0.3s;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    left: 2px;
    top: 2px;
    background-color: white;
    border-radius: 50%;
    transition: transform 0.3s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.toggle-switch input:checked + .toggle-slider {
    background-color: #667eea;
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(24px);
}

.toggle-label {
    color: #666;
    font-size: 14px;
    font-weight: 500;
}

/* Auto Refresh Option Highlighting */
.auto-refresh-option {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.08) 0%, rgba(118, 75, 162, 0.08) 100%);
    border-radius: 10px;
    padding: 16px;
    margin: -5px;
    border: 1px solid rgba(102, 126, 234, 0.2);
}

.auto-refresh-option h3 {
    color: #667eea;
}

.auto-refresh-toggle-container {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.refresh-interval-hint {
    font-size: 12px;
    color: #888;
    background: rgba(102, 126, 234, 0.1);
    padding: 4px 10px;
    border-radius: 12px;
}

[data-theme="dark"] .auto-refresh-option {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.15) 0%, rgba(118, 75, 162, 0.15) 100%);
    border-color: rgba(102, 126, 234, 0.3);
}

[data-theme="dark"] .auto-refresh-option h3 {
    color: #9db5ff;
}

[data-theme="dark"] .refresh-interval-hint {
    background: rgba(102, 126, 234, 0.2);
    color: #aaa;
}

[data-theme="dark"] .toggle-slider {
    background-color: #444;
}

[data-theme="dark"] .toggle-label {
    color: #aaa;
}

/* Widget Style Selection */
.style-selection {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.style-option {
    position: relative;
    cursor: pointer;
}

.style-option input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.style-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 15px 20px;
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    transition: all 0.2s;
}

.style-option input[type="radio"]:checked + .style-preview {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.05), rgba(118, 75, 162, 0.05));
}

.style-preview:hover {
    border-color: #667eea;
    transform: translateY(-2px);
}

.style-preview svg {
    border-radius: 6px;
    background: #f8f9fa;
    padding: 5px;
}

.style-preview span {
    font-size: 13px;
    font-weight: 500;
    color: #555;
}

.style-option input[type="radio"]:checked + .style-preview span {
    color: #667eea;
    font-weight: 600;
}

/* Dark mode for style selection */
[data-theme="dark"] .style-preview {
    background: #2d2d2d;
    border-color: #444;
}

[data-theme="dark"] .style-option input[type="radio"]:checked + .style-preview {
    border-color: #667eea;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.15), rgba(118, 75, 162, 0.15));
}

[data-theme="dark"] .style-preview svg {
    background: #1e1e1e;
}

[data-theme="dark"] .style-preview span {
    color: #aaa;
}

[data-theme="dark"] .style-option input[type="radio"]:checked + .style-preview span {
    color: #9db5ff;
}

/* JS Widget Preview container */
.widget-js-preview {
    background: #f8f9fa;
    min-height: 200px;
}

[data-theme="dark"] .widget-js-preview {
    background: #2d2d2d;
}

/* Primary embed option styling */
.embed-option-primary {
    border: 2px solid #667eea;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.03), rgba(118, 75, 162, 0.03));
}

/* Widget Size Customization Styles */
.size-inputs {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.size-input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.size-input-group label {
    font-weight: 500;
    color: #555;
    font-size: 14px;
}

.slider-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.slider-container input[type="range"] {
    flex: 1;
    height: 6px;
    border-radius: 3px;
    background: linear-gradient(to right, #667eea 0%, #764ba2 100%);
    outline: none;
    -webkit-appearance: none;
}

.slider-container input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    transition: transform 0.2s;
}

.slider-container input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

.slider-container input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    border: none;
    transition: transform 0.2s;
}

.slider-container input[type="range"]::-moz-range-thumb:hover {
    transform: scale(1.1);
}

.slider-container input[type="number"] {
    flex: 0 0 90px;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s;
    text-align: center;
}

.slider-container input[type="number"]:focus {
    outline: none;
    border-color: #667eea;
}

.size-unit {
    font-size: 13px;
    color: #999;
    flex: 0 0 auto;
}

.size-hint {
    font-size: 12px;
    color: #999;
    margin-left: 4px;
}

/* Dark mode styles */
[data-theme="dark"] .size-input-group label {
    color: #ccc;
}

[data-theme="dark"] .slider-container input[type="range"] {
    background: linear-gradient(to right, #667eea 0%, #764ba2 100%);
}

[data-theme="dark"] .slider-container input[type="number"] {
    background: #2d2d2d;
    border-color: #444;
    color: #eee;
}

[data-theme="dark"] .slider-container input[type="number"]:focus {
    border-color: #9db5ff;
}

[data-theme="dark"] .size-unit,
[data-theme="dark"] .size-hint {
    color: #777;
}
