/* ============ 全局变量 ============ */
:root {
    --primary-color: #4A7CC0;
    --primary-dark: #3A6CA0;
    --card-radius: 16px;
    --sidebar-width: 240px;
    --sidebar-bg: #2c3e50;
    --navbar-height: 90px;  /* 修改点2：顶部栏放大1.5倍 60->90 */
}

/* ============ 基础样式 ============ */
* {
    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: #f5f5f5;
}

/* ============ 导航栏 ============ */
.navbar {
    height: var(--navbar-height);
    box-shadow: 0 2px 4px rgba(0,0,0,0.08);
    z-index: 1030;
}

.navbar-brand {
    font-size: 1.4rem;
    font-weight: 600;
}

.brand-text {
    color: var(--primary-color);
    font-weight: 600;
}

.search-form {
    max-width: 500px;
}

.search-form .form-control {
    border-radius: 20px 0 0 20px;
    border-right: none;
    background: white;  /* 修改点2：搜索框底色纯白 */
}

.search-form .btn {
    border-radius: 0 20px 20px 0;
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.search-form .btn:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

/* ============ 主容器布局 ============ */
.main-container {
    display: flex;
    min-height: calc(100vh - var(--navbar-height));
    padding-top: var(--navbar-height);
}

/* ============ 左侧边栏 ============ */
.sidebar {
    position: fixed;
    left: 0;
    top: var(--navbar-height);
    width: var(--sidebar-width);
    height: calc(100vh - var(--navbar-height));
    background: white;
    border-right: 1px solid #eee;
    overflow-y: auto;
    transition: all 0.3s ease;
    z-index: 1020;
}

.sidebar.collapsed {
    left: calc(-1 * var(--sidebar-width));
}

.sidebar-header {
    padding: 15px 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-content {
    padding: 15px;
}

.search-history-item {
    padding: 8px 10px;
    border-radius: 6px;
    transition: background 0.2s;
}

.search-history-item:hover {
    background: #f5f5f5;
}

.search-history-item a {
    color: #333;
    font-size: 14px;
}

.delete-history {
    opacity: 0;
    transition: opacity 0.2s;
    padding: 2px 5px !important;
}

.search-history-item:hover .delete-history {
    opacity: 1;
}

/* ============ 主内容区 ============ */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 30px;
    transition: margin-left 0.3s ease;
}

.main-content.expanded {
    margin-left: 0;
}

/* ============ 功能卡片（首页4大卡片） ============ */
.hero-card {
    background: var(--primary-color);
    color: white;
    border-radius: var(--card-radius);
    padding: 40px 30px;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    height: 100%;
}

.hero-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.hero-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 24px rgba(0,0,0,0.15);
}

.hero-card:hover::before {
    opacity: 1;
}

.card-icon {
    font-size: 48px;
    opacity: 0.9;
}

.card-icon i {
    font-size: 48px;
}

.card-title {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 12px;
}

.card-desc {
    font-size: 14px;
    opacity: 0.85;
    margin-bottom: 15px;
}

.card-stats {
    padding-top: 15px;
    border-top: 1px solid rgba(255,255,255,0.2);
}

.card-stats small {
    opacity: 0.75;
}

/* ============ 分类卡片 ============ */
.category-card {
    border: 2px solid transparent;
    border-radius: 12px;
    transition: all 0.3s ease;
}

.category-card:hover {
    border-color: var(--primary-color);
    transform: translateY(-4px);
    box-shadow: 0 8px 16px rgba(0,0,0,0.1);
}

.category-icon {
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ============ 计算器卡片 ============ */
.calculator-card {
    border: 2px solid transparent;
    border-radius: 12px;
    transition: all 0.3s ease;
}

.calculator-card:hover {
    border-color: var(--primary-color);
    transform: translateY(-4px);
    box-shadow: 0 8px 16px rgba(0,0,0,0.1);
}

.calculator-icon {
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ============ 表格样式 ============ */
.table {
    margin-bottom: 0;
}

.table thead th {
    background: #f8f9fa;
    border-bottom: 2px solid #dee2e6;
    font-weight: 600;
    color: #495057;
}

.table tbody tr:hover {
    background: #f8f9fa;
}

/* ============ 按钮样式 ============ */
.btn-primary {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

.btn-outline-primary {
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-outline-primary:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

/* ============ 徽章 ============ */
.badge {
    font-weight: 500;
}

/* ============ 表单样式 ============ */
.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(74, 124, 192, 0.25);
}

.form-label {
    font-weight: 500;
    color: #495057;
}

/* ============ 卡片 ============ */
.card {
    border: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    border-radius: 12px;
}

.card-header {
    border-bottom: 1px solid #eee;
    background: white;
    border-radius: 12px 12px 0 0 !important;
}

/* ============ 分页 ============ */
.pagination .page-link {
    color: var(--primary-color);
}

.pagination .page-item.active .page-link {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

/* ============ 底部 ============ */
.footer {
    margin-top: auto;
    padding: 30px 0;
}

.footer a {
    text-decoration: none;
    font-size: 1.1rem;  /* 修改点5：底部按钮放大约1倍 */
    font-weight: 500;
}

.footer a:hover {
    text-decoration: underline;
}

/* ============ 管理后台侧边栏 ============ */
.admin-sidebar {
    min-height: calc(100vh - var(--navbar-height));
    background: var(--sidebar-bg);
}

.admin-sidebar .nav-link {
    color: rgba(255,255,255,0.8);
    padding: 12px 20px;
    border-left: 3px solid transparent;
    transition: all 0.2s;
}

.admin-sidebar .nav-link:hover,
.admin-sidebar .nav-link.active {
    color: white;
    background: rgba(255,255,255,0.1);
    border-left-color: var(--primary-color);
}

.admin-sidebar .nav-link i {
    width: 20px;
    text-align: center;
    margin-right: 8px;
}

.admin-content {
    background: #f8f9fa;
    min-height: calc(100vh - var(--navbar-height));
}

/* ============ 统计卡片（管理后台） ============ */
.card.bg-primary,
.card.bg-warning,
.card.bg-success,
.card.bg-info {
    border: none;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

/* ============ 响应式断点 ============ */

/* 手机端（<576px） */
@media (max-width: 576px) {
    .main-content {
        margin-left: 0;
        padding: 15px;
    }

    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.show {
        transform: translateX(0);
        width: var(--sidebar-width);
    }

    .hero-card {
        padding: 30px 20px;
    }

    .card-title {
        font-size: 20px;
    }

    .card-icon i {
        font-size: 36px;
    }

    .navbar-brand {
        font-size: 1.1rem;
    }

    .search-form {
        max-width: 100%;
    }
}

/* 平板端（576px - 768px） */
@media (min-width: 576px) and (max-width: 768px) {
    .main-content {
        margin-left: 0;
    }

    .sidebar {
        width: 0;
        overflow: hidden;
    }

    .sidebar.show {
        width: var(--sidebar-width);
    }
}

/* 平板端横屏（768px - 992px） */
@media (min-width: 768px) and (max-width: 992px) {
    .sidebar {
        width: 200px;
    }

    .main-content {
        margin-left: 200px;
    }
}

/* 汉堡菜单按钮（移动端显示） */
.navbar-toggler {
    border: none;
    padding: 4px 8px;
}

.navbar-toggler:focus {
    box-shadow: none;
}

/* ============ 动画 ============ */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.3s ease;
}

/* ============ 滚动条美化 ============ */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* ============ 工具类 ============ */
.text-primary-custom {
    color: var(--primary-color) !important;
}

.bg-primary-custom {
    background: var(--primary-color) !important;
}

.border-primary-custom {
    border-color: var(--primary-color) !important;
}

/* ============ 打印样式 ============ */
@media print {
    .sidebar,
    .navbar,
    .btn,
    .admin-sidebar {
        display: none !important;
    }

    .main-content {
        margin-left: 0 !important;
        padding: 0 !important;
    }

    .card {
        box-shadow: none !important;
        border: 1px solid #ddd !important;
    }
}

/* 修改点6：首页100%缩放完整显示 */
.hero-section {
    padding: 15px 0 8px !important;
}

.hero-card {
    padding: 20px 16px !important;
    min-height: auto !important;
}

.hero-card .card-icon {
    font-size: 32px !important;
    margin-bottom: 10px !important;
}

.hero-card .card-icon i {
    font-size: 32px !important;
}

.hero-card .card-title {
    font-size: 18px !important;
    margin-bottom: 6px !important;
}

.hero-card .card-desc {
    font-size: 12px !important;
    margin-bottom: 8px !important;
    line-height: 1.3 !important;
}

.hero-card .card-stats {
    padding-top: 8px !important;
    font-size: 11px !important;
}

/* 确保整体高度不溢出 */
.main-content {
    min-height: auto !important;
}

/* 调整卡片容器间距 */
.row.g-4.justify-content-center > .col-lg-3 {
    padding-left: 8px !important;
    padding-right: 8px !important;
}

/* 小屏幕适配 */
@media (max-width: 768px) {
    .hero-card {
        padding: 16px 12px !important;
    }
    .hero-card .card-title {
        font-size: 16px !important;
    }
}

/* ============ 首页紧凑布局（100%视口无滚动）============ */
.main-container {
    min-height: calc(100vh - var(--navbar-height));
    padding-bottom: 0;
}

.main-content {
    padding: 15px 20px;
}

/* 首页 hero 卡片紧凑 */
.hero-card {
    padding: 20px 15px !important;
}

.hero-card .card-icon {
    font-size: 36px !important;
    margin-bottom: 8px;
}

.hero-card .card-icon i {
    font-size: 36px !important;
}

.hero-card .card-title {
    font-size: 18px !important;
    margin-bottom: 6px;
}

.hero-card .card-desc {
    font-size: 12px !important;
    margin-bottom: 8px;
}

.hero-card .card-stats {
    padding-top: 8px;
    font-size: 12px;
}

/* 首页统计区域紧凑 */
.stats-row .card-body {
    padding: 12px !important;
}

.stats-row .display-6 {
    font-size: 28px !important;
}

.stats-row .card-text {
    font-size: 13px !important;
}

/* 页脚始终在底部 */
.footer {
    margin-top: auto;
    padding: 15px 0 !important;
    position: relative;
    z-index: 10;
}

/* 确保主容器 flex 布局撑满视口 */
body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.main-container {
    flex: 1;
}

/* 侧边栏展开按钮 - 样式由 base.html 内联控制 */
