/* 基础样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft YaHei', sans-serif;
    background: #f5f7fa;
}

/* 侧边栏 */
.sidebar {
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    position: sticky;
    top: 0;
}

.nav-link {
    color: rgba(255, 255, 255, 0.85);
    padding: 12px 20px;
    border-radius: 8px;
    margin: 4px 0;
    transition: all 0.3s;
}

.nav-link:hover {
    color: white;
    background: rgba(255, 255, 255, 0.2);
}

.nav-link.active {
    color: white;
    background: rgba(255, 255, 255, 0.25);
}

.nav-link i {
    width: 24px;
}

/* 主内容区 */
.main-content {
    padding: 30px;
    background: #f5f7fa;
    min-height: 100vh;
}

/* 卡片 */
.card {
    border: none;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
    margin-bottom: 20px;
}

.card-header {
    background: transparent;
    border-bottom: 1px solid #eee;
    padding: 16px 20px;
    font-weight: 600;
}

/* 统计卡片 */
.stat-card {
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 24px;
}

/* 表格 */
.table {
    margin-bottom: 0;
}

.table th {
    font-weight: 600;
    color: #666;
    border-bottom-width: 1px;
}

.table td {
    vertical-align: middle;
    color: #333;
}

/* 表单 */
.form-label {
    font-weight: 500;
    color: #555;
    margin-bottom: 6px;
}

.form-control, .form-select {
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 10px 12px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus, .form-select:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* 按钮 */
.btn {
    border-radius: 8px;
    padding: 8px 16px;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #5a6fd6 0%, #6a4190 100%);
    transform: translateY(-1px);
}

/* 状态标签 */
.badge {
    padding: 6px 12px;
    border-radius: 20px;
    font-weight: 500;
}

/* 设备项 */
.device-item, .cluster-item {
    background: #fafafa;
    transition: background 0.2s;
}

.device-item:hover, .cluster-item:hover {
    background: #f5f5f5;
}

/* 进度条 */
.progress {
    height: 8px;
    border-radius: 4px;
}

.progress-stacked {
    display: flex;
    height: 20px;
    border-radius: 10px;
    overflow: hidden;
}

/* ========== 移动端适配 ========== */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        width: 280px;
        z-index: 1000;
        transition: left 0.3s;
    }
    
    .sidebar.show {
        left: 0;
    }
    
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
        display: none;
    }
    
    .sidebar-overlay.show {
        display: block;
    }
    
    .main-content {
        margin-left: 0;
        padding: 15px;
    }
    
    .mobile-menu-btn {
        display: block;
        position: fixed;
        top: 15px;
        left: 15px;
        z-index: 998;
        background: #667eea;
        color: white;
        border: none;
        border-radius: 8px;
        padding: 10px 15px;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    }
    
    .col-md-2, .col-md-10 {
        width: 100%;
        flex: 0 0 100%;
        max-width: 100%;
    }
    
    .card-body {
        padding: 15px;
    }
    
    .table {
        font-size: 14px;
    }
    
    .btn-group-sm .btn {
        padding: 4px 8px;
    }
    
    /* 输入框优化 */
    .input-group {
        width: 100%;
    }
    
    .cluster-item .row .col-md-6,
    .device-item .row .col-md-5 {
        width: 100%;
        max-width: 100%;
        flex: 0 0 100%;
        margin-bottom: 10px;
    }
    
    .device-item .row .col-md-2 {
        width: 100%;
        max-width: 100%;
        flex: 0 0 100%;
    }
    
    .form-control {
        font-size: 16px !important;
    }
    
    .btn {
        min-height: 44px;
        min-width: 44px;
    }
    
    .form-label {
        font-size: 14px;
        margin-bottom: 4px;
    }
}

/* 桌面端隐藏移动菜单按钮 */
@media (min-width: 769px) {
    .mobile-menu-btn {
        display: none;
    }
}

/* ========== 照片样式 ========== */

/* 照片网格 */
.cluster-photos, .device-photos {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.photo-item {
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid #ddd;
}

.photo-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    cursor: pointer;
}

.photo-item .delete-btn {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(255, 0, 0, 0.7);
    color: white;
    border: none;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.photo-item .delete-btn:hover {
    background: rgba(255, 0, 0, 1);
}

/* 照片列表 */
.photo-list {
    max-height: 150px;
    overflow-y: auto;
    border: 1px solid #eee;
    border-radius: 6px;
    padding: 8px;
    background: #fafafa;
}

.photo-list-item {
    display: flex;
    align-items: center;
    padding: 4px 0;
    border-bottom: 1px dashed #eee;
}

.photo-list-item:last-child { 
    border-bottom: none; 
}

.photo-list-item i { 
    margin-right: 6px; 
    color: #667eea; 
}

.photo-list-item a {
    flex: 1;
    color: #333;
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.photo-list-item a:hover { 
    color: #667eea; 
    text-decoration: underline; 
}

/* 照片弹窗 */
.photo-modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.photo-modal-content {
    background: white;
    border-radius: 12px;
    width: 500px;
    max-width: 90%;
    max-height: 80vh;
    overflow: hidden;
}

.photo-modal-header {
    display: flex;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid #eee;
    font-weight: bold;
}

.photo-modal-header button {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
}

.photo-modal-body { 
    padding: 16px; 
    text-align: center; 
}

.photo-modal-footer {
    padding: 12px 16px;
    border-top: 1px solid #eee;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* 照片列表容器 */
.photo-list-container {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid #eee;
    border-radius: 6px;
    padding: 8px;
    background: #fafafa;
}

/* Toast 样式 */
.toast-container {
    z-index: 1100;
}

/* 空状态 */
.empty-state {
    text-align: center;
    padding: 40px;
    color: #999;
}

.empty-state i {
    font-size: 48px;
    margin-bottom: 16px;
}

/* 打印样式 */
@media print {
    .sidebar, .mobile-menu-btn, .btn, .card-footer {
        display: none !important;
    }
    
    .main-content {
        margin: 0;
        padding: 0;
    }
    
    .card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}

/* ========== 手机端输入框优化（追加，不冲突） ========== */
@media (max-width: 768px) {
    .col-md-6, .col-md-5, .col-md-4, .col-md-3, .col-md-2 {
        width: 100% !important;
        max-width: 100% !important;
        flex: 0 0 100% !important;
    }
    .input-group {
        width: 100% !important;
    }
    input.form-control {
        font-size: 16px !important;
    }
}