/* ==========================================================================
   Editor Modes (Original vs Markdown)
   ========================================================================== */

/* Markdown Mode - Dark IDE Style */
.markdown-mode-active .editor-panel {
    background: #1e1e1e;
    color: #d4d4d4;
    border: 1px solid #333;
}

.markdown-mode-active .panel-header-tabs,
.markdown-mode-active .editor-toolbar-top,
.markdown-mode-active .rich-toolbar,
.markdown-mode-active #markdown-title-wrapper {
    background: #252525 !important;
    border-color: #333 !important;
    color: #888 !important;
}

.markdown-mode-active .tab.active {
    color: #fff !important;
}

.markdown-mode-active .tab.active::after {
    background: #4f46e5 !important;
}

.markdown-mode-active #input-text {
    background: #1e1e1e !important;
    color: #d4d4d4 !important;
    font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace !important;
    line-height: 1.6 !important;
    padding: 30px !important;
    caret-color: #fff;
}

/* Original Mode - Clean Paper Style */
.original-mode-active .editor-panel {
    background: #ffffff;
    box-shadow: inset 0 0 40px rgba(0,0,0,0.01);
}

.original-mode-active #input-text {
    font-family: 'Inter', -apple-system, sans-serif !important;
    background: transparent !important;
    line-height: 1.8 !important;
    padding: 40px !important;
    font-size: 1.05rem !important;
}

/* Mode-specific Widgets */
.markdown-helper-panel {
    position: absolute;
    top: 100px;
    right: 20px;
    width: 180px;
    background: rgba(37, 37, 37, 0.9);
    backdrop-filter: blur(8px);
    border: 1px solid #444;
    border-radius: 8px;
    padding: 12px;
    font-size: 0.75rem;
    color: #aaa;
    display: none;
    z-index: 10;
}

.markdown-mode-active .markdown-helper-panel {
    display: block;
}

.markdown-helper-panel h4 {
    color: #eee;
    margin-bottom: 8px;
    font-size: 0.8rem;
    border-bottom: 1px solid #444;
    padding-bottom: 4px;
}

.markdown-helper-panel ul { list-style: none; }
.markdown-helper-panel li { margin-bottom: 4px; display: flex; justify-content: space-between; }
.markdown-helper-panel code { color: #6366f1; background: rgba(99, 102, 241, 0.1); padding: 1px 4px; border-radius: 3px; }

/* Floating Action Button for Original Mode */
.original-mode-active .btn-smart-cleanup {
    display: flex !important;
}

.btn-smart-cleanup {
    position: absolute;
    bottom: 30px;
    right: 30px;
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 30px;
    font-weight: 600;
    box-shadow: 0 10px 20px rgba(79, 70, 229, 0.3);
    cursor: pointer;
    display: none;
    align-items: center;
    gap: 8px;
    z-index: 20;
    transition: all 0.3s;
}

.btn-smart-cleanup:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 24px rgba(79, 70, 229, 0.4);
}

/* ==========================================================================
   Base & Reset (SaaS Modern UI)
   ========================================================================== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    /* Brand Colors */
    --primary-color: #4f46e5;      /* Indigo 600 */
    --primary-hover: #4338ca;      /* Indigo 700 */
    --primary-light: #e0e7ff;      /* Indigo 100 */
    --success-color: #10b981;      /* Emerald 500 */
    --success-hover: #059669;      /* Emerald 600 */
    --warning-color: #f59e0b;      /* Amber 500 */
    --danger-color:  #ef4444;      /* Red 500 */
    
    /* Neutrals - Light Mode */
    --bg-app: #f3f4f6;             /* Gray 100 */
    --bg-panel: #ffffff;
    --bg-surface: #f9fafb;         /* Gray 50 */
    --border-light: #f3f4f6;
    --border-color: #e5e7eb;       /* Gray 200 */
    --border-dark: #d1d5db;        /* Gray 300 */
    
    /* Typography */
    --text-main: #111827;          /* Gray 900 */
    --text-secondary: #4b5563;     /* Gray 600 */
    --text-muted: #9ca3af;         /* Gray 400 */
    
    /* Layout */
    --sidebar-left-w: 380px;
    --sidebar-right-w: 340px;
    --header-h: 60px;
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-floating: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-app);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- Layout --- */
.app-layout {
    display: flex;
    flex-direction: row;
    height: 100vh;
}

/* Payment Methods */
.payment-methods {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
    justify-content: center;
}

.method-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 24px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: white;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.2s ease;
}

.method-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.method-btn.active {
    border-color: var(--primary-color);
    background: var(--primary-light);
    color: var(--primary-color);
}

.method-btn i {
    font-size: 18px;
}

.method-btn .fa-alipay { color: #1677FF; }
.method-btn .fa-weixin { color: #09B83E; }

/* Sidebar */
.main-sidebar {
    width: 240px;
    background: #ffffff;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    z-index: 50;
}

.brand-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-light);
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    color: var(--text-main);
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
}

.nav-item i {
    width: 16px;
    text-align: center;
    color: var(--text-muted);
}

.nav-item:hover {
    background: var(--bg-surface);
}

.nav-item.active {
    background: #f3f4f6;
    color: var(--text-main);
    font-weight: 600;
}

.nav-item.active i {
    color: var(--text-main);
}

.nav-group-title {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-main);
    cursor: pointer;
}

.nav-group-title i:first-child {
    width: 16px;
    text-align: center;
    color: var(--text-muted);
}

.nav-group-items {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* AI Adaptive Template Base Styles */
.template-custom-ai {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: var(--text-main);
    line-height: 1.8;
}

.template-custom-ai .ai-adaptive-container {
    max-width: 100%;
    margin: 0 auto;
    padding: 20px;
    box-sizing: border-box;
}

.template-custom-ai p {
    margin-bottom: 1.5em;
}

.template-custom-ai img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 20px 0;
}

/* AI Info Drawer (Right side overlay) */
.ai-info-drawer {
    position: absolute;
    top: 0;
    right: -320px;
    width: 320px;
    height: 100%;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-left: 1px solid var(--border-color);
    box-shadow: -4px 0 25px rgba(0, 0, 0, 0.05);
    padding: 24px;
    z-index: 100;
    overflow-y: auto;
    transition: right 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.ai-info-drawer.show {
    right: 0;
    display: block !important;
}

.interactive-keyword:hover {
    background: #e0e7ff !important;
    border-color: #6366f1 !important;
}

.interactive-param:hover {
    background: rgba(99, 102, 241, 0.05);
    border-radius: 4px;
}
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-app);
    height: 100vh; /* Explicit height */
}

/* Top Header */
.top-header {
    height: 56px; /* Slightly more compact */
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    position: relative;
    z-index: 100;
}

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

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: opacity 0.2s;
}
.user-profile:hover {
    opacity: 0.8;
}

.profile-info {
    display: flex;
    flex-direction: column;
}

/* Workspace Header */
.workspace-header {
    padding: 20px 24px 10px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.workspace-actions {
    display: flex;
    gap: 12px;
}

.app-container {
    display: flex;
    flex: 1;
    overflow: hidden;
    padding: 16px 24px 24px 24px;
    gap: 24px;
}

/* Editor & Preview Panels */
.editor-panel, .preview-panel {
    flex: 1;
    background: #ffffff;
    border-radius: var(--radius-lg);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.03);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(0, 0, 0, 0.05);
    height: 100%; /* Ensure panels take full height of container */
}

.panel-header-tabs {
    display: flex;
    align-items: center;
    padding: 0 20px;
    border-bottom: 1px solid var(--border-light);
    background: #ffffff;
    height: 48px; /* Compressed from 54px */
}

.panel-header-tabs .tabs {
    display: flex;
    gap: 24px;
    height: 100%;
}

.panel-header-tabs .tab {
    background: none;
    border: none;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    position: relative;
    padding: 0 8px;
    height: 100%;
    transition: color 0.2s;
}

.panel-header-tabs .tab:hover {
    color: var(--text-main);
}

.panel-header-tabs .tab.active {
    color: var(--primary-color);
    font-weight: 600;
}

.panel-header-tabs .tab.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--primary-color);
    border-radius: 2px 2px 0 0;
}

.editor-toolbar-top {
    padding: 12px 20px; /* Compressed padding */
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #ffffff;
}

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

.btn-text {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.85rem;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.btn-text:hover { background: var(--bg-surface); color: var(--text-main); }
.btn-text.active { color: var(--primary-color); font-weight: 600; background: var(--primary-light); }

.rich-toolbar {
    padding: 6px 16px; /* Compressed from 8px */
    display: flex;
    align-items: center;
    gap: 2px;
    border-top: 1px solid var(--border-light);
    border-bottom: 1px solid var(--border-light);
    background: #ffffff;
    flex-wrap: wrap;
}

.rich-toolbar .icon-btn {
    width: 32px;
    height: 32px;
    border-radius: 4px;
    color: var(--text-secondary);
}

.rich-toolbar .icon-btn:hover {
    background: var(--bg-surface);
    color: var(--primary-color);
}

.toolbar-divider {
    width: 1px;
    height: 16px;
    background: var(--border-color);
    margin: 0 8px;
}

.preview-controls {
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-light);
    background: #ffffff;
}

.style-select {
    padding: 6px 32px 6px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: #ffffff;
    font-size: 0.85rem;
    outline: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%234b5563' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
}

/* User Profile & Dropdown */
.user-profile {
    position: relative;
    cursor: pointer;
}

.user-dropdown-menu {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 220px;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.08), 0 1px 3px rgba(0,0,0,0.05);
    border: 1px solid rgba(0,0,0,0.05);
    padding: 8px;
    display: none;
    flex-direction: column;
    z-index: 1000;
    animation: dropdownFadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.user-dropdown-menu::before {
    content: '';
    position: absolute;
    top: -5px;
    right: 20px;
    width: 10px;
    height: 10px;
    background: white;
    transform: rotate(45deg);
    border-left: 1px solid rgba(0,0,0,0.05);
    border-top: 1px solid rgba(0,0,0,0.05);
}

.user-dropdown-menu.show {
    display: flex;
}

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

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    font-size: 0.9rem;
    color: var(--text-main);
    border-radius: 8px;
    transition: all 0.2s;
    text-decoration: none;
    font-weight: 500;
}

.dropdown-item i {
    font-size: 1.05rem;
    width: 20px;
    text-align: center;
    color: var(--text-muted);
    transition: color 0.2s;
}

.dropdown-item:hover {
    background: var(--bg-surface);
    color: var(--primary-color);
}

.dropdown-item:hover i {
    color: var(--primary-color);
}

.dropdown-divider {
    height: 1px;
    background: var(--border-color);
    margin: 6px 8px;
}

.dropdown-item.logout {
    color: var(--danger-color);
}

.dropdown-item.logout i {
    color: var(--danger-color);
}

.dropdown-item.logout:hover {
    background: #fef2f2;
    color: var(--danger-color);
}

/* --- Top Header Actions --- */
.header-action-btn {
    width: 36px;
    height: 36px;
    font-size: 1.1rem;
    color: #64748b;
    position: relative;
}

.notification-wrapper {
    position: relative;
}

.notification-dot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 8px;
    height: 8px;
    background: var(--danger-color);
    border: 2px solid white;
    border-radius: 50%;
}

.header-divider {
    width: 1px;
    height: 24px;
    background: var(--border-color);
    margin: 0 12px;
}

.btn-upgrade-pro-header {
    padding: 6px 14px;
    font-size: 0.85rem;
    height: 36px;
    background: linear-gradient(135deg, #f59e0b, #ea580c);
    border: none;
    color: white;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(234, 88, 12, 0.25);
}
.btn-upgrade-pro-header:hover {
    background: linear-gradient(135deg, #fbbf24, #f97316);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(234, 88, 12, 0.35);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 8px;
    border-radius: 30px;
    transition: all 0.2s;
}
.user-profile:hover {
    background: var(--bg-surface);
}

.user-profile .avatar {
    width: 32px;
    height: 32px;
    background: #f1f5f9;
    color: #64748b;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    border: 1px solid var(--border-color);
}

.profile-username {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-main);
    display: block;
}

.profile-badge {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* Modal Enhancements */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, 0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay.show {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-floating);
    width: 100%;
    max-width: 500px;
    position: relative;
    overflow: hidden;
    animation: modalSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalSlideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: rgba(0,0,0,0.05);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: all 0.2s;
}
.modal-close:hover {
    background: rgba(0,0,0,0.1);
    color: var(--text-main);
}
.panel {
    background: var(--bg-panel);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.panel-header h2 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 8px;
}
.panel-header h2 i {
    color: var(--text-muted);
}

.btn {
    padding: 10px 16px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 500;
    font-size: 0.9rem;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    letter-spacing: 0.2px;
}

.btn.primary { 
    background: var(--primary-color); 
    color: white; 
    box-shadow: 0 2px 4px rgba(79, 70, 229, 0.2);
}
.btn.primary:hover { 
    background: var(--primary-hover); 
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(79, 70, 229, 0.3);
}
.btn.success { 
    background: var(--success-color); 
    color: white; 
}
.btn.success:hover { 
    background: var(--success-hover); 
}
.btn.secondary {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}
.btn.secondary:hover {
    background: var(--border-light);
    color: var(--text-main);
}
.btn.full-width { width: 100%; }
.btn.large { padding: 12px 24px; font-size: 1rem; border-radius: var(--radius-md); }

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}
.icon-btn:hover { 
    background: var(--bg-surface);
    color: var(--text-main); 
}
.icon-btn.danger:hover {
    color: var(--danger-color);
    background: #fef2f2;
}

/* --- Left Sidebar: Editor --- */
.sidebar-left {
    width: var(--sidebar-left-w);
    flex-shrink: 0;
}

.editor-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0;
    position: relative;
    background: #ffffff;
    overflow: hidden; /* Prevent child leakage */
    min-height: 0; /* Important for flex child to be scrollable */
}

#input-text {
    flex: 1;
    width: 100%;
    height: 100%;
    border: none;
    padding: 24px;
    resize: none;
    font-family: 'Inter', sans-serif;
    font-size: 15px;
    line-height: 1.8;
    outline: none;
    background: transparent;
    color: var(--text-main);
    overflow-y: auto;
    display: block; /* Ensure it's block for height to work */
}

#input-text::placeholder {
    color: var(--text-muted);
    font-family: 'Inter', sans-serif;
}

.editor-footer {
    padding: 16px;
    background: var(--bg-surface);
    border-top: 1px solid var(--border-light);
}

/* --- Middle Stage: Phone Preview --- */
.preview-stage-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f3f4f6;
    overflow: hidden; /* Prevent native scrollbars to use scale instead */
    position: relative;
    padding: 20px;
}

.preview-stage {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

/* Subtle dot grid background */
.preview-stage::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image: radial-gradient(var(--border-dark) 1px, transparent 1px);
    background-size: 24px 24px;
    opacity: 0.4;
    z-index: 0;
}

.phone-mockup {
    width: 375px; /* iPhone standard width */
    height: 812px; /* iPhone standard height (Fixed to avoid squishing) */
    background: #ffffff;
    border-radius: 48px;
    border: 14px solid #111827; /* Dark sleek bezel */
    box-shadow: 
        inset 0 0 0 1px #374151, /* Inner metallic edge */
        0 25px 50px -12px rgba(0, 0, 0, 0.25), /* Outer deep shadow */
        0 0 0 2px #d1d5db; /* Outer metallic line */
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex-shrink: 0;
    z-index: 10;
    transform-origin: center center; /* For JS scaling */
}

/* Hardware Buttons simulation */
.phone-btn-silence,
.phone-btn-volume-up,
.phone-btn-volume-down,
.phone-btn-power {
    position: absolute;
    background: #111827;
    z-index: 5;
}

.phone-btn-silence {
    left: -17px;
    top: 110px;
    width: 4px;
    height: 24px;
    border-radius: 4px 0 0 4px;
}
.phone-btn-volume-up {
    left: -17px;
    top: 160px;
    width: 4px;
    height: 46px;
    border-radius: 4px 0 0 4px;
}
.phone-btn-volume-down {
    left: -17px;
    top: 220px;
    width: 4px;
    height: 46px;
    border-radius: 4px 0 0 4px;
}
.phone-btn-power {
    right: -17px;
    top: 180px;
    width: 4px;
    height: 60px;
    border-radius: 0 4px 4px 0;
}

/* Notch / Dynamic Island simulation */
.phone-header {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    width: 120px;
    height: 34px;
    background: #000000;
    border-radius: 20px;
    z-index: 30;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding-right: 12px;
    box-shadow: inset 0 0 4px rgba(255,255,255,0.1);
}
.phone-header .camera {
    width: 14px;
    height: 14px;
    background: #0f0f0f;
    border-radius: 50%;
    border: 2px solid #1a1a1a;
    box-shadow: inset 0 0 4px rgba(255,255,255,0.2);
}

/* WeChat Fake Nav Bar */
.wechat-nav-bar {
    height: 54px;
    background: #ededed;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    padding-top: 14px; /* Offset for dynamic island */
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    border-bottom: 1px solid #e5e5e5;
    flex-shrink: 0;
    z-index: 20;
    margin-top: 30px; /* Space for status bar area */
}
.wechat-nav-title {
    font-weight: 500;
    font-size: 1.05rem;
    color: #111;
}
.wechat-nav-left, .wechat-nav-right {
    font-size: 1.1rem;
    color: #111;
    width: 32px;
    display: flex;
    align-items: center;
    cursor: pointer;
}
.wechat-nav-right {
    justify-content: flex-end;
}

.phone-screen {
    flex: 1;
    overflow-y: auto;
    background: #ffffff;
    scrollbar-width: none; 
    -ms-overflow-style: none;
    padding-bottom: 20px;
    /* Removed padding-top since wechat nav bar handles it */
}
.phone-screen::-webkit-scrollbar { display: none; }

.phone-home-bar {
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 130px;
    height: 5px;
    background: #e5e7eb;
    border-radius: 3px;
    z-index: 20;
    pointer-events: none;
}

/* Glassmorphism Action Bar */
.stage-actions {
    margin-top: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    align-items: stretch;
    background: rgba(255, 255, 255, 0.7);
    padding: 20px;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    z-index: 10;
    width: 390px;
}

.action-controls-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.action-group {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.action-group input[type="range"] {
    width: 80px;
    accent-color: var(--primary-color);
}

.action-group input[type="color"] {
    -webkit-appearance: none;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    padding: 0;
    overflow: hidden;
}
.action-group input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.action-group input[type="color"]::-webkit-color-swatch { border: none; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0,0,0,0.1); }

/* --- Right Sidebar: AI Assistant --- */
.sidebar-right {
    width: var(--sidebar-right-w);
    flex-shrink: 0;
}

.ai-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.ai-section {
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 16px;
}

.ai-section h4 {
    font-size: 0.85rem;
    text-transform: uppercase;
    color: var(--text-secondary);
    letter-spacing: 0.5px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
}

/* --- Diagnosis --- */
.diagnosis-box {
    font-size: 0.85rem;
}

.diagnosis-score {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px dashed var(--border-color);
}

.diagnosis-score-val {
    font-size: 1.8rem;
    font-weight: 800;
    letter-spacing: -1px;
}
.diagnosis-score-val.high { color: var(--success-color); }
.diagnosis-score-val.medium { color: var(--warning-color); }
.diagnosis-score-val.low { color: var(--danger-color); }

.diagnosis-item {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
    line-height: 1.5;
    padding: 8px;
    border-radius: 6px;
    background: white;
    border: 1px solid var(--border-light);
}

.diagnosis-item.good { border-left: 3px solid var(--success-color); }
.diagnosis-item.warning { border-left: 3px solid var(--warning-color); }
.diagnosis-item.error { border-left: 3px solid var(--danger-color); }
.diagnosis-item.info { border-left: 3px solid var(--primary-color); }

/* --- Components Library --- */
.saved-component-item {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    font-size: 0.85rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: var(--shadow-sm);
}
.saved-component-item:hover {
    border-color: var(--primary-color);
    transform: translateX(2px);
    box-shadow: var(--shadow-md);
}
.saved-component-item span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
    font-weight: 500;
}
.saved-component-item .delete-btn {
    color: var(--text-muted);
    background: none;
    border: none;
    cursor: pointer;
    opacity: 0;
    transition: all 0.2s;
}
.saved-component-item:hover .delete-btn {
    opacity: 1;
}
.saved-component-item .delete-btn:hover {
    color: var(--danger-color);
}

/* Toggle Switch */
.switch { position: relative; display: inline-block; width: 36px; height: 20px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: var(--border-dark); transition: .3s; border-radius: 20px; }
.slider:before { position: absolute; content: ""; height: 14px; width: 14px; left: 3px; bottom: 3px; background-color: white; transition: .3s; border-radius: 50%; box-shadow: 0 1px 2px rgba(0,0,0,0.2); }
input:checked + .slider { background-color: var(--success-color); }
input:checked + .slider:before { transform: translateX(16px); }

/* --- Toast Notification --- */
#toast {
    position: fixed;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--text-main);
    color: white;
    padding: 12px 24px;
    border-radius: 50px;
    z-index: 10000;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    opacity: 0;
    pointer-events: none;
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 8px;
}
#toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* --- Premium Overlays (SaaS style) --- */
.overlay-backdrop {
    display: none; 
    position: fixed; 
    inset: 0; 
    background: rgba(17, 24, 39, 0.6); 
    z-index: 9999; 
    align-items: center; 
    justify-content: center; 
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    padding: 20px;
}

.modal-card {
    background: white;
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 420px;
    text-align: center;
    box-shadow: var(--shadow-floating);
    overflow: hidden;
    animation: modalPop 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalPop {
    0% { opacity: 0; transform: scale(0.95) translateY(10px); }
    100% { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes breathe {
    0% { box-shadow: 0 4px 15px rgba(79, 70, 229, 0.3); transform: translateY(0); }
    50% { box-shadow: 0 8px 25px rgba(236, 72, 153, 0.4); transform: translateY(-1px); }
    100% { box-shadow: 0 4px 15px rgba(79, 70, 229, 0.3); transform: translateY(0); }
}

.btn-ai-magic {
    animation: breathe 3s infinite ease-in-out;
    transition: all 0.3s;
}
.btn-ai-magic:hover {
    animation: none;
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(236, 72, 153, 0.5) !important;
}

.modal-header {
    background: linear-gradient(135deg, var(--bg-surface) 0%, white 100%);
    padding: 30px 30px 20px;
    border-bottom: 1px solid var(--border-light);
}

.modal-header h2 {
    color: var(--text-main);
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 8px;
    letter-spacing: -0.5px;
}

.modal-header p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.5;
}

.modal-body {
    padding: 30px;
}

.input-field {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid var(--border-dark);
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    transition: all 0.2s;
    outline: none;
    background: var(--bg-surface);
}
.input-field:focus {
    border-color: var(--primary-color);
    background: white;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}
.input-field.mono { font-family: 'JetBrains Mono', monospace; letter-spacing: 1px; text-align: center; }

.modal-footer {
    padding: 20px 30px;
    background: var(--bg-surface);
    border-top: 1px solid var(--border-light);
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Pricing Badges */
.pricing-tiers {
    display: flex;
    gap: 10px;
    margin-bottom: 24px;
}
.tier-card {
    flex: 1;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px;
    cursor: pointer;
    transition: all 0.2s;
    background: white;
}
.tier-card:hover {
    border-color: var(--primary-color);
}
.tier-card.selected {
    border-color: var(--primary-color);
    background: var(--primary-light);
    box-shadow: 0 0 0 1px var(--primary-color);
}
.tier-name { font-size: 0.8rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 4px; }
.tier-price { font-size: 1.2rem; font-weight: 800; color: var(--text-main); }
.tier-price span { font-size: 0.7rem; font-weight: normal; color: var(--text-muted); }


/* --- Responsive --- */
@media (max-width: 1024px) {
    body { overflow: auto; height: auto; }
    .app-layout { height: auto; min-height: 100vh; flex-direction: column; }
    .main-sidebar { width: 100%; height: auto; flex-direction: row; align-items: center; padding: 10px 20px; border-right: none; border-bottom: 1px solid var(--border-color); }
    .main-sidebar .sidebar-nav { display: none !important; } /* Hide sidebar nav on mobile, use top header */
    .brand-logo { margin: 0; padding: 0; border: none; }
    
    .top-header { flex-wrap: wrap; height: auto; padding: 10px 16px; gap: 10px; }
    .header-left, .header-right { width: 100%; justify-content: space-between; }
    .header-divider { display: none; }
    
    .app-container { flex-direction: column; padding: 0; gap: 0; height: auto; }
    .panel { border-radius: 0; border: none; border-bottom: 1px solid var(--border-color); box-shadow: none; width: 100%; height: auto; min-height: 400px; }
    .sidebar-left, .sidebar-right { width: 100%; height: auto; flex: none; display: block; }
    
    /* Hide some panels on mobile or stack them */
    .sidebar-right { display: flex; flex-wrap: wrap; }
    .tool-group { width: 100%; }
    
    .editor-wrapper { min-height: 400px; height: 50vh; }
    .ai-content { height: auto !important; overflow: visible; }
    .preview-stage { padding: 40px 16px; background: var(--bg-surface); min-height: 600px; }
    .phone-mockup { width: 100%; max-width: 400px; height: 800px; margin: 0 auto; border-radius: 36px; }
    .stage-actions { width: 100%; max-width: 400px; margin: 24px auto 0; }
    
    .workspace-header { flex-direction: column; align-items: flex-start; gap: 10px; padding: 10px 16px; }
    .workspace-actions { width: 100%; justify-content: space-between; }
    .workspace-actions .btn { flex: 1; padding: 8px; font-size: 0.8rem; }
}

@media (max-width: 480px) {
    .phone-mockup { border-radius: 20px; box-shadow: var(--shadow-md); height: auto; min-height: 600px; border-width: 8px; }
    .phone-header, .phone-home-bar { display: none; }
    .phone-screen { padding-top: 0; border-radius: 12px; }
    .btn-upgrade-pro-header { display: none !important; } /* Hide on very small screens to save space */
    .user-profile .profile-info { display: none; } /* Hide username, keep avatar */
    .header-quote { display: none !important; }
}

/* WeChat Paste Fixes */
.ai-adaptive-container * {
    max-width: 100% !important;
    box-sizing: border-box !important;
    word-wrap: break-word !important;
    word-break: break-word !important;
}
.ai-adaptive-container { width: 100% !important; overflow-x: hidden !important; }