/* 全局样式 */
: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;
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f8f9fa;
    line-height: 1.6;
}

/* 导航栏样式 */
.navbar {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.navbar-brand {
    font-weight: 600;
    font-size: 1.25rem;
}

.nav-link {
    font-weight: 500;
    transition: var(--transition);
    border-radius: var(--border-radius);
    margin: 0 0.25rem;
}

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

.nav-link.active {
    background-color: rgba(255, 255, 255, 0.2);
    font-weight: 600;
}

/* 卡片样式 */
.card {
    border: none;
    border-radius: 0.75rem;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    transition: var(--transition);
    overflow: hidden;
}

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

.card-header {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-bottom: 1px solid #dee2e6;
    font-weight: 600;
    padding: 1rem 1.5rem;
}

.card-body {
    padding: 1.5rem;
}

/* 按钮样式 */
.btn {
    border-radius: var(--border-radius);
    font-weight: 500;
    transition: var(--transition);
    border: none;
    padding: 0.5rem 1rem;
}

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

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

.btn-success {
    background: linear-gradient(135deg, #198754 0%, #157347 100%);
}

.btn-warning {
    background: linear-gradient(135deg, #ffc107 0%, #ffca2c 100%);
    color: #000;
}

.btn-danger {
    background: linear-gradient(135deg, #dc3545 0%, #bb2d3b 100%);
}

.btn-info {
    background: linear-gradient(135deg, #0dcaf0 0%, #3dd5f3 100%);
    color: #000;
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

/* 表格样式 */
.table {
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--box-shadow);
}

.table thead th {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-bottom: 2px solid #dee2e6;
    font-weight: 600;
    color: var(--dark-color);
    padding: 1rem 0.75rem;
}

.table tbody tr {
    transition: var(--transition);
}

.table tbody tr:hover {
    background-color: rgba(13, 110, 253, 0.05);
    transform: scale(1.01);
}

.table td {
    padding: 0.75rem;
    vertical-align: middle;
}

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

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

/* 修复下拉选择器箭头和文字重叠问题 */
.form-select {
    padding-right: 2.25rem;
    background-position: right 0.75rem center;
    background-size: 16px 12px;
}

/* 确保下拉选择器有足够的右边距 */
#yearSelect, #monthSelect {
    padding-right: 2.5rem;
    min-width: 100px;
}

.input-group-text {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border: 1px solid #ced4da;
    border-radius: var(--border-radius) 0 0 var(--border-radius);
}

/* 状态徽章 */
.badge {
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.35em 0.65em;
    border-radius: 0.25rem;
}

.status-pending {
    background-color: #ffc107;
    color: #000;
}

.status-in-progress {
    background-color: #0dcaf0;
    color: #000;
}

.status-completed {
    background-color: #198754;
    color: #fff;
}

.status-cancelled {
    background-color: #dc3545;
    color: #fff;
}

.status-closed {
    background-color: #6c757d;
    color: #fff;
}

/* 统计卡片 */
.stats-card {
    background: linear-gradient(135deg, #fff 0%, #f8f9fa 100%);
    border-left: 4px solid var(--primary-color);
    transition: var(--transition);
}

.stats-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 0.75rem 1.5rem rgba(0, 0, 0, 0.15);
}

.stats-card .card-body {
    padding: 1.5rem;
}

.stats-card h4 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.stats-card p {
    font-size: 0.875rem;
    color: var(--secondary-color);
    margin-bottom: 0;
}

/* 登录页面 */
.min-vh-100 {
    min-height: 100vh;
}

#loginPage .card {
    border: none;
    border-radius: 1rem;
    box-shadow: 0 1rem 3rem rgba(0, 0, 0, 0.175);
}

#loginPage .card-body {
    padding: 3rem;
}

#loginPage .form-control {
    padding: 0.75rem 1rem;
    font-size: 1rem;
}

#loginPage .btn {
    padding: 0.75rem 1rem;
    font-size: 1rem;
    font-weight: 600;
}

/* 模态框样式 */
.modal-content {
    border: none;
    border-radius: 0.75rem;
    box-shadow: 0 1rem 3rem rgba(0, 0, 0, 0.175);
}

.modal-header {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-bottom: 1px solid #dee2e6;
    border-radius: 0.75rem 0.75rem 0 0;
    padding: 1.5rem;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    border-top: 1px solid #dee2e6;
    padding: 1rem 1.5rem;
}

/* Toast 通知 */
.toast {
    border: none;
    border-radius: var(--border-radius);
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

.toast-header {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-bottom: 1px solid #dee2e6;
}

/* 加载遮罩 */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.loading-overlay .spinner-border {
    width: 3rem;
    height: 3rem;
}

/* 内容页面 */
.content-page {
    padding: 0 1rem;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .content-page {
        padding: 0 0.5rem;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    .table-responsive {
        font-size: 0.875rem;
    }
    
    .btn {
        padding: 0.375rem 0.75rem;
        font-size: 0.875rem;
    }
    
    .modal-body {
        padding: 1rem;
    }
    
    #loginPage .card-body {
        padding: 2rem;
    }
    
    /* 移动端文本截断调整 */
    .device-info-table .device-name {
        max-width: 100px;
    }
    
    .device-info-table .client-id {
        max-width: 120px;
    }
    
    .device-info-table .username {
        max-width: 80px;
    }
    
    .device-info-table .mqtt-host {
        max-width: 120px;
    }
}

@media (max-width: 576px) {
    .stats-card h4 {
        font-size: 1.5rem;
    }
    
    .navbar-brand {
        font-size: 1rem;
    }
    
    .table {
        font-size: 0.8rem;
    }
    
    .btn-sm {
        padding: 0.2rem 0.4rem;
        font-size: 0.75rem;
    }
}

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

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.fade-in {
    animation: fadeIn 0.5s ease-out;
}

.slide-in {
    animation: slideIn 0.3s ease-out;
}

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

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* 工具提示 */
.tooltip {
    font-size: 0.875rem;
}

/* 进度条 */
.progress {
    height: 0.5rem;
    border-radius: 0.25rem;
    background-color: #e9ecef;
}

.progress-bar {
    border-radius: 0.25rem;
    transition: width 0.6s ease;
}

/* 修复进度条百分比显示问题 */
.progress[style*="height: 25px"] {
    position: relative;
    min-height: 25px;
}

.progress[style*="height: 25px"] .progress-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    font-size: 12px;
    font-weight: bold;
    color: white;
    text-shadow: 1px 1px 1px rgba(0,0,0,0.5);
}

/* 进度条百分比显示控制 */
.progress[style*="height: 25px"] {
    position: relative;
}

.progress[style*="height: 25px"] .progress-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    font-size: 12px;
    font-weight: bold;
    color: white;
    text-shadow: 1px 1px 1px rgba(0,0,0,0.5);
}

/* 外部百分比显示 - 默认隐藏 */
.progress[style*="height: 25px"]::after {
    content: attr(data-percentage);
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    font-size: 12px;
    font-weight: bold;
    color: #333;
    z-index: 10;
    display: none;
}

/* 低进度时显示外部百分比，隐藏内部百分比 */
.progress[style*="height: 25px"].low-progress::after {
    display: block;
}

.progress[style*="height: 25px"].low-progress .progress-bar {
    color: transparent;
}

/* 分页 */
.pagination {
    margin-bottom: 0;
}

.page-link {
    border-radius: var(--border-radius);
    margin: 0 0.125rem;
    transition: var(--transition);
}

.page-link:hover {
    transform: translateY(-1px);
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}

/* 搜索框 */
.search-box {
    position: relative;
}

.search-box .form-control {
    padding-left: 2.5rem;
}

.search-box .search-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--secondary-color);
    z-index: 5;
}

/* 空状态 */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--secondary-color);
}

.empty-state i {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state h5 {
    margin-bottom: 0.5rem;
    color: var(--dark-color);
}

.empty-state p {
    margin-bottom: 0;
    font-size: 0.875rem;
}

/* 文本截断样式 */
.text-truncate-custom {
    max-width: 150px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: inline-block;
    vertical-align: middle;
}

.text-truncate-long {
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: inline-block;
    vertical-align: middle;
}

.text-truncate-short {
    max-width: 120px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: inline-block;
    vertical-align: middle;
}

/* 设备信息表格特定样式 */
.device-info-table {
    table-layout: fixed;
}

.device-info-table th:nth-child(1) { /* ID */
    width: 80px;
}
.device-info-table th:nth-child(2) { /* 创建时间 */
    width: 140px;
}

.device-info-table th:nth-child(3) { /* 关联状态 */
    width: 90px;
}

.device-info-table th:nth-child(4) { /* 关联设备ID */
    width: 150px;
}

.device-info-table th:nth-child(5) { /* 设备名称 */
    width: 150px;
}

.device-info-table th:nth-child(6) { /* 客户端ID */
    width: 180px;
}

.device-info-table th:nth-child(7) { /* 用户名 */
    width: 120px;
}

.device-info-table th:nth-child(8) { /* MQTT主机 */
    width: 200px;
}

.device-info-table th:nth-child(9) { /* 端口 */
    width: 80px;
}

.device-info-table th:nth-child(10) { /* 操作 */
    width: 120px;
}

.device-info-table .device-name {
    max-width: 150px;
}

.device-info-table .client-id {
    max-width: 180px;
}

.device-info-table .username {
    max-width: 120px;
}

.device-info-table .mqtt-host {
    max-width: 200px;
}

.device-info-table .device-id {
    max-width: 150px;
}

.device-info-table .device-name,
.device-info-table .client-id,
.device-info-table .username,
.device-info-table .mqtt-host,
.device-info-table .device-id {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: inline-block;
    vertical-align: middle;
}

/* 创建时间列样式 */
.device-info-table td:nth-child(1) {
    white-space: nowrap;
    font-size: 0.85rem;
}

/* 关联状态列样式 */
.device-info-table td:nth-child(2) {
    text-align: center;
}

/* 关联设备ID列样式 */
.device-info-table td:nth-child(3) {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-family: monospace;
    font-size: 0.9rem;
}
