/* ========================================
   自定义CSS样式 - 物业管理系统
   ======================================== */

/* 全局样式 */
:root {
    --primary-color: #0d6efd;
    --secondary-color: #6c757d;
    --success-color: #198754;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
    --info-color: #0dcaf0;
    --light-color: #f8f9fa;
    --dark-color: #212529;
    --border-radius: 0.375rem;
    --box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    --transition: all 0.15s ease-in-out;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: var(--dark-color);
}

/* 导航栏样式 */
.navbar {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    background: linear-gradient(135deg, var(--primary-color) 0%, #0b5ed7 100%) !important;
}

.navbar-brand {
    font-weight: 700;
    font-size: 1.5rem;
}

.navbar-nav .nav-link {
    font-weight: 500;
    transition: var(--transition);
    padding: 0.5rem 1rem !important;
    border-radius: var(--border-radius);
    margin: 0 0.25rem;
    display: flex !important;
    align-items: center !important;
    gap: 0.5rem;
}

.navbar-nav .nav-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
}

.navbar-nav .nav-link i {
    font-size: 1rem;
    min-width: 16px;
    text-align: center;
}

/* 确保下拉菜单项也是水平排列 */
.dropdown-item {
    display: flex !important;
    align-items: center !important;
    gap: 0.5rem;
}

.dropdown-item i {
    font-size: 1rem;
    min-width: 16px;
    text-align: center;
}

/* 修复折叠导航栏中的文字排列 */
.navbar-collapse .navbar-nav .nav-link,
.navbar-collapse .dropdown-item {
    writing-mode: initial !important;
    text-orientation: initial !important;
    direction: ltr !important;
    display: flex !important;
    align-items: center !important;
    gap: 0.5rem;
    white-space: nowrap;
}

.navbar-collapse .nav-link i,
.navbar-collapse .dropdown-item i {
    display: inline-block !important;
    writing-mode: initial !important;
    text-orientation: initial !important;
}

/* 主内容区域 */
.main-content {
    min-height: calc(100vh - 120px);
}

/* 在主内容区域中，让 Bootstrap 的 .container 在大屏时占据主区域的 80%
   这样可以覆盖 Bootstrap 默认的像素级 max-width（例如 1320px），
   避免容器被限制为较小的固定宽度而导致内部内容看起来被裁剪。 */
@media (min-width: 1400px) {
    .main-content > .container {
        width: 80%;
        max-width: none !important; /* 覆盖 Bootstrap 的 max-width */
        margin: 0 auto; /* 水平居中 */
    }
}

/* Hero区域样式 */
.hero-section {
    background: linear-gradient(135deg, var(--primary-color) 0%, #0b5ed7 100%);
    position: relative;
    overflow: hidden;
}

.hero-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 20"><defs><radialGradient id="a" cx="50%" cy="40%"><stop offset="0%" stop-color="%23ffffff" stop-opacity="0.1"/><stop offset="100%" stop-color="%23ffffff" stop-opacity="0"/></radialGradient></defs><rect width="100%" height="100%" fill="url(%23a)"/></svg>');
}

.hero-section .container {
    position: relative;
    z-index: 1;
}

.hero-section .btn {
    transition: var(--transition);
}

.hero-section .btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

/* 功能卡片样式 */
.feature-card {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    transition: var(--transition);
    border: 1px solid #e9ecef;
}

.feature-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

.feature-icon i {
    transition: var(--transition);
}

.feature-card:hover .feature-icon i {
    transform: scale(1.1);
}

/* 统计卡片样式 */
.stat-card {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    transition: var(--transition);
    border: 1px solid #e9ecef;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.1);
}

.stat-number {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

/* 卡片组件样式 */
.card {
    border: none;
    box-shadow: var(--box-shadow);
    transition: var(--transition);
}

.card:hover {
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.1);
}

.card-header {
    background: var(--light-color);
    border-bottom: 1px solid #e9ecef;
}

/* 表单样式 */
.form-control {
    border: 2px solid #e9ecef;
    border-radius: var(--border-radius);
    transition: var(--transition);
    padding: 0.75rem 1rem;
}

.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.15);
    transform: translateY(-2px);
}

.form-label {
    font-weight: 600;
    color: var(--dark-color);
    margin-bottom: 0.5rem;
}

/* 按钮样式 */
.btn {
    border-radius: var(--border-radius);
    font-weight: 600;
    transition: var(--transition);
    padding: 0.75rem 1.5rem;
}

.btn:hover {
    transform: translateY(-2px);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, #0b5ed7 100%);
    border: none;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #0b5ed7 0%, #0a52c7 100%);
}

/* 联系信息样式 */
.contact-info h6 {
    color: var(--dark-color);
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.contact-info .text-muted {
    padding-left: 2rem;
    margin-left: -2rem;
}

.social-links .btn {
    margin-bottom: 0.5rem;
}

/* 错误页面样式 */
.error-page h1 {
    font-size: 8rem;
    font-weight: 900;
    opacity: 0.5;
}

.error-page {
    padding: 3rem 0;
}

/* 页脚样式 */
footer {
    margin-top: auto;
    background: linear-gradient(135deg, var(--dark-color) 0%, #1a1d20 100%) !important;
}

footer a {
    transition: var(--transition);
}

footer a:hover {
    transform: scale(1.2);
    color: var(--primary-color) !important;
}

/* 警告框样式 */
.alert {
    border: none;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
}

.alert-dismissible .btn-close {
    padding: 1rem 1rem;
}

/* 动画效果 */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in-up {
    animation: fadeInUp 0.6s ease-out;
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}

.pulse {
    animation: pulse 2s infinite;
}

/* 加载动画 */
.loading {
    position: relative;
    color: transparent !important;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 1rem;
    height: 1rem;
    margin-top: -0.5rem;
    margin-left: -0.5rem;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* 响应式设计 */
@media (max-width: 768px) {
    .hero-section {
        padding: 2rem 0 !important;
    }
    
    .hero-section .display-4 {
        font-size: 2rem;
    }
    
    .stat-number {
        font-size: 2rem;
    }
    
    .error-page h1 {
        font-size: 4rem;
    }
    
    .feature-card {
        margin-bottom: 2rem;
    }
}

@media (max-width: 576px) {
    .hero-section .btn {
        display: block;
        width: 100%;
        margin-bottom: 1rem;
    }
    
    .navbar-brand {
        font-size: 1.25rem;
    }
    
    .stat-card {
        margin-bottom: 1rem;
    }
}

/* 自定义滚动条 */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--light-color);
}

::-webkit-scrollbar-thumb {
    background: var(--secondary-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}

/* 选择文本样式 */
::selection {
    background: var(--primary-color);
    color: white;
}

/* 调整 table-responsive 在大屏时的宽度与居中行为
   仅针对不使用 flex-grow-1 的表格容器，避免影响一些页面（如 communities.html）中
   使用 flex 布局使表格充满卡片高度的情况。需求：宽度为页面的 80%，最小为 1800px，
   不足时允许横向滚动，且容器水平居中。 */
.table-responsive:not(.flex-grow-1) {
    width: 100%;
    margin: 0 auto; /* 水平居中 */
    overflow-x: auto; /* 当表格宽度超出时启用横向滚动 */
    -webkit-overflow-scrolling: touch;
}

/* 如果需要，让里面的表格不自动换行（可保留/删除，按需启用） */
.table-responsive:not(.flex-grow-1) table {
    /* 优先让表格在容器内完全展示：
       - 宽度占满容器，避免超出被父元素裁剪
       - 使用固定表格布局以便单元格可预测地换行
       - 通过单元格换行/断字避免出现横向滚动条 */
    width: 100%;
    table-layout: fixed;
}

.table-responsive:not(.flex-grow-1) th,
.table-responsive:not(.flex-grow-1) td {
    white-space: normal; /* 允许换行 */
    word-break: break-word;
    overflow-wrap: anywhere;
}

/* 辅助类 */
.text-gradient {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--info-color) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.shadow-hover {
    transition: var(--transition);
}

.shadow-hover:hover {
    box-shadow: 0 1rem 3rem rgba(0, 0, 0, 0.175) !important;
}

/* 回到顶部按钮样式 */
#backToTopBtn {
    width: 50px !important;
    height: 50px !important;
    min-width: 50px !important;
    min-height: 50px !important;
    border-radius: 50% !important;
    padding: 0 !important;
    border: none !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2) !important;
    transition: all 0.3s ease-in-out !important;
    background: linear-gradient(135deg, var(--primary-color) 0%, #0b5ed7 100%) !important;
}

#backToTopBtn:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3) !important;
    background: linear-gradient(135deg, #0b5ed7 0%, var(--primary-color) 100%) !important;
}

#backToTopBtn:active {
    transform: translateY(0) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2) !important;
}

#backToTopBtn i {
    font-size: 16px !important;
    color: white !important;
    line-height: 1 !important;
}