/* AI翻译器移动端优化样式 - 简化版本 */

/* 移动端主题变量覆盖（更易读、留白更大） */
@media (max-width: 768px) {
    :root {
        --font-base: 15.5px;
        --line-base: 1.6;
        --radius-md: 12px;
        --radius-lg: 12px;
        --control-height: 48px;
        --btn-height: 50px;
        --card-padding: 1rem;
        --shadow-md: 0 8px 18px rgba(0,0,0,0.12);
    }
}

/* === 移动端全局优化 === */
@media (max-width: 768px) {
    /* 全局样式 */
    body { font-size: var(--font-base); line-height: var(--line-base); }

    .container {
        padding: 0 1rem;
        max-width: 100%;
    }

    main.container {
        padding: 1rem 0;
    }

    /* 标题优化 */
    .display-4 {
        font-size: 1.5rem !important;
        margin-bottom: 0.5rem;
    }

    .lead {
        font-size: 0.9rem;
        margin-bottom: 1rem;
    }

    /* 卡片优化 */
    .card { border-radius: var(--radius-lg) !important; margin-bottom: 1rem; padding: var(--card-padding); }

    .card-body {
        padding: 1.5rem !important;
    }

    /* === 语言选择区域 - 水平对齐优化 === */
    .row.mb-4 {
        margin-bottom: 1.5rem !important;
    }

    /* 语言选择框保持水平布局 */
    .col-md-5 {
        width: 45%;
        margin-bottom: 0;
    }

    .col-md-2 {
        width: 10%;
        margin-bottom: 0;
    }

    /* 交换按钮居中对齐 */
    #swapLanguages {
        width: 100%;
        height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 8px;
        margin: 0;
    }

    /* 表单标签对齐 */
    .form-label {
        font-size: 0.9rem;
        font-weight: 600;
        margin-bottom: 0.5rem;
        white-space: nowrap;
    }

    .form-label i {
        font-size: 0.8rem;
        margin-right: 0.25rem;
    }

    /* 表单控件统一高度 */
    .form-control, .form-select {
        font-size: 0.95rem;
        padding: 0.6rem;
        border-radius: var(--radius-md) !important;
        height: var(--control-height) !important;
        min-height: var(--control-height) !important;
    }

    /* 文本区域优化 */
    textarea.form-control {
        min-height: 120px;
        max-height: 300px;
        resize: vertical;
    }

    /* 字符计数和按钮水平对齐 */
    .d-flex.justify-content-between {
        flex-direction: row;
        align-items: center;
        gap: 1rem;
    }

    .d-flex.justify-content-between .text-muted {
        font-size: 0.8rem;
        margin: 0;
    }

    #detectLanguage {
        padding: 0.4rem 0.8rem;
        font-size: 0.8rem;
        min-height: 32px;
        margin: 0;
    }

    /* === 模型选择区域 - 水平对齐优化 === */
    .row.mb-3 {
        margin-bottom: 1rem !important;
    }

    .col-md-4 {
        width: 35%;
        margin-bottom: 0;
    }

    .col-md-6 {
        width: 55%;
        margin-bottom: 0;
    }

    .col-md-2 {
        width: 10%;
        margin-bottom: 0;
    }

    #refreshModels {
        width: 100%;
        height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        margin: 0;
    }

    /* === 翻译文本区域 - 水平对齐优化 === */
    .col-md-6 {
        width: 50%;
        margin-bottom: 0;
    }

    /* 复制按钮对齐 */
    .mt-2.text-end {
        text-align: right;
        margin-top: 0.5rem;
    }

    #copyResult {
        padding: 0.4rem 0.8rem;
        font-size: 0.8rem;
        min-height: 32px;
    }

    /* === 翻译按钮优化 === */
    .text-center.mt-4 {
        margin-top: 1.5rem !important;
    }

    #translateBtn {
        width: 100%;
        padding: 1rem;
        font-size: 1.1rem;
        font-weight: 600;
        border-radius: 12px;
        min-height: 50px;
    }

    /* === 加载状态优化 === */
    #loadingIndicator {
        padding: 1rem;
    }

    #loadingIndicator .spinner-border {
        width: 2rem;
        height: 2rem;
    }

    /* === 警告框优化 === */
    .alert {
        margin-top: 1rem;
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
    }

    /* === 功能说明区域优化 === */
    .row.mt-5 {
        margin-top: 2rem !important;
    }

    .col-md-4 {
        width: 33.333%;
        margin-bottom: 1.5rem;
    }

    /* === 页脚优化 === */
    footer {
        padding: 1rem 0;
        margin-top: 2rem;
        font-size: 0.8rem;
    }

    /* === 实时提示优化 === */
    .real-time-hint {
        font-size: 0.7rem;
        margin-top: 0.25rem;
        opacity: 0.7;
    }

    /* === 语言检测状态优化 === */
    .detection-status {
        font-size: 0.75rem;
        margin-top: 0.25rem;
        padding: 0.25rem 0.5rem;
        background-color: rgba(0, 123, 255, 0.1);
        border-radius: 4px;
        display: inline-block;
    }

    /* === 特殊交互优化 === */
    * {
        touch-action: manipulation;
    }

    .btn {
        min-height: var(--btn-height) !important;
        display: flex;
        align-items: center;
        justify-content: center;
        white-space: nowrap;
        border-radius: var(--radius-md) !important;
    }

    /* === 键盘弹出时优化 === */
    @media (max-width: 768px) and (max-height: 600px) {
        .row.mt-5 {
            margin-top: 1rem !important;
        }

        footer {
            margin-top: 1rem;
            padding: 0.5rem 0;
        }
    }
}

/* === 小屏幕手机优化 === */
@media (max-width: 480px) {
    body {
        font-size: 13px;
    }

    .container {
        padding: 0 0.5rem;
    }

    .card-body {
        padding: 1rem !important;
    }

    /* 小屏幕下改为垂直布局 */
    .col-md-5, .col-md-2, .col-md-6, .col-md-4 {
        width: 100%;
        margin-bottom: 0.75rem;
    }

    .col-md-5:last-child, .col-md-6:last-child, .col-md-4:last-child {
        margin-bottom: 0;
    }

    /* 字符计数和按钮改为垂直布局 */
    .d-flex.justify-content-between {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    #detectLanguage {
        align-self: flex-end;
    }

    /* 复制按钮左对齐 */
    .mt-2.text-end {
        text-align: left;
    }

    /* 功能说明区域改为垂直布局 */
    .col-md-4 {
        width: 100%;
    }
}

/* === 横屏模式优化 === */
@media (max-width: 768px) and (orientation: landscape) {
    main.container {
        padding: 0.5rem 0;
    }

    .card-body {
        padding: 1rem !important;
    }

    textarea.form-control {
        min-height: 80px;
        max-height: 150px;
    }

    .row.mt-5 {
        margin-top: 1rem !important;
    }

    footer {
        margin-top: 1rem;
        padding: 0.5rem 0;
    }
}

/* === 深色模式支持 === */
@media (prefers-color-scheme: dark) {
    @media (max-width: 768px) {
        body {
            background-color: #1a1a1a;
            color: #e0e0e0;
        }

        .card {
            background-color: #2d2d2d;
            color: #e0e0e0;
        }

        .form-control, .form-select {
            background-color: #3d3d3d;
            border-color: #555;
            color: #e0e0e0;
        }

        .form-control:focus, .form-select:focus {
            background-color: #3d3d3d;
            border-color: #007bff;
        }

        .form-label {
            color: #e0e0e0;
        }

        .text-muted {
            color: #a0a0a0 !important;
        }

        .real-time-hint {
            color: #a0a0a0;
        }

        #translatedText {
            background-color: #3d3d3d;
            color: #e0e0e0;
        }

        .navbar {
            background-color: #2d2d2d !important;
        }

        footer {
            background-color: #2d2d2d !important;
            color: #a0a0a0;
        }
    }
}
