:root {
    --bg-primary: #F5F5F7;
    --bg-secondary: #FFFFFF;
    --bg-card: #FFFFFF;
    --bg-card-hover: #F8F8FA;
    --border-color: #E5E5EA;
    --text-primary: #1D1D1F;
    --text-secondary: #6E6E73;
    --text-muted: #8E8E93;
    --apple-blue: #007AFF;
    --apple-blue-hover: #0066D6;
    --apple-blue-bg: rgba(0, 122, 255, 0.1);
    --apple-green: #34C759;
    --apple-green-bg: rgba(52, 199, 89, 0.1);
    --apple-green-border: rgba(52, 199, 89, 0.3);
    --apple-red: #FF3B30;
    --apple-red-bg: rgba(255, 59, 48, 0.1);
    --apple-orange: #FF9500;
    --apple-purple: #AF52DE;
    --card-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
    --card-shadow-hover: 0 8px 24px rgba(0, 0, 0, 0.1);
    --input-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.top-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 32px;
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    position: sticky;
    top: 0;
    z-index: 100;
}

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

.back-link {
    color: var(--apple-blue);
    text-decoration: none;
    font-size: 15px;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: opacity 0.2s;
}

.back-link:hover {
    opacity: 0.7;
}

.page-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 17px;
    font-weight: 600;
    color: var(--text-primary);
}

.page-title svg {
    color: var(--apple-blue);
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.nav-icon-btn {
    color: var(--apple-blue);
    text-decoration: none;
    padding: 8px;
    border-radius: 10px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-icon-btn:hover {
    background: var(--apple-blue-bg);
}

.nav-icon-btn svg {
    width: 18px;
    height: 18px;
}

.main-content {
    flex: 1;
    padding: 32px 24px;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
}

.config-container {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.config-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 24px;
    box-shadow: var(--card-shadow);
    transition: box-shadow 0.3s ease;
}

.config-card:hover {
    box-shadow: var(--card-shadow-hover);
}

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

.card-header h3 {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 17px;
    font-weight: 600;
    color: var(--text-primary);
}

.card-header h3 svg {
    color: var(--apple-blue);
}

.provider-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 16px;
}

.provider-card {
    padding: 20px 16px;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 16px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.1, 0.25, 1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.provider-card:hover {
    border-color: var(--apple-blue);
    background: var(--apple-blue-bg);
    box-shadow: 0 4px 16px rgba(0, 122, 255, 0.12);
    transform: translateY(-2px);
}

.provider-card.active {
    border-color: var(--apple-blue);
    background: var(--apple-blue-bg);
    box-shadow: 0 4px 16px rgba(0, 122, 255, 0.15);
}

.provider-card svg {
    margin-bottom: 10px;
    color: var(--text-secondary);
    transition: color 0.3s;
}

.provider-card.active svg {
    color: var(--apple-blue);
}

.provider-card .provider-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-control {
    padding: 12px 16px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 15px;
    outline: none;
    transition: all 0.2s;
    box-shadow: var(--input-shadow);
}

.form-control:focus {
    border-color: var(--apple-blue);
    box-shadow: 0 0 0 4px var(--apple-blue-bg);
    background: var(--bg-secondary);
}

.form-control::placeholder {
    color: var(--text-muted);
}

.input-with-toggle {
    position: relative;
    display: flex;
    align-items: center;
}

.input-with-toggle .form-control {
    flex: 1;
    padding-right: 44px;
}

.toggle-visibility {
    position: absolute;
    right: 12px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toggle-visibility:hover {
    color: var(--apple-blue);
    background: var(--apple-blue-bg);
}

.toggle-visibility svg {
    width: 18px;
    height: 18px;
}

.form-range {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--border-color);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.form-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--apple-blue);
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 122, 255, 0.3);
    transition: all 0.2s;
}

.form-range::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.4);
}

.form-range::-moz-range-thumb {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--apple-blue);
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 8px rgba(0, 122, 255, 0.3);
}

.range-labels {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

.form-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 20px;
}

.test-result {
    font-size: 14px;
    font-weight: 500;
}

.test-result.success {
    color: var(--apple-green);
}

.test-result.error {
    color: var(--apple-red);
}

.active-ai-card {
    border-color: var(--apple-green-border);
    background: linear-gradient(135deg, var(--apple-green-bg) 0%, var(--bg-secondary) 100%);
}

.active-ai-card .card-header h3 {
    color: var(--apple-green);
}

.active-ai-card .card-header svg {
    color: var(--apple-green);
}

.active-ai-display {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.active-ai-icon {
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--apple-blue-bg);
    border: 1px solid rgba(0, 122, 255, 0.2);
    border-radius: 14px;
    color: var(--apple-blue);
}

.active-ai-icon svg {
    width: 26px;
    height: 26px;
}

.active-ai-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.active-ai-name {
    font-size: 17px;
    font-weight: 600;
    color: var(--text-primary);
}

.active-ai-model {
    font-size: 14px;
    color: var(--text-secondary);
}

.settings-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

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

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

.setting-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.setting-name {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-primary);
}

.setting-desc {
    font-size: 13px;
    color: var(--text-muted);
}

.switch {
    position: relative;
    width: 51px;
    height: 31px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--border-color);
    border-radius: 31px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.slider:before {
    position: absolute;
    content: "";
    height: 27px;
    width: 27px;
    left: 2px;
    bottom: 2px;
    background: white;
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

input:checked + .slider {
    background: var(--apple-green);
}

input:checked + .slider:before {
    transform: translateX(20px);
}

.models-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.model-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    transition: all 0.2s;
}

.model-item:hover {
    background: var(--bg-secondary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.model-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.model-status {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.model-status.active {
    background: var(--apple-green);
    box-shadow: 0 0 8px var(--apple-green);
}

.model-status.inactive {
    background: var(--text-muted);
}

.model-name {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-primary);
}

.model-provider {
    font-size: 13px;
    color: var(--text-muted);
}

.model-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.model-actions button,
.btn-set-active,
.btn-delete {
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 500;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-set-active {
    background: var(--apple-blue-bg);
    color: var(--apple-blue);
}

.btn-set-active:hover {
    background: var(--apple-blue);
    color: white;
}

.btn-delete {
    background: var(--apple-red-bg);
    color: var(--apple-red);
}

.btn-delete:hover {
    background: var(--apple-red);
    color: white;
}

.btn-delete svg {
    width: 14px;
    height: 14px;
}

.active-badge {
    font-size: 13px;
    color: var(--apple-green);
    font-weight: 500;
    padding: 8px 14px;
    background: var(--apple-green-bg);
    border-radius: 10px;
}

.btn {
    padding: 12px 24px;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
    -webkit-font-smoothing: antialiased;
}

.btn svg {
    width: 16px;
    height: 16px;
}

.btn-sm {
    padding: 8px 14px;
    font-size: 13px;
    border-radius: 10px;
}

.btn-sm svg {
    width: 14px;
    height: 14px;
}

.btn-lg {
    padding: 14px 32px;
    font-size: 16px;
    border-radius: 14px;
}

.btn-lg svg {
    width: 18px;
    height: 18px;
}

.btn-primary {
    background: var(--apple-blue);
    color: white;
    box-shadow: 0 2px 8px rgba(0, 122, 255, 0.25);
}

.btn-primary:hover {
    background: var(--apple-blue-hover);
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.35);
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--bg-primary);
    color: var(--apple-blue);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--apple-blue-bg);
    border-color: var(--apple-blue);
}

.save-actions {
    display: flex;
    justify-content: center;
    gap: 16px;
    padding: 24px 0;
}

.empty-state {
    text-align: center;
    padding: 32px;
    color: var(--text-muted);
    font-size: 14px;
}

@media (max-width: 768px) {
    .top-nav {
        padding: 14px 20px;
    }
    
    .main-content {
        padding: 24px 16px;
    }
    
    .config-card {
        padding: 20px;
        border-radius: 16px;
    }
    
    .form-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .provider-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 12px;
    }
    
    .provider-card {
        padding: 16px 12px;
    }
    
    .save-actions {
        flex-direction: column;
    }
    
    .save-actions .btn {
        width: 100%;
        justify-content: center;
    }
    
    .model-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .model-actions {
        width: 100%;
    }
    
    .model-actions button {
        flex: 1;
    }
}

@media (max-width: 480px) {
    .provider-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .active-ai-display {
        flex-direction: column;
        text-align: center;
    }
}
