/* 基础样式 - 响应式设计核心 */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    max-width: 1200px;
    margin: 0 auto;
    padding: 16px;
    line-height: 1.5;
    background-color: #f5f5f5;
    font-size: 14px;
}

/* 连接状态卡片 - 置顶在两个卡片之上 */
.connection-status-card {
    background: white;
    border-radius: 8px;
    padding: 12px 16px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
    margin-bottom: 8px; /* 减小间距 */
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    grid-column: 1 / -1; /* 跨两列 */
}

.connection-badge {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.badge-disconnected {
    background-color: #f44336;
}

.badge-connected {
    background-color: #4CAF50;
}

.badge-connecting {
    background-color: #ff9800;
}

.connection-text {
    font-size: 14px;
    font-weight: 500;
    color: #333;
}

/* 顶部消息提示样式 */
.notification-container {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    width: 100%;
    max-width: 800px;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.notification {
    padding: 10px 16px;
    border-radius: 6px;
    color: white;
    font-size: 13px;
    font-weight: 500;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    transition: all 0.3s ease;
    opacity: 0;
    transform: translateY(-20px);
    animation: slideDown 0.3s forwards;
}

@keyframes slideDown {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.notification.success {
    background-color: #4CAF50;
}

.notification.error {
    background-color: #f44336;
}

.notification.info {
    background-color: #2196F3;
}

.notification.warning {
    background-color: #ff9800;
}

/* 布局容器 */
.main-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

.log-container {
    grid-column: 1 / -1;
}

.card {
    background: white;
    border-radius: 8px;
    padding: 16px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
    height: 100%;
}

h2 {
    color: #333;
    margin-bottom: 16px;
    font-size: 18px;
    border-bottom: 1px solid #eee;
    padding-bottom: 6px;
    font-weight: 500;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* 表单样式 */
.form-group {
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

label {
    font-weight: 500;
    color: #555;
    font-size: 13px;
}

input[type="text"], select, input[type="file"] {
    padding: 8px 10px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    font-size: 13px;
    width: 100%;
    transition: border 0.2s;
}

input[type="text"]:focus, select:focus {
    outline: none;
    border-color: #2196F3;
    box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.08);
}

/* 可拉伸的文本框样式 */
.resizable-textarea {
    padding: 8px 10px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    font-size: 13px;
    width: 100%;
    min-height: 100px; /* 最小高度 */
    height: 120px; /* 默认高度 */
    resize: vertical; /* 只允许垂直拉伸 */
    transition: border 0.2s;
    font-family: inherit;
    line-height: 1.5;
}

.resizable-textarea:focus {
    outline: none;
    border-color: #2196F3;
    box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.08);
}

/* 开关样式 */
.switch {
    position: relative;
    display: inline-block;
    width: 46px;
    height: 24px;
}

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

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: #2196F3;
}

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

/* 开关组样式 */
.switch-group {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.switch-label {
    flex: 1;
    font-weight: 500;
    color: #555;
    font-size: 13px;
}

/* 证书类型选择 */
.cert-type-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 10px 0;
}

.cert-type-option {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* 文件上传样式 */
.file-upload-group {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.file-input-wrapper {
    position: relative;
    flex: 1;
}

.file-input {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.file-display {
    padding: 8px 10px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    font-size: 13px;
    background-color: #f9f9f9;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.upload-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 6px;
    background-color: #2196F3;
    color: white;
    cursor: pointer;
    font-size: 16px;
}

/* 协议选择器样式 */
.protocol-group {
    display: flex;
    gap: 8px;
}

.protocol-select {
    flex: 0 0 100px;
}

.host-input {
    flex: 1;
}

/* 按钮样式 */
.btn-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 12px;
}

button {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
    flex: 1;
    min-width: 100px;
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary {
    background-color: #4CAF50;
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background-color: #43a047;
}

.btn-danger {
    background-color: #f44336;
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background-color: #d32f2f;
}

.btn-info {
    background-color: #2196F3;
    color: white;
}

.btn-info:hover:not(:disabled) {
    background-color: #1976D2;
}

.btn-secondary {
    background-color: #9e9e9e;
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background-color: #757575;
}

/* 订阅状态样式 */
.subscription-status {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    padding: 6px 10px;
    border-radius: 6px;
    background-color: #f8f8f8;
    font-size: 13px;
}

.status-badge {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.status-disconnected {
    background-color: #f44336;
}

.status-connected {
    background-color: #4CAF50;
}

/* 日志区域 */
textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    font-family: monospace;
    font-size: 12px;
    resize: vertical;
    min-height: 180px;
    line-height: 1.4;
}

/* 清空日志按钮 - 精简样式 */
.clear-log-btn {
    width: auto;
    min-width: 60px;
    max-width: 80px;
    padding: 2px 8px;
    font-size: 12px;
    white-space: nowrap;
    background-color: #2196F3;
    color: white;
    border-radius: 4px;
    flex: none;
}

.clear-log-btn:hover {
    background-color: #1976D2;
}

/* 可隐藏区域样式 */
.hideable-section {
    transition: all 0.3s ease;
}

.hidden {
    display: none;
}

.ssl-section {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #eee;
}

/* 响应式适配 */
@media (max-width: 768px) {
    .main-container {
        grid-template-columns: 1fr;
    }

    .form-row {
        display: flex;
        gap: 12px;
    }
    
    .form-row .form-group {
        flex: 1;
    }

    h2 {
        font-size: 20px;
    }

    .protocol-group {
        /* flex-direction: column; */
    }
    
    .protocol-select {
        flex: 1;
    }
    
    /* 移动端调整清空日志按钮 */
    .clear-log-btn {
        min-width: 50px;
        max-width: 70px;
        padding: 2px 6px;
        font-size: 11px;
    }
    
    /* 移动端调整消息内容框高度 */
    .resizable-textarea {
        min-height: 80px;
        height: 100px;
    }
}

@media (min-width: 1024px) {
    body {
        padding: 20px;
    }
    
    .card {
        padding: 20px;
    }
}

/* 提升页面加载体验 */
@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
    }
}