/* 邮件助手 Dashboard 样式 */

:root {
    --primary-color: #4a90d9;
    --primary-hover: #357abd;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --background-color: #f5f7fa;
    --card-background: #ffffff;
    --text-color: #333333;
    --text-secondary: #666666;
    --border-color: #e0e0e0;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --radius: 8px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
    font-size: 16px;
}

/* ========== 登录页面 ========== */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.login-box {
    background: var(--card-background);
    padding: 40px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.login-box h1 {
    font-size: 28px;
    margin-bottom: 8px;
    color: var(--primary-color);
}

.login-box .icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.login-box p {
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.login-box input {
    width: 100%;
    padding: 14px 16px;
    font-size: 18px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    margin-bottom: 16px;
    text-align: center;
    letter-spacing: 4px;
}

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

.login-box button {
    width: 100%;
    padding: 14px;
    font-size: 18px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.3s;
}

.login-box button:hover {
    background: var(--primary-hover);
}

.login-box button:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.error-message {
    color: var(--danger-color);
    margin-top: 12px;
    font-size: 14px;
}

/* ========== Dashboard 主界面 ========== */
.dashboard-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* 头部 */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: var(--card-background);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

.header h1 {
    font-size: 24px;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 8px;
}

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

.btn {
    padding: 10px 20px;
    font-size: 14px;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

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

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

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

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

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background: #c82333;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

/* 邮箱列表区域 */
.accounts-section {
    background: var(--card-background);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 20px;
}

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

.section-title {
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.accounts-list {
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    max-height: 200px;
    overflow-y: auto;
}

.account-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.2s;
}

.account-item:last-child {
    border-bottom: none;
}

.account-item:hover {
    background: #f8f9fa;
}

.account-item input[type="checkbox"] {
    width: 20px;
    height: 20px;
    margin-right: 12px;
    cursor: pointer;
}

.account-info {
    flex: 1;
}

.account-name {
    font-weight: 500;
    margin-bottom: 2px;
}

.account-email {
    font-size: 13px;
    color: var(--text-secondary);
}

.account-type {
    font-size: 12px;
    padding: 2px 8px;
    background: #e3f2fd;
    color: #1976d2;
    border-radius: 4px;
    margin-right: 8px;
}

.account-delete {
    background: none;
    border: none;
    color: var(--danger-color);
    cursor: pointer;
    padding: 4px 8px;
    font-size: 14px;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.account-delete:hover {
    opacity: 1;
}

.accounts-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.no-accounts {
    text-align: center;
    padding: 30px;
    color: var(--text-secondary);
}

/* 对话区域 */
.chat-section {
    background: var(--card-background);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    height: calc(100vh - 380px);
    min-height: 400px;
}

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

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.message {
    margin-bottom: 20px;
    display: flex;
    gap: 12px;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.message-user .message-avatar {
    background: #e3f2fd;
}

.message-assistant .message-avatar {
    background: #f3e5f5;
}

.message-content {
    flex: 1;
    background: #f8f9fa;
    padding: 12px 16px;
    border-radius: var(--radius);
    max-width: 85%;
}

.message-user .message-content {
    background: #e3f2fd;
}

.message-content p {
    margin-bottom: 8px;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.email-card {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 12px;
    margin: 8px 0;
}

.email-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.email-card-subject {
    font-weight: 500;
    color: var(--text-color);
}

.email-card-date {
    font-size: 12px;
    color: var(--text-secondary);
}

.email-card-from {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.email-card-summary {
    font-size: 14px;
    color: #666;
    line-height: 1.5;
}

.chat-input-area {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 12px;
}

.chat-input {
    flex: 1;
    padding: 14px 16px;
    font-size: 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    resize: none;
    min-height: 50px;
    max-height: 120px;
}

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

.chat-send-btn {
    padding: 14px 24px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 16px;
    transition: background 0.3s;
}

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

.chat-send-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.empty-chat {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-secondary);
    text-align: center;
    padding: 40px;
}

.empty-chat .icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.empty-chat p {
    font-size: 14px;
    max-width: 300px;
}

.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 8px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: #999;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-8px); }
}

/* ========== 弹窗 ========== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 20px;
}

.modal {
    background: var(--card-background);
    border-radius: var(--radius);
    width: 100%;
    max-width: 450px;
    max-height: 90vh;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
}

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

.modal-header h3 {
    font-size: 18px;
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 4px 8px;
    line-height: 1;
}

.modal-close:hover {
    color: var(--text-color);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
    -webkit-overflow-scrolling: touch;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 14px;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px;
    font-size: 15px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.form-hint {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
    background: var(--card-background);
}

/* ========== 使用说明弹窗 ========== */
.help-modal {
    max-width: 600px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.help-modal .modal-body {
    overflow-y: auto;
    max-height: calc(90vh - 140px);
}

.help-content {
    font-size: 16px;
    line-height: 1.8;
}

.help-section {
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px dashed var(--border-color);
}

.help-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.help-section h4 {
    font-size: 18px;
    color: var(--primary-color);
    margin-bottom: 12px;
}

.help-section p {
    margin-bottom: 10px;
}

.help-section ul,
.help-section ol {
    margin-left: 20px;
    margin-bottom: 12px;
}

.help-section li {
    margin-bottom: 8px;
}

.help-tip {
    background: #fff3cd;
    border-left: 4px solid #ffc107;
    padding: 12px 16px;
    border-radius: 0 var(--radius) var(--radius) 0;
    margin-top: 12px;
    font-size: 14px;
    line-height: 1.6;
}

.help-examples {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.help-example {
    background: #e3f2fd;
    color: #1976d2;
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 14px;
    cursor: default;
}

/* ========== 授权码教程 ========== */
.auth-code-guide {
    background: #f0f7ff;
    border: 1px solid #b3d4fc;
    border-radius: var(--radius);
    padding: 16px;
    margin-top: 16px;
}

.guide-header {
    font-size: 16px;
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 12px;
}

.guide-steps {
    font-size: 14px;
    line-height: 1.8;
}

.guide-steps p {
    margin-bottom: 8px;
}

.guide-steps ol {
    margin-left: 20px;
    margin-bottom: 12px;
}

.guide-steps li {
    margin-bottom: 8px;
    padding-left: 4px;
}

.guide-steps a {
    color: var(--primary-color);
    text-decoration: underline;
}

.guide-steps strong {
    color: #333;
    background: #fff3cd;
    padding: 1px 4px;
    border-radius: 3px;
}

.guide-note {
    background: #fff;
    border-left: 3px solid var(--primary-color);
    padding: 10px 12px;
    margin-top: 12px;
    font-size: 13px;
    color: #555;
}

/* ========== 响应式 ========== */
@media (max-width: 768px) {
    .dashboard-container {
        padding: 10px;
    }

    .header {
        flex-direction: column;
        gap: 10px;
        text-align: center;
        padding: 12px 16px;
    }

    .header h1 {
        font-size: 20px;
    }

    .header-actions {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
        gap: 8px;
    }

    .header-actions .btn {
        padding: 8px 12px;
        font-size: 13px;
    }

    .section-header {
        flex-direction: column;
        gap: 10px;
        align-items: stretch;
    }

    .section-header .btn {
        width: 100%;
        justify-content: center;
    }

    .accounts-section {
        padding: 14px;
    }

    .chat-section {
        height: calc(100vh - 400px);
        min-height: 300px;
    }

    .message-content {
        max-width: 95%;
    }

    .accounts-actions {
        flex-wrap: wrap;
        gap: 8px;
    }

    /* 弹窗手机端优化 */
    .modal-overlay {
        padding: 10px;
        align-items: flex-start;
        padding-top: 20px;
    }

    .modal {
        max-width: 100%;
        max-height: calc(100vh - 40px);
        border-radius: 12px;
    }

    .modal-header {
        padding: 14px 16px;
    }

    .modal-header h3 {
        font-size: 17px;
    }

    .modal-body {
        padding: 16px;
    }

    .modal-footer {
        padding: 12px 16px;
        flex-direction: column;
        gap: 10px;
    }

    .modal-footer .btn {
        width: 100%;
        padding: 14px;
        font-size: 16px;
        justify-content: center;
    }

    /* 表单优化 */
    .form-group {
        margin-bottom: 14px;
    }

    .form-group label {
        font-size: 15px;
        margin-bottom: 8px;
    }

    .form-group input,
    .form-group select {
        padding: 14px 12px;
        font-size: 16px;
    }

    /* 授权码教程优化 */
    .auth-code-guide {
        padding: 14px;
        margin-top: 14px;
    }

    .guide-steps {
        font-size: 14px;
        line-height: 1.7;
    }

    .guide-steps ol {
        margin-left: 16px;
    }

    .guide-steps li {
        margin-bottom: 10px;
    }

    /* 使用说明弹窗 */
    .help-modal {
        max-width: 100%;
    }

    .help-section h4 {
        font-size: 16px;
    }

    .help-examples {
        gap: 6px;
    }

    .help-example {
        font-size: 13px;
        padding: 6px 12px;
    }
}

@media (max-width: 480px) {
    .login-box {
        padding: 30px 20px;
    }

    .login-box h1 {
        font-size: 24px;
    }

    .chat-section {
        height: calc(100vh - 380px);
        min-height: 280px;
    }

    .chat-input-area {
        flex-direction: column;
        padding: 12px;
        gap: 10px;
    }

    .chat-input {
        font-size: 16px;
        padding: 12px;
    }

    .chat-send-btn {
        width: 100%;
        padding: 14px;
        font-size: 16px;
    }

    .account-item {
        padding: 10px 12px;
    }

    .account-name {
        font-size: 15px;
    }

    .account-email {
        font-size: 12px;
    }

    .account-type {
        font-size: 11px;
        padding: 2px 6px;
    }
}

/* ========== 工具类 ========== */
.hidden {
    display: none !important;
}

.loading {
    opacity: 0.6;
    pointer-events: none;
}

.text-center {
    text-align: center;
}

.text-danger {
    color: var(--danger-color);
}

.text-success {
    color: var(--success-color);
}

.mt-2 {
    margin-top: 8px;
}

.mb-2 {
    margin-bottom: 8px;
}
