/* ============================================
   DUALESE INDEX POPUP - Portrait Mode Design
   ============================================ */

/* Index Trigger Button - Fixed Position */
.dualese-index-trigger {
    position: fixed;
    bottom: 30px;
    right: calc((100vw - 860px) / 2 - 70px);
    z-index: 9998;
}

@media (max-width: 1000px) {
    .dualese-index-trigger {
        right: 20px;
    }
}

.dualese-index-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 22px;
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: #fff;
    border: none;
    border-radius: 50px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 8px 30px rgba(79, 70, 229, 0.4);
    transition: all 0.3s ease;
}

.dualese-index-btn:hover {
    transform: translateY(-3px) scale(1.03);
    box-shadow: 0 12px 40px rgba(79, 70, 229, 0.5);
}

.dualese-index-btn:active {
    transform: scale(0.95);
}

.dualese-index-icon {
    font-size: 24px;
}

.dualese-index-label {
    font-size: 15px;
    letter-spacing: 0.5px;
}

/* Overlay - Full Screen */
.dualese-index-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 99999;
    display: none;
    justify-content: center;
    align-items: center;
    padding: 20px;
    animation: overlayFadeIn 0.3s ease;
}

.dualese-index-overlay.active {
    display: flex;
}

@keyframes overlayFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Popup - Portrait Style */
.dualese-index-popup {
    background: #ffffff;
    border-radius: 24px;
    width: 100%;
    max-width: 640px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.4);
    animation: popupSlideUp 0.35s ease;
    overflow: hidden;
}

@keyframes popupSlideUp {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Header */
.dualese-index-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 28px;
    border-bottom: 2px solid #f1f5f9;
    flex-shrink: 0;
}

.dualese-index-header h2 {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
    color: #1e293b;
}

.dualese-index-close {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: #94a3b8;
    padding: 4px 8px;
    border-radius: 8px;
    transition: all 0.2s ease;
    line-height: 1;
}

.dualese-index-close:hover {
    background: #f1f5f9;
    color: #ef4444;
}

/* Body - Scrollable */
.dualese-index-body {
    padding: 20px 28px 28px;
    overflow-y: auto;
    flex: 1;
}

/* Stats */
.dualese-index-stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: #f8fafc;
    border-radius: 12px;
    margin-bottom: 20px;
    font-size: 14px;
    color: #475569;
    flex-wrap: wrap;
    gap: 8px;
}

.dualese-index-stats strong {
    color: #1e293b;
}

.dualese-index-current {
    font-size: 13px;
    color: #64748b;
}

.dualese-index-current strong {
    color: #4f46e5;
}

/* Page List */
.dualese-index-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.dualese-index-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: #ffffff;
    border-radius: 12px;
    border: 2px solid transparent;
    transition: all 0.2s ease;
    position: relative;
}

.dualese-index-item:hover {
    background: #f1f5f9;
    border-color: #e2e8f0;
    transform: translateX(4px);
}

.dualese-index-item.current {
    background: #eef2ff;
    border-color: #4f46e5;
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.15);
}

.dualese-index-link {
    display: flex;
    align-items: center;
    gap: 14px;
    flex: 1;
    text-decoration: none;
    color: #1e293b;
    min-width: 0;
}

.dualese-index-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    background: #f1f5f9;
    border-radius: 50%;
    font-size: 13px;
    font-weight: 600;
    color: #64748b;
    flex-shrink: 0;
}

.dualese-index-item.current .dualese-index-number {
    background: #4f46e5;
    color: #ffffff;
}

.dualese-index-title {
    flex: 1;
    font-size: 15px;
    font-weight: 500;
    color: #1e293b;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dualese-index-item.current .dualese-index-title {
    color: #1e293b;
}

.dualese-index-mode {
    font-size: 12px;
    font-weight: 600;
    padding: 3px 12px;
    border-radius: 20px;
    background: #f1f5f9;
    color: #64748b;
    flex-shrink: 0;
}

.dualese-index-item.current .dualese-index-mode {
    background: #e0e7ff;
    color: #4f46e5;
}

.dualese-index-badge {
    font-size: 10px;
    font-weight: 700;
    padding: 2px 10px;
    border-radius: 20px;
    background: #4f46e5;
    color: #ffffff;
    letter-spacing: 0.3px;
    flex-shrink: 0;
}

/* Edit Button */
.dualese-index-edit-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.dualese-index-edit-btn:hover {
    background: #4f46e5;
    border-color: #4f46e5;
    transform: scale(1.05);
}

/* Footer */
.dualese-index-footer {
    padding-top: 16px;
    border-top: 1px solid #f1f5f9;
    text-align: center;
    flex-shrink: 0;
}

.dualese-index-close-btn {
    padding: 10px 40px;
    background: #f1f5f9;
    border: none;
    border-radius: 50px;
    font-size: 14px;
    font-weight: 600;
    color: #475569;
    cursor: pointer;
    transition: all 0.2s ease;
}

.dualese-index-close-btn:hover {
    background: #e2e8f0;
    color: #1e293b;
}

/* Scrollbar Styling */
.dualese-index-body::-webkit-scrollbar {
    width: 6px;
}

.dualese-index-body::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 8px;
}

.dualese-index-body::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 8px;
}

.dualese-index-body::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* ============================================
   EDIT MODAL
   ============================================ */

.dualese-edit-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 100000;
    display: none;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.dualese-edit-modal.active {
    display: flex;
}

.dualese-edit-modal-content {
    background: #ffffff;
    border-radius: 20px;
    width: 100%;
    max-width: 700px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
    animation: popupSlideUp 0.3s ease;
    overflow: hidden;
}

.dualese-edit-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 2px solid #f1f5f9;
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: #ffffff;
}

.dualese-edit-modal-header h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
}

.dualese-edit-modal-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #ffffff;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.dualese-edit-modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.dualese-edit-modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.dualese-edit-field {
    margin-bottom: 20px;
}

.dualese-edit-field label {
    display: block;
    font-weight: 600;
    font-size: 14px;
    color: #1e293b;
    margin-bottom: 8px;
}

.dualese-edit-input,
.dualese-edit-select,
.dualese-edit-textarea {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    font-size: 15px;
    font-family: inherit;
    transition: all 0.2s ease;
    background: #ffffff;
}

.dualese-edit-input:focus,
.dualese-edit-select:focus,
.dualese-edit-textarea:focus {
    outline: none;
    border-color: #4f46e5;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.dualese-edit-textarea {
    min-height: 150px;
    resize: vertical;
    font-family: 'Noto Sans CJK TC', 'Noto Sans CJK SC', monospace;
    line-height: 1.6;
}

.dualese-edit-hint {
    margin-top: 6px;
    font-size: 12px;
    color: #94a3b8;
}

.dualese-edit-options {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.dualese-edit-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
    color: #1e293b;
}

.dualese-edit-checkbox input {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.dualese-edit-status {
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    display: none;
}

.dualese-edit-status.success {
    display: block;
    background: #dcfce7;
    color: #166534;
}

.dualese-edit-status.error {
    display: block;
    background: #fee2e2;
    color: #991b1b;
}

.dualese-edit-status.loading {
    display: block;
    background: #dbeafe;
    color: #1e40af;
}

.dualese-edit-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid #f1f5f9;
    background: #f8fafc;
}

.dualese-edit-cancel-btn {
    padding: 12px 24px;
    background: #ffffff;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    color: #475569;
    cursor: pointer;
    transition: all 0.2s ease;
}

.dualese-edit-cancel-btn:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
}

.dualese-edit-save-btn {
    padding: 12px 24px;
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    color: #ffffff;
    cursor: pointer;
    transition: all 0.2s ease;
}

.dualese-edit-save-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(79, 70, 229, 0.4);
}

.dualese-edit-save-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* ========== Mobile Responsive ========== */
@media (max-width: 768px) {
    .dualese-index-trigger {
        bottom: 20px;
        right: 20px;
    }
    
    .dualese-index-btn {
        padding: 12px 18px;
        font-size: 14px;
    }
    
    .dualese-index-btn .dualese-index-label {
        display: none;
    }
    
    .dualese-index-btn .dualese-index-icon {
        font-size: 28px;
    }
    
    .dualese-index-popup {
        max-width: 100%;
        max-height: 90vh;
        border-radius: 20px;
        margin: 10px;
    }
    
    .dualese-index-header {
        padding: 16px 20px;
    }
    
    .dualese-index-header h2 {
        font-size: 18px;
    }
    
    .dualese-index-body {
        padding: 16px 20px 20px;
    }
    
    .dualese-index-stats {
        flex-direction: column;
        align-items: stretch;
        gap: 4px;
        font-size: 13px;
    }
    
    .dualese-index-item {
        padding: 10px 14px;
        gap: 6px;
    }
    
    .dualese-index-link {
        gap: 10px;
    }
    
    .dualese-index-title {
        font-size: 14px;
    }
    
    .dualese-index-number {
        min-width: 28px;
        height: 28px;
        font-size: 12px;
    }
    
    .dualese-index-mode {
        font-size: 11px;
        padding: 2px 10px;
    }
    
    .dualese-index-badge {
        font-size: 9px;
        padding: 1px 8px;
    }
    
    .dualese-index-edit-btn {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }
    
    .dualese-index-close-btn {
        padding: 8px 30px;
        font-size: 13px;
    }
    
    /* Edit Modal Mobile */
    .dualese-edit-modal-content {
        max-width: 100%;
        max-height: 95vh;
        border-radius: 16px;
        margin: 10px;
    }
    
    .dualese-edit-modal-header {
        padding: 16px 20px;
    }
    
    .dualese-edit-modal-header h3 {
        font-size: 18px;
    }
    
    .dualese-edit-modal-body {
        padding: 20px;
    }
    
    .dualese-edit-modal-footer {
        padding: 12px 20px;
        flex-direction: column;
    }
    
    .dualese-edit-cancel-btn,
    .dualese-edit-save-btn {
        width: 100%;
        justify-content: center;
    }
    
    .dualese-edit-options {
        flex-direction: column;
        gap: 12px;
    }
}

@media (max-width: 480px) {
    .dualese-index-popup {
        margin: 6px;
        border-radius: 16px;
    }
    
    .dualese-index-header {
        padding: 12px 16px;
    }
    
    .dualese-index-header h2 {
        font-size: 16px;
    }
    
    .dualese-index-body {
        padding: 12px 16px 16px;
    }
    
    .dualese-index-item {
        padding: 8px 12px;
        gap: 4px;
        border-radius: 8px;
    }
    
    .dualese-index-title {
        font-size: 13px;
    }
    
    .dualese-index-number {
        min-width: 24px;
        height: 24px;
        font-size: 11px;
    }
    
    .dualese-edit-modal-content {
        margin: 6px;
        border-radius: 12px;
    }
    
    .dualese-edit-modal-header {
        padding: 12px 16px;
    }
    
    .dualese-edit-modal-body {
        padding: 16px;
    }
}