/**
 * 豆芽成长记录系统 - 响应式布局优化
 * 确保移动端和桌面端完美适配
 */

/* 基础重置和通用样式 */
* {
    box-sizing: border-box;
}

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}

/* 可点击元素的最小尺寸（符合无障碍标准） */
a, button, input, select, textarea {
    min-height: 44px;
    min-width: 44px;
}

/* 移动端优先的基础样式 */
@media (max-width: 767.98px) {
    /* 容器和布局 */
    .container {
        padding-left: 15px;
        padding-right: 15px;
    }
    
    /* 导航栏 */
    .top-nav {
        padding: 10px 0;
    }
    
    .top-nav .container {
        padding-left: 15px;
        padding-right: 15px;
    }
    
    .top-nav .nav-link {
        padding: 5px 10px;
        font-size: 0.9rem;
    }
    
    /* 标题 */
    h1 {
        font-size: 1.8rem;
    }
    
    h2 {
        font-size: 1.5rem;
    }
    
    h3 {
        font-size: 1.3rem;
    }
    
    /* 卡片和面板 */
    .card, .baby-profile-card, .timeline-card, .gallery-card, 
    .stats-card, .family-management, .media-types, .date-filter {
        padding: 20px;
        margin-bottom: 20px;
    }
    
    /* 表单 */
    .form-control, .form-select {
        padding: 12px 15px;
        margin-bottom: 15px;
    }
    
    /* 按钮 */
    .btn, .btn-primary, .btn-secondary, .btn-login, .btn-register {
        padding: 12px 20px;
        font-size: 0.9rem;
    }
    
    /* 宝宝档案页面 */
    .baby-header {
        flex-direction: column;
        text-align: center;
        padding: 20px;
    }
    
    .baby-avatar {
        margin-right: 0;
        margin-bottom: 15px;
        width: 60px;
        height: 60px;
    }
    
    .baby-details {
        flex-direction: column;
        gap: 10px;
    }
    
    .detail-item {
        width: 100%;
        justify-content: center;
    }
    
    /* 统计卡片 */
    .stats-overview {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }
    
    /* 时间线 */
    .timeline-container {
        padding-left: 25px;
    }
    
    .timeline-item {
        margin-bottom: 30px;
    }
    
    .timeline-dot {
        left: -20px;
        width: 25px;
        height: 25px;
    }
    
    .timeline-line {
        left: -7px;
        width: 2px;
    }
    
    /* 瀑布流 */
    .masonry-container {
        column-count: 2;
        column-gap: 15px;
    }
    
    .masonry-item {
        margin-bottom: 15px;
    }
    
    .media-image {
        border-radius: 10px;
    }
    
    /* 照片查看器 */
    .photo-viewer-prev, .photo-viewer-next {
        width: 40px;
        height: 40px;
    }
    
    .photo-viewer-close {
        width: 40px;
        height: 40px;
    }
    
    .photo-viewer-info {
        bottom: 10px;
        max-width: 90%;
        padding: 8px 15px;
        font-size: 0.9rem;
    }
    
    /* 家庭成员卡片 */
    .member-header {
        flex-direction: column;
        text-align: center;
    }
    
    .member-avatar {
        margin-right: 0;
        margin-bottom: 15px;
        width: 50px;
        height: 50px;
    }
    
    .member-actions {
        justify-content: center;
        margin-top: 15px;
    }
    
    /* 图表 */
    .chart-container {
        height: 250px;
    }
    
    /* 里程碑卡片 */
    .milestone-grid {
        grid-template-columns: 1fr;
    }
    
    /* 浮动按钮 */
    .fab {
        width: 56px;
        height: 56px;
        font-size: 1.2rem;
    }
    
    .fab-option a {
        padding: 8px 15px;
        font-size: 0.9rem;
    }
    
    /* 模态框 */
    .modal-content {
        margin: 10px;
        border-radius: 15px;
    }
    
    .modal-header, .modal-body, .modal-footer {
        padding: 15px;
    }
    
    /* 表单浮动标签 */
    .form-floating label {
        padding: 1rem 0.75rem;
    }
    
    /* 加载更多按钮 */
    .load-more-btn {
        padding: 10px 20px;
        font-size: 0.9rem;
    }
}

/* 平板设备 */
@media (min-width: 768px) and (max-width: 991.98px) {
    /* 宝宝档案页面 */
    .baby-header {
        padding: 25px;
    }
    
    .baby-avatar {
        width: 70px;
        height: 70px;
    }
    
    /* 统计卡片 */
    .stats-overview {
        grid-template-columns: repeat(4, 1fr);
    }
    
    /* 瀑布流 */
    .masonry-container {
        column-count: 3;
    }
    
    /* 图表 */
    .chart-container {
        height: 280px;
    }
    
    /* 里程碑卡片 */
    .milestone-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* 大屏幕设备 */
@media (min-width: 992px) {
    /* 宝宝档案页面 */
    .baby-header {
        padding: 30px;
    }
    
    .baby-avatar {
        width: 80px;
        height: 80px;
    }
    
    /* 瀑布流 */
    .masonry-container {
        column-count: 4;
    }
    
    /* 图表 */
    .chart-container {
        height: 300px;
    }
    
    /* 里程碑卡片 */
    .milestone-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* 超大屏幕设备 */
@media (min-width: 1200px) {
    .container {
        max-width: 1140px;
    }
    
    /* 瀑布流 */
    .masonry-container {
        column-count: 5;
    }
    
    /* 里程碑卡片 */
    .milestone-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* 打印样式 */
@media print {
    .top-nav, .fab-container, .btn, .load-more, .modal {
        display: none !important;
    }
    
    body {
        background: white !important;
        color: black !important;
    }
    
    .card, .baby-profile-card, .timeline-card, .gallery-card {
        box-shadow: none !important;
        border: 1px solid #ddd !important;
        page-break-inside: avoid;
    }
    
    .timeline-item {
        page-break-inside: avoid;
    }
    
    .masonry-item {
        page-break-inside: avoid;
    }
}

/* 高对比度模式 */
@media (prefers-contrast: high) {
    :root {
        --primary-color: #0000ff;
        --secondary-color: #e6f0ff;
        --text-color: #000000;
        --bg-color: #ffffff;
        --card-shadow: 0 2px 4px rgba(0,0,0,0.5);
    }
    
    .card, .baby-profile-card, .timeline-card, .gallery-card {
        border: 2px solid #000000;
    }
    
    .btn, .btn-primary {
        border: 2px solid #000000;
    }
}

/* 减少动画偏好 */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* 暗色模式 */
@media (prefers-color-scheme: dark) {
    :root {
        --primary-color: #6a8caf;
        --secondary-color: #2c3e50;
        --text-color: #ffffff;
        --bg-color: #1a1a1a;
        --card-shadow: 0 8px 16px rgba(0,0,0,0.3);
    }
    
    body {
        background: linear-gradient(135deg, #1a1a1a 0%, #2c3e50 100%);
        color: var(--text-color);
    }
    
    .card, .baby-profile-card, .timeline-card, .gallery-card {
        background: #2c3e50;
    }
    
    .form-control, .form-select {
        background: #2c3e50;
        color: white;
        border-color: #3a4d63;
    }
    
    .form-control:focus, .form-select:focus {
        background: #2c3e50;
        border-color: var(--primary-color);
        color: white;
    }
    
    .modal-content {
        background: #2c3e50;
        color: white;
    }
}

/* 横屏模式优化 */
@media screen and (orientation: landscape) and (max-height: 500px) {
    .top-nav {
        padding: 5px 0;
    }
    
    .baby-header {
        padding: 15px;
    }
    
    .baby-avatar {
        width: 50px;
        height: 50px;
    }
    
    .card, .baby-profile-card, .timeline-card, .gallery-card {
        padding: 15px;
        margin-bottom: 15px;
    }
    
    .chart-container {
        height: 200px;
    }
}

/* 触摸设备优化 */
@media (hover: none) and (pointer: coarse) {
    .btn, .btn-primary, .btn-secondary {
        min-height: 48px;
        min-width: 48px;
        padding: 12px 20px;
    }
    
    .nav-link {
        padding: 10px 15px;
    }
    
    .timeline-item, .member-card, .family-card {
        margin-bottom: 20px;
    }
    
    /* 增大点击区域 */
    .btn-action {
        width: 44px;
        height: 44px;
    }
    
    .timeline-dot {
        width: 35px;
        height: 35px;
    }
    
    .fab {
        width: 64px;
        height: 64px;
    }
}

/* 小屏设备特殊处理 */
@media screen and (max-width: 320px) {
    .container {
        padding-left: 10px;
        padding-right: 10px;
    }
    
    .stats-overview {
        grid-template-columns: 1fr;
    }
    
    .masonry-container {
        column-count: 1;
    }
    
    .detail-item {
        padding: 8px 15px;
        font-size: 0.9rem;
    }
    
    .timeline-content {
        padding: 15px;
    }
    
    .media-info {
        padding: 10px;
    }
}