/* GeoGebra 课件工具样式 */

:root {
    --primary-color: #4285f4;
    --primary-hover: #3367d6;
    --secondary-color: #5f6368;
    --success-color: #34a853;
    --error-color: #ea4335;
    --warning-color: #fbbc04;
    --bg-color: #f8f9fa;
    --card-bg: #ffffff;
    --border-color: #dadce0;
    --text-color: #202124;
    --text-secondary: #5f6368;
    --shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
    --shadow-hover: 0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg-color);
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* 顶部 */
.header {
    background: linear-gradient(135deg, #4285f4 0%, #34a853 100%);
    color: white;
    padding: 12px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header h1 {
    font-size: 1.4rem;
    font-weight: 500;
}

.mode-switcher {
    display: flex;
    align-items: center;
    gap: 10px;
}

.mode-switcher label {
    font-size: 0.9rem;
    opacity: 0.9;
}

.mode-switcher select {
    padding: 8px 16px;
    border-radius: 6px;
    border: none;
    background: rgba(255,255,255,0.2);
    color: white;
    font-size: 0.95rem;
    cursor: pointer;
    outline: none;
}

.mode-switcher select:hover {
    background: rgba(255,255,255,0.3);
}

.mode-switcher select option {
    color: var(--text-color);
    background: white;
}

/* 主容器 */
.main-container {
    display: flex;
    flex: 1;
    gap: 16px;
    padding: 16px;
    height: calc(100vh - 130px);
}

/* 编辑器面板 - 缩小宽度 */
.editor-panel {
    width: 320px;
    min-width: 280px;
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fafafa;
}

.panel-header h3 {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-color);
}

.panel-header .hint {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* 快捷按钮 */
.quick-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-color);
    background: #fafafa;
}

.quick-btn {
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    background: white;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
}

.quick-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* 命令输入框 */
#command-input {
    flex: 1;
    padding: 16px;
    border: none;
    font-family: "SF Mono", Monaco, "Cascadia Code", "Roboto Mono", Consolas, monospace;
    font-size: 0.9rem;
    line-height: 1.6;
    resize: none;
    outline: none;
    min-height: 200px;
}

#command-input::placeholder {
    color: #9aa0a6;
}

/* 按钮行 */
.button-row {
    display: flex;
    gap: 10px;
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
}

.btn-primary {
    flex: 1;
    padding: 10px 20px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.btn-secondary {
    padding: 10px 20px;
    background: white;
    color: var(--secondary-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: #f1f3f4;
    border-color: var(--secondary-color);
}

.btn-small {
    padding: 4px 10px;
    font-size: 0.8rem;
    border: 1px solid var(--border-color);
    background: white;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-small:hover {
    background: #f1f3f4;
}

/* 示例选择 */
.examples-section {
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 10px;
}

.examples-section label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.examples-section select {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    outline: none;
}

.examples-section select:focus {
    border-color: var(--primary-color);
}

/* 日志区域 - 可折叠 */
.log-section {
    border-top: 1px solid var(--border-color);
    max-height: 150px;
    display: flex;
    flex-direction: column;
    transition: max-height 0.3s ease;
}

.log-section.collapsed {
    max-height: 36px;
}

.log-header {
    padding: 8px 16px;
    background: #fafafa;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
}

.log-header:hover {
    background: #f0f0f0;
}

.log-header::before {
    content: '▼';
    margin-right: 6px;
    transition: transform 0.2s;
    display: inline-block;
}

.log-section.collapsed .log-header::before {
    transform: rotate(-90deg);
}

#log-output {
    flex: 1;
    padding: 10px 16px;
    font-family: monospace;
    font-size: 0.8rem;
    line-height: 1.5;
    overflow-y: auto;
    background: #fafafa;
    max-height: 120px;
}

.log-section.collapsed #log-output {
    display: none;
}

#log-output .success {
    color: var(--success-color);
}

#log-output .error {
    color: var(--error-color);
}

#log-output .info {
    color: var(--text-secondary);
}

/* 画布面板 */
.canvas-panel {
    flex: 1;
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.canvas-actions {
    display: flex;
    gap: 8px;
}

#ggb-container {
    flex: 1;
    min-height: 400px;
}

#ggb-container iframe,
#ggb-container > div {
    width: 100% !important;
    height: 100% !important;
}

/* 加载遮罩 */
#loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.95);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10;
    transition: opacity 0.3s;
}

#loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

#loading-overlay p {
    margin-top: 16px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* 底部导出栏 */
.export-bar {
    background: var(--card-bg);
    padding: 12px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -2px 8px rgba(0,0,0,0.05);
}

.export-section {
    display: flex;
    align-items: center;
    gap: 12px;
}

.export-section span {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.btn-export {
    padding: 8px 16px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-export:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

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

.help-link {
    color: var(--primary-color);
    text-decoration: none;
    font-size: 0.85rem;
}

.help-link:hover {
    text-decoration: underline;
}

.shortcut-hint {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* 3D提示 */
.tips-3d {
    position: fixed;
    bottom: 80px;
    right: 24px;
    background: rgba(0,0,0,0.75);
    color: white;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 0.8rem;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.3s;
    pointer-events: none;
}

.tips-3d.visible {
    opacity: 1;
    transform: translateY(0);
}

/* 响应式 */
@media (max-width: 900px) {
    .main-container {
        flex-direction: column;
        max-height: none;
    }
    
    .editor-panel {
        width: 100%;
        min-width: auto;
        max-height: 50vh;
    }
    
    .canvas-panel {
        min-height: 400px;
    }
    
    .export-bar {
        flex-direction: column;
        gap: 12px;
    }
    
    .tips-3d {
        bottom: 140px;
    }
}

/* 滚动条样式 */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

/* 全屏模式样式 */
.btn-fullscreen {
    background: var(--primary-color);
    color: white;
}

.btn-fullscreen:hover {
    background: var(--primary-hover);
}

/* 全屏模式 - 隐藏所有不需要的元素 */
.main-container.fullscreen-mode {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    background: white;
    max-height: none;
    border-radius: 0;
    margin: 0;
    padding: 0;
    display: block;
}

/* 全屏时只显示画布面板 */
.main-container.fullscreen-mode .editor-panel,
.main-container.fullscreen-mode .export-bar,
.main-container.fullscreen-mode .tips-3d {
    display: none !important;
}

/* 画布面板全屏 */
.canvas-panel.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: white;
    margin: 0;
    padding: 0;
    border: none;
}

.canvas-panel.fullscreen .panel-header {
    flex-shrink: 0;
    height: 50px;
    padding: 10px 16px;
    background: linear-gradient(135deg, #4285f4 0%, #34a853 100%);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.canvas-panel.fullscreen .panel-header h3 {
    margin: 0;
    font-size: 1.1rem;
}

.canvas-panel.fullscreen #ggb-container {
    flex: 1;
    width: 100% !important;
    height: calc(100vh - 50px) !important;
    min-height: calc(100vh - 50px);
}

.canvas-panel.fullscreen #ggb-container > * {
    width: 100% !important;
    height: 100% !important;
}

.canvas-panel.fullscreen #loading-overlay {
    position: absolute;
    top: 50px;
    left: 0;
    right: 0;
    bottom: 0;
}

/* ESC提示 */
.main-container.fullscreen-mode .canvas-panel.fullscreen::before {
    content: '按 ESC 退出全屏';
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 14px;
    pointer-events: none;
    opacity: 0.9;
    z-index: 10000;
}

/* 标签页栏 */
.tabs-bar {
    display: flex;
    align-items: center;
    background: #e8eaed;
    padding: 0 16px;
    height: 36px;
    border-bottom: 1px solid var(--border-color);
}

.tabs-container {
    display: flex;
    flex: 1;
    overflow-x: auto;
    gap: 2px;
}

.tabs-container::-webkit-scrollbar {
    height: 4px;
}

.tab-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 16px;
    background: #e0e0e0;
    border-radius: 6px 6px 0 0;
    cursor: pointer;
    font-size: 0.85rem;
    color: #5f6368;
    white-space: nowrap;
    transition: all 0.2s;
    min-width: 80px;
    max-width: 150px;
}

.tab-item:hover {
    background: #d0d0d0;
}

.tab-item.active {
    background: white;
    color: var(--text-color);
    font-weight: 500;
}

.tab-item .tab-name {
    overflow: hidden;
    text-overflow: ellipsis;
}

.tab-item .tab-close {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 12px;
    line-height: 16px;
    text-align: center;
    color: #999;
    opacity: 0;
    transition: all 0.2s;
}

.tab-item:hover .tab-close {
    opacity: 1;
}

.tab-item .tab-close:hover {
    background: #ea4335;
    color: white;
}

.tab-add-btn {
    padding: 6px 12px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    margin-left: 8px;
    white-space: nowrap;
}

.tab-add-btn:hover {
    background: var(--primary-hover);
}
