/* File: assets/css/style.css */

:root {
    --primary-color: #007bff;
    --primary-hover: #0056b3;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #17a2b8;
    --secondary-color: #6c757d;
    --light-color: #f8f9fa;
    --dark-color: #343a40;
    --border-radius: 8px; /* 更圆润的角 */
    --box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08); /* 更柔和的阴影 */
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    
    /* 安全区域变量 (iPhone X+) */
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent; /* 移除移动端点击高亮 */
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f0f2f5;
    padding-bottom: calc(70px + var(--safe-area-bottom)); /* 为底部导航栏留出空间 */
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 15px;
}

/* 导航栏 (顶部用户信息区) */
.navbar {
    background-color: white;
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* 按钮优化 */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    text-decoration: none;
    transition: var(--transition);
    min-height: 38px; /* 保证触控高度 */
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary { background-color: var(--primary-color); color: white; }
.btn-primary:hover { background-color: var(--primary-hover); box-shadow: 0 2px 6px rgba(0, 123, 255, 0.3); }

.btn-success { background-color: var(--success-color); color: white; }
.btn-success:hover { background-color: #218838; box-shadow: 0 2px 6px rgba(40, 167, 69, 0.3); }

.btn-danger { background-color: var(--danger-color); color: white; }
.btn-danger:hover { background-color: #c82333; box-shadow: 0 2px 6px rgba(220, 53, 69, 0.3); }

.btn-warning { background-color: var(--warning-color); color: #212529; }
.btn-warning:hover { background-color: #e0a800; }

.btn-info { background-color: var(--info-color); color: white; }

.btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

/* 表单优化 */
.form-group { margin-bottom: 1.2rem; }

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--dark-color);
}

.form-control, .form-select {
    width: 100%;
    padding: 0.6rem 0.8rem;
    border: 1px solid #ddd;
    border-radius: var(--border-radius);
    font-size: 1rem;
    background-color: #fff;
    transition: var(--transition);
    appearance: none; /* 移除原生样式 */
}

.form-control:focus, .form-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.15);
}

/* 标签页导航 (响应式核心) */
.nav-pills {
    display: flex;
    list-style: none;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0.6rem 1.2rem;
    text-decoration: none;
    color: var(--secondary-color);
    border-radius: 20px; /* 胶囊状 */
    transition: var(--transition);
    font-weight: 500;
    background-color: rgba(0,0,0,0.03);
}

.nav-link:hover {
    background-color: rgba(0, 123, 255, 0.1);
    color: var(--primary-color);
}

.nav-link.active {
    background-color: var(--primary-color);
    color: white;
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.3);
}

.tab-content {
    background-color: white;
    padding: 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* 表格优化 (通用) */
.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-bottom: 1rem;
}

.table thead th {
    background-color: #f8f9fa;
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--secondary-color);
    border-bottom: 2px solid #e9ecef;
}

.table tbody td {
    padding: 1rem;
    border-bottom: 1px solid #f0f0f0;
    vertical-align: middle;
}

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* === 规则卡片网格布局 (替代表格) === */
.rules-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
    padding-bottom: 1rem;
}

@media (max-width: 768px) {
    .rules-grid {
        grid-template-columns: 1fr; /* 手机端单列 */
    }
}

.rule-card {
    background: white;
    border-radius: 12px;
    padding: 1.25rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    border: 1px solid rgba(0,0,0,0.03);
    display: flex;
    flex-direction: column;
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
    overflow: hidden;
}

.rule-card:active {
    transform: scale(0.98);
}

.rule-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
}

/* 根据加减分改变左侧边框颜色 */
.rule-card.type-add::before { background-color: var(--success-color); }
.rule-card.type-sub::before { background-color: var(--danger-color); }

.rule-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.8rem;
    font-size: 0.85rem;
    color: #888;
}

.rule-content {
    font-size: 1.1rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 1rem;
    line-height: 1.5;
    flex-grow: 1;
}

.rule-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid #f0f0f0;
    padding-top: 0.8rem;
    margin-top: auto;
}

.rule-points {
    font-size: 1.2rem;
    font-weight: bold;
}
.rule-points.add { color: var(--success-color); }
.rule-points.sub { color: var(--danger-color); }

/* === 聊天气泡样式 (愿望回复) === */
.chat-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1rem;
    background-color: #f8f9fa;
    border-radius: var(--border-radius);
    max-height: 400px;
    overflow-y: auto;
    margin-bottom: 1rem;
}

.chat-msg {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    position: relative;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.chat-msg.left {
    align-self: flex-start;
}

.chat-msg.right {
    align-self: flex-end;
    align-items: flex-end;
}

.chat-info {
    font-size: 0.75rem;
    color: #999;
    margin-bottom: 4px;
    padding: 0 4px;
}

.chat-bubble {
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 0.95rem;
    line-height: 1.5;
    word-break: break-word;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    position: relative;
}

.chat-msg.left .chat-bubble {
    background-color: white;
    color: #333;
    border-bottom-left-radius: 4px;
    border: 1px solid #e9ecef;
}

.chat-msg.right .chat-bubble {
    background-color: var(--primary-color);
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    color: white;
    border-bottom-right-radius: 4px;
}

/* 徽章 */
.badge {
    display: inline-block;
    padding: 0.35rem 0.6rem;
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: 4px;
    margin-right: 0.25rem;
    line-height: 1;
}
.bg-primary { background: rgba(0, 123, 255, 0.1); color: var(--primary-color); }
.bg-success { background: rgba(40, 167, 69, 0.1); color: var(--success-color); }
.bg-danger { background: rgba(220, 53, 69, 0.1); color: var(--danger-color); }
.bg-warning { background: rgba(255, 193, 7, 0.15); color: #856404; }
.bg-info { background: rgba(23, 162, 184, 0.1); color: var(--info-color); }
.bg-secondary { background: #e9ecef; color: var(--secondary-color); }

/* 卡片 - 更像 App 里的卡片 */
.card {
    background-color: white;
    border: none;
    border-radius: var(--border-radius);
    margin-bottom: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    overflow: hidden;
    transition: var(--transition);
}

.card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.card-header {
    padding: 1rem;
    background-color: white;
    border-bottom: 1px solid #f0f0f0;
}

.card-body { padding: 1.25rem; }

.collapse { display: none; }
.collapse.show { display: block; }

/* 移动端底部导航栏适配 (Magic Happen Here) */
@media (max-width: 768px) {
    body {
        background-color: #f8f8f8;
    }

    .container {
        padding: 10px;
    }

    /* 将 nav-pills 转换为底部固定 TabBar */
    .nav-pills {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(10px);
        box-shadow: 0 -2px 15px rgba(0,0,0,0.05);
        margin: 0;
        padding: 5px 0 calc(5px + var(--safe-area-bottom));
        justify-content: space-around;
        z-index: 9999;
        flex-direction: row;
        border-top: 1px solid rgba(0,0,0,0.05);
    }

    .nav-item {
        flex: 1;
        display: flex;
        justify-content: center;
    }

    .nav-link {
        flex-direction: column;
        padding: 5px 0;
        font-size: 0.75rem;
        border-radius: 8px;
        background: transparent !important; /* 移除胶囊背景 */
        color: #999;
        width: 100%;
        gap: 2px;
    }

    .nav-link:hover {
        background: transparent;
        color: var(--primary-color);
    }
    
    .nav-link .emoji-icon {
        font-size: 1.4rem;
        margin-bottom: 1px;
        filter: grayscale(100%);
        transition: filter 0.2s;
    }

    .nav-link.active {
        color: var(--primary-color);
        box-shadow: none;
        font-weight: 600;
    }
    
    .nav-link.active .emoji-icon {
        filter: grayscale(0%);
    }

    .tab-content {
        padding: 1rem;
        box-shadow: none;
        background: transparent;
    }

    .card {
        box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    }
    
    /* 调整 Toast 位置避免被底部栏遮挡 */
    .toast {
        top: 20px;
        bottom: auto;
    }
}

/* 提示框 */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    background-color: #333;
    color: white;
    padding: 12px 20px;
    border-radius: 50px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 10000;
    display: none;
    min-width: 200px;
    text-align: center;
}

.toast.show {
    display: block;
    animation: slideInDown 0.3s ease;
}

@keyframes slideInDown {
    from { transform: translateY(-20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.toast-header { display: none; } /* 简化 Toast 样式 */

/* 警告框 */
.alert {
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: var(--border-radius);
    border: none;
}
.alert-danger { background-color: #ffeaea; color: #d63031; }

/* 模态框 */
.modal {
    display: none;
    position: fixed;
    z-index: 10001; /* 比底部栏高 */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
}

.modal.show { display: flex; align-items: center; justify-content: center; }

.modal-dialog {
    background-color: white;
    border-radius: 12px;
    max-width: 500px;
    width: 92%;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    animation: zoomIn 0.2s ease;
}

@keyframes zoomIn {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.modal-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #eee;
    font-weight: bold;
}

.modal-body { padding: 1.5rem; }

.modal-footer {
    padding: 1rem 1.25rem;
    background: #f9f9f9;
    border-radius: 0 0 12px 12px;
}

/* 工具类 & 栅格 */
.text-center { text-align: center; }
.text-nowrap { white-space: nowrap; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 1rem; }
.mb-3 { margin-bottom: 1rem; }
.me-2 { margin-right: 0.5rem; }
.d-flex { display: flex; }
.gap-2 { gap: 0.5rem; }

.btn-sm {
    padding: 0.25rem 0.6rem;
    font-size: 0.875rem;
    line-height: 1.5;
}

.row { display: flex; flex-wrap: wrap; margin: 0 -8px; }
.col-12 { flex: 0 0 100%; padding: 0 8px; }
.col-6 { flex: 0 0 50%; padding: 0 8px; }
.col-md-4 { flex: 0 0 33.333333%; padding: 0 8px; }

@media (max-width: 768px) {
    .col-md-4 { flex: 0 0 100%; }
    .col-6 { flex: 0 0 100%; }
}