/* ========== 全局重置与基础样式 ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: #f0f2f5;
    color: #333;
    line-height: 1.6;
    min-height: 100vh;
}

/* ========== 导航栏 ========== */
.navbar {
    background: #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-container {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
}

.nav-brand {
    font-size: 18px;
    font-weight: 600;
    color: #1a73e8;
    text-decoration: none;
}

.nav-links {
    display: flex;
    gap: 8px;
}

.nav-link {
    color: #555;
    text-decoration: none;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 14px;
    transition: background 0.2s, color 0.2s;
}

.nav-link:hover {
    background: #f0f2f5;
    color: #1a73e8;
}

.nav-link.active {
    color: #1a73e8;
    font-weight: 500;
}

/* ========== 容器 ========== */
.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 20px 16px;
}

/* ========== 登录页 ========== */
.login-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 200px);
}

.login-card {
    background: #fff;
    border-radius: 12px;
    padding: 40px 32px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

.login-title {
    font-size: 24px;
    font-weight: 600;
    text-align: center;
    margin-bottom: 8px;
    color: #1a1a1a;
}

.login-subtitle {
    text-align: center;
    color: #888;
    margin-bottom: 28px;
    font-size: 14px;
}

/* ========== 表单控件 ========== */
.form-group {
    margin-bottom: 16px;
}

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

.form-label .required {
    color: #e53935;
}

.form-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #d9d9d9;
    border-radius: 8px;
    font-size: 15px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: #fff;
}

.form-input:focus {
    border-color: #1a73e8;
    box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.12);
}

.form-select {
    padding: 8px 12px;
    border: 1px solid #d9d9d9;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    background: #fff;
    cursor: pointer;
}

.form-select:focus {
    border-color: #1a73e8;
}

.error-msg {
    color: #e53935;
    font-size: 13px;
    margin-bottom: 12px;
    padding: 8px 12px;
    background: #fff5f5;
    border-radius: 6px;
}

/* ========== 按钮 ========== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, opacity 0.2s;
    text-decoration: none;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary {
    background: #1a73e8;
    color: #fff;
}

.btn-primary:hover:not(:disabled) {
    background: #1557b0;
}

.btn-secondary {
    background: #f0f2f5;
    color: #555;
}

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

.btn-danger {
    background: #fff5f5;
    color: #e53935;
}

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

.btn-block {
    width: 100%;
    padding: 12px;
    font-size: 16px;
}

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

.btn-copy-sm {
    background: none;
    border: 1px solid #d9d9d9;
    border-radius: 4px;
    padding: 2px 8px;
    font-size: 12px;
    color: #666;
    cursor: pointer;
    margin-left: 6px;
}

.btn-copy-sm:hover {
    background: #f0f2f5;
    color: #1a73e8;
    border-color: #1a73e8;
}

/* ========== 工具栏 ========== */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 10px;
}

.toolbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.update-time {
    font-size: 13px;
    color: #999;
}

/* ========== 短信卡片列表 ========== */
.sms-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.sms-card {
    background: #fff;
    border-radius: 10px;
    padding: 16px 20px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
    transition: box-shadow 0.2s;
}

.sms-card:hover {
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.sms-card.has-code {
    border-left: 4px solid #1a73e8;
}

.sms-card.has-code.code-faded {
    border-left-color: #a8c2ea;
}

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

.sms-platform {
    font-size: 14px;
    font-weight: 600;
    color: #1a73e8;
    background: #e8f0fe;
    padding: 2px 10px;
    border-radius: 12px;
}

.sms-platform.unknown {
    color: #999;
    background: #f5f5f5;
}

.sms-time {
    font-size: 13px;
    color: #999;
}

.sms-code {
    font-size: 36px;
    font-weight: 700;
    color: #1a73e8;
    letter-spacing: 4px;
    padding: 8px 0;
    cursor: pointer;
    user-select: all;
    transition: color 0.2s;
}

.sms-code:hover {
    color: #0d47a1;
}

.sms-card.has-code.code-faded .sms-code {
    color: #7ea2d6;
}

.sms-card.has-code.code-faded .sms-code:hover {
    color: #6f92c8;
}

.sms-card.has-code.code-faded .sms-platform:not(.unknown) {
    color: #5e84bc;
    background: #f1f6fe;
}

.sms-card.has-code.code-faded .sms-time,
.sms-card.has-code.code-faded .sms-meta,
.sms-card.has-code.code-faded .sms-content {
    color: #8f9ab0;
}

.sms-card.has-code.code-faded .sms-content {
    background: #f7f9fd;
}

.sms-code.no-code {
    font-size: 16px;
    color: #bbb;
    letter-spacing: 0;
    cursor: default;
    font-weight: 400;
}

.sms-meta {
    display: flex;
    gap: 20px;
    font-size: 13px;
    color: #888;
    margin-bottom: 8px;
}

.sms-content {
    font-size: 13px;
    color: #666;
    background: #fafafa;
    padding: 10px 12px;
    border-radius: 6px;
    line-height: 1.8;
    word-break: break-all;
}

/* ========== 空状态 ========== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #999;
    font-size: 15px;
}

.loading {
    text-align: center;
    padding: 40px;
    color: #999;
}

/* ========== 管理页面 ========== */
.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

.page-title {
    font-size: 22px;
    font-weight: 600;
}

.admin-actions {
    display: flex;
    gap: 8px;
}

.smsf-config-card {
    background: #fff;
    border-radius: 10px;
    padding: 14px 16px;
    margin-bottom: 12px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
    border: 1px solid #e7eef9;
}

.smsf-config-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.smsf-config-title {
    font-size: 16px;
    font-weight: 600;
    color: #1a73e8;
}

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

.device-card {
    background: #fff;
    border-radius: 10px;
    padding: 16px 20px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.device-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 8px;
}

.device-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.device-name {
    font-size: 16px;
    font-weight: 600;
}

.device-status {
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 500;
}

.status-active {
    background: #e8f5e9;
    color: #2e7d32;
}

.status-inactive {
    background: #fce4ec;
    color: #c62828;
}

.device-actions {
    display: flex;
    gap: 6px;
}

.device-details {
    font-size: 14px;
    color: #666;
}

.detail-row {
    padding: 4px 0;
}

.detail-row-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
}

.detail-row-actions .detail-label {
    margin-right: 2px;
}

.detail-row-actions .btn-copy-sm {
    margin-left: 0;
}

.detail-label {
    color: #999;
    font-size: 13px;
}

.device-key {
    font-size: 12px;
    background: #f5f5f5;
    padding: 2px 6px;
    border-radius: 4px;
    word-break: break-all;
}

/* ========== 弹窗 ========== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 200;
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
}

.modal-content {
    position: relative;
    background: #fff;
    border-radius: 12px;
    padding: 28px;
    width: 90%;
    max-width: 440px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
}

.modal-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 20px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 20px;
}

/* ========== 密钥展示 ========== */
.key-hint {
    font-size: 14px;
    color: #666;
    margin-bottom: 12px;
}

.key-display {
    background: #f5f5f5;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 14px;
    font-family: "Courier New", monospace;
    font-size: 15px;
    word-break: break-all;
    text-align: center;
    cursor: pointer;
    user-select: all;
    letter-spacing: 1px;
}

.key-warning {
    font-size: 13px;
    color: #e53935;
    margin-top: 10px;
}

/* ========== Toast 提示 ========== */
.toast {
    position: fixed;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: #fff;
    padding: 10px 24px;
    border-radius: 8px;
    font-size: 14px;
    z-index: 999;
    transition: opacity 0.3s;
    pointer-events: none;
}

.toast.hidden {
    opacity: 0;
}

/* ========== 通用隐藏 ========== */
.hidden {
    display: none !important;
}

/* ========== 响应式布局 ========== */
@media (max-width: 600px) {
    .nav-container {
        padding: 0 12px;
    }

    .container {
        padding: 12px;
    }

    .login-card {
        padding: 28px 20px;
        margin: 0 8px;
    }

    .sms-code {
        font-size: 28px;
        letter-spacing: 2px;
    }

    .sms-meta {
        flex-direction: column;
        gap: 4px;
    }

    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .toolbar-right {
        justify-content: space-between;
    }

    .admin-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .device-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .device-actions {
        width: 100%;
    }

    .device-actions .btn-sm {
        flex: 1;
        text-align: center;
    }

    .modal-content {
        width: 95%;
        padding: 20px;
    }
}
