/**
 * @file responsive.css
 * @brief ESP32-CAM Web客户端响应式样式
 * 
 * 针对不同屏幕尺寸的响应式设计
 */

/* 平板设备 (768px - 1024px) */
@media (max-width: 1024px) {
    .container {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid #e1e5e9;
        padding: 10px 0;
    }
    
    .sidebar-nav ul {
        display: flex;
        overflow-x: auto;
        padding: 0 20px;
    }
    
    .nav-item {
        padding: 10px 15px;
        border-left: none;
        border-bottom: 3px solid transparent;
        white-space: nowrap;
    }
    
    .nav-item.active {
        border-left: none;
        border-bottom-color: #667eea;
    }
    
    .main-content {
        padding: 20px;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .camera-container {
        grid-template-columns: 1fr;
    }
    
    .profile-content {
        grid-template-columns: 1fr;
    }
    
    .control-panel {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .device-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    }
}

/* 大屏手机 (576px - 768px) */
@media (max-width: 768px) {
    .header {
        padding: 0 15px;
        height: 60px;
    }
    
    .app-title {
        font-size: 18px;
    }
    
    .header-right {
        gap: 10px;
    }
    
    .user-info {
        font-size: 14px;
    }
    
    .btn {
        padding: 10px 15px;
        font-size: 14px;
    }
    
    .main-content {
        padding: 15px;
    }
    
    .page-header {
        flex-direction: column;
        gap: 15px;
        align-items: flex-start;
    }
    
    .page-actions {
        width: 100%;
        justify-content: flex-end;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .stat-card {
        padding: 20px;
    }
    
    .stat-icon {
        width: 50px;
        height: 50px;
        font-size: 32px;
    }
    
    .stat-info h3 {
        font-size: 28px;
    }
    
    .device-grid {
        grid-template-columns: 1fr;
    }
    
    .control-panel {
        grid-template-columns: 1fr;
    }
    
    .camera-controls {
        display: flex;
        flex-direction: column;
        gap: 10px;
        width: 100%;
    }
    
    .form-select {
        min-width: auto;
        width: 100%;
    }
    
    .modal-content {
        width: 95%;
        margin: 10% auto;
    }
    
    .profile-content {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .login-container {
        padding: 20px 15px;
    }
    
    .login-form {
        padding: 30px 20px;
    }
}

/* 小屏手机 (小于576px) */
@media (max-width: 576px) {
    .header {
        padding: 0 10px;
    }
    
    .header-left {
        gap: 10px;
    }
    
    .logo {
        width: 32px;
        height: 32px;
    }
    
    .app-title {
        font-size: 16px;
    }
    
    .connection-status span:last-child {
        display: none;
    }
    
    .user-info {
        font-size: 12px;
    }
    
    .btn {
        padding: 8px 12px;
        font-size: 12px;
    }
    
    .main-content {
        padding: 10px;
    }
    
    .page-header h2 {
        font-size: 24px;
    }
    
    .stat-card {
        padding: 15px;
        flex-direction: column;
        text-align: center;
        gap: 15px;
    }
    
    .stat-icon {
        width: 40px;
        height: 40px;
        font-size: 24px;
    }
    
    .stat-info h3 {
        font-size: 24px;
    }
    
    .device-header {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }
    
    .device-actions {
        width: 100%;
        justify-content: space-between;
    }
    
    .device-actions .btn {
        flex: 1;
        min-width: 0;
    }
    
    .camera-view {
        min-height: 300px;
    }
    
    .control-buttons {
        flex-direction: row;
        flex-wrap: wrap;
    }
    
    .control-buttons .btn {
        flex: 1;
        min-width: 120px;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .form-actions .btn {
        width: 100%;
    }
    
    .sidebar-nav ul {
        padding: 0 10px;
    }
    
    .nav-item {
        padding: 8px 12px;
        font-size: 14px;
    }
    
    .nav-item .icon {
        font-size: 16px;
    }
    
    .toast {
        top: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
    }
    
    .login-header h1 {
        font-size: 24px;
    }
    
    .login-logo {
        width: 60px;
        height: 60px;
    }
}

/* 超小屏设备 (小于400px) */
@media (max-width: 400px) {
    .header {
        flex-wrap: wrap;
        height: auto;
        padding: 10px;
    }
    
    .header-left, .header-right {
        width: 100%;
        justify-content: center;
        margin-bottom: 10px;
    }
    
    .container {
        min-height: calc(100vh - 120px);
    }
    
    .stats-grid {
        gap: 10px;
    }
    
    .stat-card {
        padding: 12px;
    }
    
    .section {
        padding: 15px;
    }
    
    .page-header {
        margin-bottom: 20px;
    }
    
    .control-buttons .btn {
        min-width: 100px;
        font-size: 11px;
    }
    
    .device-card {
        padding: 15px;
    }
    
    .modal-content {
        width: 98%;
        margin: 5% auto;
    }
    
    .modal-body {
        padding: 20px 15px;
    }
}

/* 横屏手机优化 */
@media (max-height: 500px) and (orientation: landscape) {
    .login-container {
        padding: 20px;
        justify-content: flex-start;
    }
    
    .login-header {
        margin-bottom: 20px;
    }
    
    .login-form {
        padding: 20px;
    }
    
    .camera-view {
        min-height: 250px;
    }
}

/* 高分辨率屏幕优化 */
@media (min-width: 1400px) {
    .container {
        max-width: 1400px;
        margin: 0 auto;
    }
    
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .device-grid {
        grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    }
    
    .control-panel {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* 打印样式 */
@media print {
    .header, .sidebar, .page-actions, .btn {
        display: none !important;
    }
    
    .container {
        display: block;
    }
    
    .main-content {
        padding: 0;
    }
    
    .page-content {
        display: block !important;
    }
    
    .stat-card, .device-card, .section {
        box-shadow: none;
        border: 1px solid #ccc;
    }
}

/* 深色模式支持 */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-primary: #1a1a1a;
        --bg-secondary: #2d2d2d;
        --text-primary: #ffffff;
        --text-secondary: #cccccc;
        --border-color: #404040;
    }
    
    /* 可以在未来版本中实现完整的深色模式 */
}

/* 减少动画偏好 */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* 高对比度模式 */
@media (prefers-contrast: high) {
    .btn-primary {
        background: #0000ff;
        color: #ffff00;
    }
    
    .stat-card {
        border: 2px solid #000000;
    }
}