/**
 * 小学计算题生成器 - 前端样式
 */

/* 全局样式 */
:root {
    --primary-color: #4a6da7;
    --primary-hover: #3a5a8f;
    --secondary-color: #f5f7fa;
    --accent-color: #ff9a3c;
    --text-primary: #333333;
    --text-secondary: #666666;
    --text-light: #888888;
    --border-color: #e0e0e0;
    --shadow-color: rgba(0, 0, 0, 0.08);
    --success-color: #5cb85c;
    --warning-color: #f0ad4e;
    --bg-light: #ffffff;
    --border-radius: 8px;
    --transition: all 0.3s ease;
}

.xxmg-container {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    max-width: 800px;
    margin: 0 auto;
    padding: 25px;
    background-color: var(--bg-light);
    border-radius: var(--border-radius);
    box-shadow: 0 2px 15px var(--shadow-color);
    color: var(--text-primary);
}

/* 配置表单 */
.xxmg-config-panel {
    margin-bottom: 35px;
}

.xxmg-config-panel h3 {
    margin-top: 0;
    margin-bottom: 20px;
    font-size: 26px;
    color: var(--primary-color);
    border-bottom: 2px solid var(--secondary-color);
    padding-bottom: 12px;
    text-align: center;
    font-weight: 600;
}

.xxmg-description {
    margin-bottom: 25px;
    color: var(--text-secondary);
    font-size: 16px;
    text-align: center;
    line-height: 1.5;
}

.xxmg-form {
    background-color: var(--secondary-color);
    padding: 25px;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

.xxmg-form-group {
    margin-bottom: 20px;
}

.xxmg-form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 15px;
}

.xxmg-form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 15px;
    color: var(--text-primary);
    background-color: var(--bg-light);
    box-sizing: border-box;
    transition: var(--transition);
}

.xxmg-form-control:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 3px rgba(74, 109, 167, 0.1);
}

.xxmg-checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 5px;
}

.xxmg-checkbox-group label {
    display: inline-flex;
    align-items: center;
    margin-right: 0;
    font-weight: normal;
    cursor: pointer;
    padding: 6px 12px;
    background-color: var(--bg-light);
    border-radius: 6px;
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

.xxmg-checkbox-group label:hover {
    background-color: var(--secondary-color);
    border-color: var(--primary-color);
}

.xxmg-checkbox-group input[type="checkbox"] {
    margin-right: 6px;
    transform: scale(1.1);
}

.xxmg-checkbox-group input[type="checkbox"]:checked + span {
    color: var(--primary-color);
    font-weight: 500;
}

.xxmg-button {
    background-color: var(--primary-color);
    color: #fff;
    border: none;
    padding: 12px 18px;
    font-size: 16px;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition);
    width: 100%;
    text-align: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.xxmg-button:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.xxmg-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* 结果区域样式 */
.xxmg-result-container {
    background-color: var(--bg-light);
    padding: 25px;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    margin-top: 30px;
    transition: var(--transition);
    box-shadow: 0 2px 10px var(--shadow-color);
}

.xxmg-header-info {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    margin-bottom: 20px;
    font-size: 14px;
    color: var(--text-light);
}

.xxmg-header-item {
    margin-bottom: 10px;
    min-width: 150px;
}

.xxmg-header-input {
    border: none;
    border-bottom: 1px solid var(--border-color);
    padding: 3px 6px;
    width: 130px;
    font-size: 14px;
    transition: var(--transition);
}

.xxmg-header-input:focus {
    border-color: var(--primary-color);
    outline: none;
}

.xxmg-header-blank {
    display: inline-block;
    width: 130px;
    border-bottom: 1px solid var(--border-color);
}

.xxmg-problem-title {
    text-align: center;
    font-size: 24px;
    margin: 25px 0;
    color: var(--primary-color);
    font-weight: 600;
}

/* 学生信息样式 */
.xxmg-student-info {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    margin: -10px 0 25px;
    font-size: 15px;
    color: var(--text-secondary);
    text-align: center;
}

.xxmg-student-item {
    margin: 0 20px 10px;
    white-space: nowrap;
}

.xxmg-student-item .xxmg-header-input, 
.xxmg-student-item .xxmg-header-blank {
    border-bottom: 1px solid var(--border-color);
    min-width: 110px;
    transition: var(--transition);
}

.xxmg-student-item .xxmg-header-input:focus {
    border-color: var(--primary-color);
}

.xxmg-problem-list {
    margin-bottom: 35px;
    column-count: 3; /* 使用3列布局 */
    column-gap: 25px; /* 列间距 */
    column-fill: balance; /* 平衡各列高度 */
}

.xxmg-problem-item {
    break-inside: avoid; /* 避免题目被分割到不同列 */
    page-break-inside: avoid;
    margin-bottom: 18px; /* 题目之间的间距 */
    font-size: 16px;
    line-height: 1.5;
    padding: 8px 12px;
    background-color: var(--secondary-color);
    border-radius: 6px;
    transition: var(--transition);
}

.xxmg-problem-item:hover {
    background-color: rgba(74, 109, 167, 0.05);
}

.xxmg-problem-number {
    color: var(--primary-color);
    font-size: 14px;
    margin-right: 5px;
    font-weight: 600;
}

.xxmg-answer-section {
    margin-top: 35px;
    padding-top: 25px;
    border-top: 1px dashed var(--border-color);
}

.xxmg-answer-title {
    text-align: center;
    font-size: 20px;
    margin-bottom: 25px;
    color: var(--primary-color);
    font-weight: 600;
}

.xxmg-answer-list {
    column-count: 3; /* 使用3列布局 */
    column-gap: 25px; /* 列间距 */
    column-fill: balance; /* 平衡各列高度 */
}

.xxmg-answer-item {
    break-inside: avoid; /* 避免答案被分割到不同列 */
    page-break-inside: avoid;
    margin-bottom: 18px; /* 答案之间的间距 */
    font-size: 16px;
    line-height: 1.5;
    padding: 8px 12px;
    background-color: var(--secondary-color);
    border-radius: 6px;
    transition: var(--transition);
}

.xxmg-action-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 35px;
    flex-wrap: wrap;
}

.xxmg-action-buttons .xxmg-button {
    width: auto;
    min-width: 120px;
}

.xxmg-action-buttons .xxmg-button:nth-child(2) {
    background-color: var(--accent-color);
}

.xxmg-action-buttons .xxmg-button:nth-child(2):hover {
    background-color: #e88a2e;
}

.xxmg-print-footer {
    text-align: center;
    margin-top: 50px;
    font-size: 12px;
    color: var(--text-light);
    display: none; /* 在屏幕上不显示 */
}

/* 加载状态样式 */
.xxmg-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.xxmg-loading-spinner {
    border: 5px solid var(--secondary-color);
    border-top: 5px solid var(--primary-color);
    border-radius: 50%;
    width: 45px;
    height: 45px;
    animation: xxmg-spin 1.5s linear infinite;
    margin-bottom: 20px;
}

.xxmg-loading-text {
    color: var(--text-secondary);
    font-size: 16px;
    text-align: center;
}

@keyframes xxmg-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 响应式设计 */
@media screen and (max-width: 1200px) {
    .xxmg-problem-list, .xxmg-answer-list {
        column-count: 3;
    }
}

@media screen and (max-width: 900px) {
    .xxmg-problem-list, .xxmg-answer-list {
        column-count: 2;
        column-gap: 20px;
    }
}

@media screen and (max-width: 768px) {
    .xxmg-container {
        padding: 20px 15px;
    }
    
    .xxmg-form {
        padding: 20px 15px;
    }
    
    .xxmg-header-info {
        flex-direction: column;
    }
    
    .xxmg-header-item {
        width: 100%;
        margin-bottom: 15px;
    }
    
    .xxmg-student-info {
        flex-direction: column;
        align-items: center;
    }
    
    .xxmg-student-item {
        margin: 0 0 15px;
        width: 100%;
        display: flex;
        justify-content: space-between;
        max-width: 300px;
    }
    
    .xxmg-checkbox-group {
        flex-direction: column;
    }
    
    .xxmg-checkbox-group label {
        margin-right: 0;
        margin-bottom: 8px;
    }
    
    .xxmg-action-buttons {
        flex-direction: column;
        gap: 10px;
    }
    
    .xxmg-action-buttons .xxmg-button {
        width: 100%;
    }
}

@media screen and (max-width: 576px) {
    .xxmg-problem-list, .xxmg-answer-list {
        column-count: 1;
    }
    
    .xxmg-config-panel h2 {
        font-size: 22px;
    }
    
    .xxmg-problem-title {
        font-size: 20px;
    }
}

/* 状态样式 */
.xxmg-option-disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.xxmg-option-disabled input {
    cursor: not-allowed;
}

.xxmg-option-note {
    font-size: 12px;
    color: var(--text-light);
    margin-left: 5px;
}

/* 工具提示 */
.xxmg-tooltip {
    position: relative;
    display: inline-block;
    margin-left: 5px;
    cursor: help;
}

.xxmg-tooltip .xxmg-tooltip-icon {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    width: 18px;
    height: 18px;
    background-color: var(--primary-color);
    color: white;
    border-radius: 50%;
    font-size: 12px;
    font-weight: bold;
}

.xxmg-tooltip .xxmg-tooltip-text {
    visibility: hidden;
    width: 200px;
    background-color: #333;
    color: #fff;
    text-align: center;
    border-radius: 6px;
    padding: 8px 10px;
    position: absolute;
    z-index: 1;
    bottom: 125%;
    left: 50%;
    margin-left: -100px;
    opacity: 0;
    transition: opacity 0.3s;
    font-size: 13px;
    font-weight: normal;
    line-height: 1.4;
}

.xxmg-tooltip .xxmg-tooltip-text::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: #333 transparent transparent transparent;
}

.xxmg-tooltip:hover .xxmg-tooltip-text {
    visibility: visible;
    opacity: 1;
}

/* 补充动画和通知样式 */
@keyframes fadeIn {
    0% { opacity: 0; transform: translateY(10px); }
    100% { opacity: 1; transform: translateY(0); }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.result-fade-in {
    animation: fadeIn 0.5s ease-out;
}

.item-fade-in {
    animation: fadeIn 0.3s ease-out forwards;
    opacity: 0;
}

.highlight-form {
    box-shadow: 0 0 0 3px rgba(74, 109, 167, 0.3);
}

.xxmg-form-error {
    color: #e53935;
    font-size: 13px;
    margin-top: 5px;
    animation: fadeIn 0.3s ease-out;
}

.xxmg-field-message {
    font-size: 13px;
    margin-top: 5px;
    animation: fadeIn 0.3s ease-out;
}

.xxmg-message-warning {
    color: #ff9800;
}

.xxmg-message-info {
    color: #2196f3;
}

.xxmg-message-error {
    color: #e53935;
}

.xxmg-message-success {
    color: #4caf50;
}

.xxmg-form-control.error {
    border-color: #e53935;
}

.xxmg-checkbox-group label.checked {
    background-color: rgba(74, 109, 167, 0.1);
    border-color: #4a6da7;
}

/* 按钮动画 */
.xxmg-button.submitting {
    background-color: #3a5a8f;
    position: relative;
}

.xxmg-button-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s linear infinite;
    margin-right: 5px;
    vertical-align: middle;
}

/* 通知样式 */
.xxmg-notification {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background-color: white;
    color: #333;
    padding: 12px 15px;
    border-radius: 4px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 300px;
    z-index: 9999;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s ease;
}

.xxmg-notification-show {
    transform: translateY(0);
    opacity: 1;
}

.xxmg-notification-success {
    border-left: 4px solid #4caf50;
}

.xxmg-notification-error {
    border-left: 4px solid #e53935;
}

.xxmg-notification-warning {
    border-left: 4px solid #ff9800;
}

.xxmg-notification-info {
    border-left: 4px solid #2196f3;
}

.xxmg-notification-message {
    flex: 1;
    margin-right: 10px;
}

.xxmg-notification-close {
    cursor: pointer;
    font-size: 18px;
    color: #999;
}

/* 打印对话框 */
.xxmg-print-dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.xxmg-dialog-show {
    opacity: 1;
    visibility: visible;
}

/* 打印提示样式 */
.xxmg-print-tip {
    font-size: 12px;
    color: #666;
    margin-top: 5px;
    font-style: italic;
}

/* 按钮下方的操作提示 */
.xxmg-action-tips {
    margin-top: 10px;
    text-align: center;
    padding: 5px 0;
}

.xxmg-action-tips .xxmg-print-tip {
    margin: 0;
    color: #777;
}

/* 使用次数信息区域样式 */
.xxmg-usage-info-container {
    margin-top: 20px;
    padding: 10px;
    text-align: center;
    border-radius: 4px;
    animation: fadeIn 0.3s ease-out;
}

.xxmg-usage-info-normal {
    border: 1px solid #ddd;
    background: #f9f9f9;
    color: #666;
}

.xxmg-usage-info-warning {
    border: 1px solid #ff9800;
    background: #fff8e1;
    color: #ff8f00;
}

.xxmg-usage-info-error {
    border: 1px solid #e53935;
    background: #ffebee;
    color: #e53935;
}

.xxmg-usage-info-container .xxmg-usage-message {
    font-size: 14px;
    margin-bottom: 8px;
}

.xxmg-usage-info-container .xxmg-usage-tip {
    font-size: 13px;
    margin-bottom: 12px;
}

/* 操作按钮样式 */
.xxmg-usage-action {
    margin-top: 15px;
}

.xxmg-action-button {
    display: inline-block;
    padding: 8px 20px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.3s ease;
}

.xxmg-login-button {
    background-color: #4a6da7;
    color: white;
    border: 1px solid #4a6da7;
}

.xxmg-login-button:hover {
    background-color: #3a5a8f;
    color: white;
    text-decoration: none;
}

.xxmg-vip-button {
    background-color: #f5a623;
    color: white;
    border: 1px solid #f5a623;
}

.xxmg-vip-button:hover {
    background-color: #e8940e;
    color: white;
    text-decoration: none;
}

/* 打印页脚在正常视图中隐藏 */
.xxmg-print-footer {
    display: none;
}

/* AI分析相关样式 */
.xxmg-ai-result-container {
    max-width: 800px;
    margin: 30px auto 0;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 25px;
    background-color: var(--bg-light);
    box-shadow: 0 2px 10px var(--shadow-color);
    animation: fadeIn 0.5s ease-out;
}

.xxmg-ai-title {
    font-size: 18px;
    margin: 0 0 15px 0;
    padding-bottom: 10px;
    border-bottom: 1px solid #e0e0e0;
    color: #333;
}

.xxmg-ai-content {
    font-size: 14px;
    line-height: 1.6;
    color: #444;
    white-space: pre-wrap;
}

.xxmg-ai-button {
    background-color: #4285f4;
    border: 1px solid #4285f4;
}

.xxmg-ai-button:hover {
    background-color: #3367d6;
}

/* AI使用信息样式 */
.xxmg-ai-usage-info-container {
    margin-top: 20px;
    padding: 15px;
    border-radius: 4px;
    background-color: #f9f9f9;
    border: 1px solid #e0e0e0;
    transition: all 0.3s ease;
    text-align: center;
}

/* 对应不同状态的样式 */
.xxmg-ai-usage-info-normal {
    border: 1px solid #b8daff;
    background: #f2f8ff;
    color: #1a73e8;
}

.xxmg-ai-usage-info-warning {
    border: 1px solid #ffeeba;
    background: #fff8e1;
    color: #ff8f00;
}

.xxmg-ai-usage-info-error {
    border: 1px solid #e53935;
    background: #ffebee;
    color: #e53935;
}

.xxmg-ai-usage-info-container .xxmg-usage-message {
    font-size: 14px;
    margin-bottom: 8px;
}

.xxmg-ai-usage-info-container .xxmg-usage-tip {
    font-size: 13px;
    margin-bottom: 12px;
}

.xxmg-ai-usage-action {
    margin-top: 15px;
}

/* 警告样式 */
.xxmg-warning {
    background-color: #fff3cd;
    color: #856404;
    padding: 10px;
    margin-bottom: 10px;
    border: 1px solid #ffeeba;
    border-radius: 4px;
    font-weight: bold;
}

/* 设置AI按钮在生成题目按钮旁边 */
#xxmg-ai-analysis {
    margin-top: 10px;
  
}

@media screen and (max-width: 768px) {
    #xxmg-ai-analysis {
        margin-top: 15px;
        margin-left: 0;
        width: 100%;
    }
}

.xxmg-ai-loading {
    text-align: center;
    padding: 20px;
    color: #666;
}

.xxmg-ai-error {
    color: #e53935;
    padding: 10px;
    border-left: 4px solid #e53935;
    background-color: #ffebee;
    margin: 10px 0;
}

.xxmg-ai-debug-info {
    margin-top: 15px;
    padding: 10px;
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow-x: auto;
}

.xxmg-ai-debug-info pre {
    white-space: pre-wrap;
    font-family: monospace;
    font-size: 12px;
    color: #333;
    margin: 0;
}

.xxmg-print-dialog {
    background-color: white;
    border-radius: 8px;
    width: 90%;
    max-width: 450px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    transform: translateY(20px);
    transition: all 0.3s ease;
}

.xxmg-dialog-show .xxmg-print-dialog {
    transform: translateY(0);
}

.xxmg-print-dialog-header {
    padding: 15px 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.xxmg-print-dialog-close {
    background: none;
    border: none;
    font-size: 22px;
    color: #999;
    cursor: pointer;
}

.xxmg-print-dialog-body {
    padding: 20px;
}

.xxmg-print-option {
    margin-bottom: 15px;
}

.xxmg-print-option label {
    display: flex;
    align-items: center;
}

.xxmg-print-option input[type="checkbox"] {
    margin-right: 8px;
}

.xxmg-print-option input[type="text"] {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-top: 5px;
}

.xxmg-print-dialog-footer {
    padding: 15px 20px;
    border-top: 1px solid #eee;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.xxmg-print-dialog-footer .xxmg-button {
    padding: 8px 15px;
    font-size: 14px;
    min-width: 80px;
}

/* 打印样式 */
@media print {
    .xxmg-config-panel, 
    .xxmg-action-buttons,
    .xxmg-loading,
    .xxmg-action-tips,
    .xxmg-usage-info-container,
    .xxmg-ai-result-container {
        display: none !important;
    }
    
    .xxmg-print-footer {
        display: block;
        text-align: center;
        margin-top: 30px;
        padding-top: 10px;
        border-top: 1px dashed #ccc;
    }
}