/* ==========================================================================
   BongBong Page Generator - Light & Readable Dashboard Styling (45+ Eyesight Friendly)
   ========================================================================== */

/* 1. Global Reset & Variables */
:root {
    /* Premium High-Contrast Light Theme Colors */
    --bg-dark: #f1f5f9;          /* Soft slate blue background */
    --bg-panel: #ffffff;         /* Crisp white panel */
    --bg-input: #ffffff;         /* Crisp white input */
    --border-color: #cbd5e1;     /* Solid readable border line */
    --border-hover: #4f46e5;     /* Solid active indigo border */
    
    --text-primary: #0f172a;     /* Deep slate black (100% contrast) */
    --text-secondary: #334155;   /* Dark grey charcoal text */
    --text-muted: #64748b;       /* Readable dark slate grey */
    
    --color-primary: #4f46e5;    /* Deep indigo primary accent */
    --color-primary-glow: rgba(79, 70, 229, 0.15);
    --color-success: #059669;    /* Forest green success */
    --color-danger: #dc2626;     /* Solid red danger */
    --color-warning: #d97706;    /* Dark gold warning */
    
    --sidebar-width: 480px;
    --navbar-height: 80px;
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Plus Jakarta Sans', 'Noto Sans TC', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
    font-size: 15px; /* Larger base font for readability */
    font-weight: 500;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

/* 2. Layout Structure */
.dashboard-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
    position: relative;
}

/* Top Navbar Style */
.top-navbar {
    height: var(--navbar-height);
    background: #ffffff;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 32px;
    z-index: 100;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.brand {
    display: flex;
    align-items: center;
    gap: 16px;
}

.brand-logo {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--color-primary), #3b82f6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: #fff;
    box-shadow: 0 4px 10px var(--color-primary-glow);
}

.brand-text h1 {
    font-size: 20px;
    font-weight: 800;
    letter-spacing: 0.5px;
    color: var(--text-primary);
}

.brand-text span {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    display: block;
    margin-top: 1px;
}

.nav-controls {
    display: flex;
    align-items: center;
    gap: 24px;
}

/* Theme Selector Tabs */
.theme-selector-tabs {
    display: flex;
    background: #f1f5f9;
    border: 1px solid var(--border-color);
    padding: 4px;
    border-radius: 30px;
    gap: 4px;
}

.theme-tab {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 8px 18px;
    font-size: 13px;
    font-weight: 700;
    border-radius: 30px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition-smooth);
}

.theme-tab:hover {
    color: var(--text-primary);
    background: rgba(0,0,0,0.02);
}

.theme-tab.active {
    background: var(--color-primary);
    color: #fff;
    box-shadow: 0 4px 12px var(--color-primary-glow);
}

/* Device Preview Mode Switch */
.preview-mode-switch {
    display: flex;
    background: #f1f5f9;
    border: 1px solid var(--border-color);
    padding: 4px;
    border-radius: 10px;
    gap: 2px;
}

.mode-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    width: 38px;
    height: 38px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: var(--transition-smooth);
}

.mode-btn:hover {
    color: var(--text-primary);
    background: #e2e8f0;
}

.mode-btn.active {
    background: #ffffff;
    color: var(--color-primary);
    border: 1px solid rgba(79, 70, 229, 0.2);
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

/* Glowing Primary Button */
.btn-glow-primary {
    background: linear-gradient(135deg, var(--color-primary), #6366f1);
    color: #fff;
    border: none;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 700;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 16px rgba(79, 70, 229, 0.3);
    transition: var(--transition-smooth);
}

.btn-glow-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(79, 70, 229, 0.45);
}

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

/* Glassmorphic Secondary Button */
.btn-glow-secondary {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    color: #334155;
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 700;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: var(--transition-smooth);
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.btn-glow-secondary:hover {
    background: #f8fafc;
    border-color: #94a3b8;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.btn-glow-secondary:active {
    transform: translateY(0);
}

/* Main Dashboard Workspace */
.dashboard-content {
    display: flex;
    flex: 1;
    height: calc(100vh - var(--navbar-height));
    overflow: hidden;
}

/* 3. Left Panel: Form Editor */
.editor-panel {
    width: var(--sidebar-width);
    background: var(--bg-panel);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    height: 100%;
}

.panel-header {
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
    background: #f8fafc;
}

.panel-header h2 {
    font-size: 18px;
    font-weight: 800;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.panel-header p {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    margin-top: 6px;
}

.scrollable-form-container {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    background: #f8fafc;
}

/* Form Styles */
.form-section {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 16px;
    margin-bottom: 20px;
    overflow: hidden;
    transition: var(--transition-smooth);
    box-shadow: 0 1px 3px rgba(0,0,0,0.02);
}

.form-section.expanded {
    border-color: #94a3b8;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.section-title {
    padding: 18px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
    transition: var(--transition-smooth);
    background: #ffffff;
}

.section-title:hover {
    background: #f1f5f9;
}

.section-title h3 {
    font-size: 15px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-primary);
}

.section-title h3 i {
    color: var(--color-primary);
    font-size: 16px;
}

.toggle-icon {
    font-size: 12px;
    color: var(--text-muted);
    transition: transform 0.3s ease;
}

.form-section.expanded .toggle-icon {
    transform: rotate(180deg);
}

.section-content {
    padding: 0 20px 20px 20px;
    display: none;
    border-top: 1px solid #cbd5e1;
    padding-top: 20px;
    background: #ffffff;
}

.form-section.expanded .section-content {
    display: block;
}

.helper-text {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 16px;
    line-height: 1.5;
}

.form-group {
    margin-bottom: 18px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-size: 13px;
    font-weight: 700;
    color: #0f172a; /* Strong legible title */
}

.form-group input, 
.form-group textarea, 
.form-group select {
    background: var(--bg-input);
    border: 1.5px solid #cbd5e1; /* Clearer border */
    border-radius: 10px;
    color: var(--text-primary); /* High contrast */
    padding: 12px 14px;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    transition: var(--transition-smooth);
}

.form-group input::placeholder {
    color: #94a3b8;
}

.form-group input:focus, 
.form-group textarea:focus, 
.form-group select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15); /* Clear solid outline */
}

.form-row {
    display: flex;
    gap: 16px;
}

.col-6 {
    flex: 1;
}

/* Image Upload UI */
.upload-dropzone {
    border: 2px dashed #cbd5e1;
    background: #f8fafc;
    border-radius: 12px;
    padding: 30px 20px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition-smooth);
    margin-bottom: 16px;
}

.upload-dropzone:hover {
    border-color: var(--color-primary);
    background: #f5f3ff;
}

.cloud-icon {
    font-size: 32px;
    color: var(--color-primary);
    margin-bottom: 12px;
}

.upload-dropzone p {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-secondary);
}

.upload-dropzone p span {
    color: var(--color-primary);
    font-weight: 800;
    text-decoration: underline;
}

.image-preview-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-top: 10px;
}

.image-preview-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
    border: 1.5px solid #cbd5e1;
    background: #f1f5f9;
}

.image-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.image-delete-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #dc2626;
    color: #fff;
    border: none;
    font-size: 11px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.image-preview-item:hover .image-delete-btn {
    opacity: 1;
}

/* Drag-and-drop image sorting */
.image-preview-item {
    cursor: grab;
    transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}
.image-preview-item.dragging {
    opacity: 0.4;
    transform: scale(0.95);
    cursor: grabbing;
}
.image-preview-item.drag-over {
    border-color: #6366f1;
    box-shadow: 0 0 0 2px #6366f1;
    transform: scale(1.04);
}
.img-drag-handle {
    position: absolute;
    bottom: 4px;
    left: 4px;
    color: rgba(255,255,255,0.9);
    font-size: 13px;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
    z-index: 2;
}
.image-preview-item:hover .img-drag-handle {
    opacity: 1;
}
.img-order-badge {
    position: absolute;
    top: 4px;
    left: 4px;
    background: rgba(0,0,0,0.55);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

/* Dynamic Rows Control */
.dynamic-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 16px;
}

.dynamic-row {
    background: #f8fafc;
    border: 1.5px solid #e2e8f0;
    border-radius: 12px;
    padding: 16px;
    position: relative;
    animation: slideDown 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.row-delete-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    color: #94a3b8;
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 16px;
    transition: var(--transition-smooth);
}

.row-delete-btn:hover {
    color: var(--color-danger);
}

.btn-secondary {
    width: 100%;
    background: #f1f5f9;
    border: 1.5px dashed #cbd5e1;
    color: #475569;
    padding: 12px;
    font-size: 14px;
    font-weight: 700;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--transition-smooth);
}

.btn-secondary:hover {
    background: #e2e8f0;
    border-color: #94a3b8;
    color: var(--text-primary);
}

/* 4. Right Panel: Preview Sandbox */
.preview-panel {
    flex: 1;
    background: #e2e8f0; /* Light slate surround for iframe contrast */
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 24px;
    overflow: hidden;
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.preview-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
}

.pulse-dot {
    width: 8px;
    height: 8px;
    background: var(--color-success);
    border-radius: 50%;
    box-shadow: 0 0 10px rgba(5, 150, 105, 0.4);
    position: relative;
}

.pulse-dot::after {
    content: '';
    position: absolute;
    top: -4px;
    left: -4px;
    width: 16px;
    height: 16px;
    border: 2px solid var(--color-success);
    border-radius: 50%;
    opacity: 0;
    animation: ripple 1.6s infinite ease-out;
}

#preview-status-text {
    font-size: 13px;
    font-weight: 700;
    color: #334155;
}

.preview-specs {
    font-size: 13px;
    font-weight: 600;
    color: #475569;
}

/* Sandbox Iframe Wrapping & Responsive Layouts */
.preview-sandbox-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

#preview-wrapper {
    height: 100%;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid #cbd5e1;
}

#preview-wrapper.desktop-view {
    width: 100%;
}

#preview-wrapper.mobile-view {
    width: 375px;
    height: 90%;
    border-radius: 36px;
    border: 12px solid #1e293b;
}

#preview-iframe {
    width: 100%;
    height: 100%;
    border: none;
    background: #fff;
}

/* 5. Notification Toast */
#toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--color-success);
    color: #fff;
    padding: 14px 24px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 700;
    box-shadow: 0 10px 24px rgba(5, 150, 105, 0.2);
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s ease;
}

.toast-hidden {
    transform: translateY(100px);
    opacity: 0;
    pointer-events: none;
}
.toast-visible {
    transform: translateY(0);
    opacity: 1;
}

/* 6. AI Copilot Inline Trigger Buttons */
.btn-ai-trigger {
    background: none;
    border: none;
    color: var(--color-primary);
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 6px;
    border-radius: 4px;
    transition: all 0.2s;
}
.btn-ai-trigger:hover {
    background: rgba(79, 70, 229, 0.08);
    transform: scale(1.05);
}

/* 7. bone2web-文字ai Glowing & Loading Animations (45+ Eyesight Friendly) */
@keyframes glowing-pulse {
    0% {
        box-shadow: 0 0 4px rgba(79, 70, 229, 0.15), inset 0 0 4px rgba(79, 70, 229, 0.05);
        background-color: #faf9ff;
        border-color: #4f46e5;
    }
    50% {
        box-shadow: 0 0 20px rgba(79, 70, 229, 0.65), inset 0 0 10px rgba(79, 70, 229, 0.1);
        background-color: #f3f0ff;
        border-color: #6366f1;
    }
    100% {
        box-shadow: 0 0 4px rgba(79, 70, 229, 0.15), inset 0 0 4px rgba(79, 70, 229, 0.05);
        background-color: #faf9ff;
        border-color: #4f46e5;
    }
}

.glowing-loading-active {
    animation: glowing-pulse 1.5s infinite ease-in-out;
}

/* Input enhancements for legibility */
#input-full-ai-draft {
    font-size: 14px !important;
    font-weight: 700 !important;
    line-height: 1.5;
    color: #0f172a !important;
}

#input-full-ai-draft::placeholder {
    color: #94a3b8;
    font-weight: 600;
}

/* 8. AI Copywriter Modal CSS (45+ Legibility & Contrast Optimized) */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.6); /* High contrast dark overlay */
    backdrop-filter: blur(8px);       /* Premium modern glassmorphism */
    display: none;                     /* Hidden by default */
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    display: flex;
    opacity: 1;
}

.modal-box {
    background: #ffffff;
    border: 2px solid #cbd5e1;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
    width: 100%;
    max-width: 600px;
    padding: 28px;
    position: relative;
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    color: #0f172a;
}

.modal-overlay.active .modal-box {
    transform: scale(1);
}

.modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: none;
    border: none;
    font-size: 28px;
    font-weight: 700;
    color: #64748b;
    cursor: pointer;
    line-height: 1;
    transition: var(--transition-smooth);
}

.modal-close:hover {
    color: #ef4444;
    transform: rotate(90deg);
}

.modal-title {
    font-size: 18px;
    font-weight: 800;
    color: #4f46e5;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
}


