/* 全局样式 */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
        'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
        sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    line-height: 1.6;
}

/* 滚动条样式 */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

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

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

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

/* 摄像头列表样式 */
.camera-item {
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    overflow: hidden;
    transition: all 0.3s ease;
    cursor: pointer;
}

.camera-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.camera-item.active {
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.camera-item-image {
    width: 100%;
    height: 120px;
    object-fit: cover;
    background-color: #f3f4f6;
}

.camera-item-info {
    padding: 12px;
}

.camera-item-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.camera-item-location {
    font-size: 0.75rem;
    color: #6b7280;
}

.camera-item-status {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 9999px;
    font-size: 0.75rem;
    margin-top: 4px;
}

.camera-item-status.online {
    background-color: #d1fae5;
    color: #065f46;
}

.camera-item-status.offline {
    background-color: #fee2e2;
    color: #991b1b;
}

/* 骨架屏动画 */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* 加载动画 */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.pulse-animation {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* 平滑滚动 */
html {
    scroll-behavior: smooth;
}

/* 模态框动画 */
.modal-transition-enter {
    opacity: 0;
}

.modal-transition-enter-active {
    opacity: 1;
    transition: opacity 300ms;
}

.modal-transition-exit {
    opacity: 1;
}

.modal-transition-exit-active {
    opacity: 0;
    transition: opacity 300ms;
}

/* 响应式调整 */
/* 平板设备 */
@media (max-width: 768px) {
    /* 调整容器宽度和边距 */
    .container {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
    
    /* 调整卡片布局 */
    .grid {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }
    
    /* 调整按钮大小和间距 */
    button, a {
        touch-action: manipulation;
    }
    
    .bg-blue-600:hover {
        background-color: #3b82f6;
    }
}

/* 手机设备 - 小型屏幕 */
@media (max-width: 480px) {
    /* 调整字体大小 */
    h1 {
        font-size: 1.5rem !important;
    }
    
    h2 {
        font-size: 1.25rem !important;
    }
    
    h3 {
        font-size: 1.125rem !important;
    }
    
    p {
        font-size: 0.875rem !important;
    }
    
    /* 调整按钮大小 */
    button, .bg-blue-600 {
        font-size: 0.875rem !important;
        padding: 0.5rem 1rem !important;
    }
    
    /* 调整热门省份按钮 */
    #popularProvinces button {
        margin: 0.25rem !important;
        padding: 0.5rem !important;
    }
    
    /* 调整监控地址卡片 */
    #monitoringLinks > div {
        padding: 1rem !important;
    }
    
    /* 调整搜索框大小 */
    input, select {
        padding: 0.5rem !important;
    }
    
    /* 调整帮助模态框 */
    #helpModal {
        padding: 1rem !important;
    }
    
    #helpModal > div {
        margin: 1rem !important;
        max-height: 90vh !important;
    }
    
    /* 调整页脚 */
    footer {
        padding: 1rem !important;
    }
}

/* 手机设备 - 竖屏优化 */
@media (max-width: 480px) and (orientation: portrait) {
    /* 调整顶部导航 */
    header {
        padding: 0.5rem 1rem !important;
    }
    
    /* 优化监控卡片布局 */
    #monitoringLinks > div {
        flex-direction: column !important;
    }
    
    /* 确保内容在安全区域内 */
    body {
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* 手机设备 - 横屏优化 */
@media (max-width: 823px) and (orientation: landscape) {
    /* 优化横屏布局 */
    .grid {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)) !important;
    }
    
    /* 调整导航栏高度 */
    header {
        padding: 0.5rem 1rem !important;
        height: auto !important;
    }
}

/* 高DPI屏幕优化 */
@media (-webkit-device-pixel-ratio: 2), (resolution: 192dpi) {
    /* 优化图标和图像显示 */
    .fa {
        font-size: 1.1em;
    }
}

/* 触摸设备优化 */
@media (hover: none) and (pointer: coarse) {
    /* 优化触摸交互 */
    button, a {
        transition: none !important;
    }
    
    button:active, a:active {
        transform: scale(0.98);
    }
    
    /* 移除悬停效果 */
    .hover\:shadow-md:hover {
        box-shadow: none;
    }
}

/* 禁用文本选择（提高触摸体验） */
.no-select {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* 优化滚动性能 */
.scroll-smooth {
    -webkit-overflow-scrolling: touch;
}

/* 移动端菜单样式 */
.mobile-menu {
    display: none;
}

@media (max-width: 768px) {
    .mobile-menu {
        display: block;
    }
}

/* 自定义滚动条 */
.custom-scrollbar {
    scrollbar-width: thin;
    scrollbar-color: #888 #f1f1f1;
}

/* 按钮悬停效果 */
.btn-hover {
    transition: all 0.2s ease;
}

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

.btn-hover:active {
    transform: translateY(0);
}

/* 工具提示样式 */
.tooltip {
    position: relative;
    display: inline-block;
}

.tooltip .tooltip-text {
    visibility: hidden;
    width: 120px;
    background-color: #555;
    color: #fff;
    text-align: center;
    border-radius: 6px;
    padding: 5px;
    position: absolute;
    z-index: 1;
    bottom: 125%;
    left: 50%;
    margin-left: -60px;
    opacity: 0;
    transition: opacity 0.3s;
    font-size: 0.75rem;
}

.tooltip:hover .tooltip-text {
    visibility: visible;
    opacity: 1;
}

/* 自定义动画 */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

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

/* 加载指示器样式 */
.loading-spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid #3498db;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 自适应表格 */
.table-responsive {
    overflow-x: auto;
}

/* 图片懒加载样式 */
.lazy-image {
    opacity: 0;
    transition: opacity 0.3s ease-in;
}

.lazy-image.loaded {
    opacity: 1;
}