/* ============================================================
 * 曼恩资产交易数智管理系统 - 响应式样式 (Responsive)
 * 断点: 768px / 1024px / 1440px
 * 移动端侧边栏收起、表格横向滚动、栅格响应式
 * ============================================================ */

/* ==========================================================
 * 超大屏 (≥1440px)
 * ========================================================== */
@media (min-width: 1440px) {
  .content-inner {
    max-width: 1400px;
  }

  /* 更大屏的栅格拓展 */
  .col-xxl-1  { flex: 0 0 8.333333%; max-width: 8.333333%; }
  .col-xxl-2  { flex: 0 0 16.666667%; max-width: 16.666667%; }
  .col-xxl-3  { flex: 0 0 25%; max-width: 25%; }
  .col-xxl-4  { flex: 0 0 33.333333%; max-width: 33.333333%; }
  .col-xxl-6  { flex: 0 0 50%; max-width: 50%; }
  .col-xxl-8  { flex: 0 0 66.666667%; max-width: 66.666667%; }
  .col-xxl-9  { flex: 0 0 75%; max-width: 75%; }
  .col-xxl-12 { flex: 0 0 100%; max-width: 100%; }

  .grid-4 { grid-template-columns: repeat(4, 1fr); }
  .kanban-board { grid-template-columns: repeat(4, 1fr); }

  .stat-card .stat-value {
    font-size: var(--font-size-4xl);
  }
}

/* ==========================================================
 * 大屏 (1024px - 1439px)
 * 默认样式即适配此区间
 * ========================================================== */
@media (max-width: 1439px) {
  .content-inner {
    max-width: 100%;
  }
}

/* ==========================================================
 * 中等屏 (768px - 1023px)
 * 侧边栏默认收起、表格开始需要横向滚动
 * ========================================================== */
@media (max-width: 1024px) {
  /* 侧边栏默认收起 */
  .sidebar {
    width: var(--sidebar-collapsed);
    min-width: var(--sidebar-collapsed);
  }

  .sidebar .sidebar-brand,
  .sidebar .nav-section-title,
  .sidebar .nav-item .nav-text,
  .sidebar .user-meta {
    display: none;
  }

  .sidebar .sidebar-header {
    justify-content: center;
    padding: 0;
  }

  .sidebar .nav-item {
    justify-content: center;
    padding: 10px;
  }

  .sidebar .sidebar-footer {
    display: flex;
    justify-content: center;
  }

  /* 展开状态覆盖 */
  .sidebar.expanded {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: var(--z-sidebar);
    box-shadow: var(--shadow-2xl);
  }

  .sidebar.expanded .sidebar-brand,
  .sidebar.expanded .nav-section-title,
  .sidebar.expanded .nav-item .nav-text,
  .sidebar.expanded .user-meta {
    display: block;
  }

  .sidebar.expanded .sidebar-header {
    justify-content: flex-start;
    padding: 0 var(--spacing-md);
  }

  .sidebar.expanded .nav-item {
    justify-content: flex-start;
    padding: 10px var(--spacing-md);
  }

  .sidebar.expanded .sidebar-footer {
    display: block;
  }

  /* 移动端遮罩 */
  .sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-overlay);
    z-index: calc(var(--z-sidebar) - 1);
  }

  .sidebar-overlay.active {
    display: block;
  }

  /* 栅格调整 */
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }

  .kanban-board {
    grid-template-columns: repeat(2, 1fr);
  }

  /* 12栅格 - 中等屏 */
  .col-md-1  { flex: 0 0 8.333333%; max-width: 8.333333%; }
  .col-md-2  { flex: 0 0 16.666667%; max-width: 16.666667%; }
  .col-md-3  { flex: 0 0 25%; max-width: 25%; }
  .col-md-4  { flex: 0 0 33.333333%; max-width: 33.333333%; }
  .col-md-6  { flex: 0 0 50%; max-width: 50%; }
  .col-md-8  { flex: 0 0 66.666667%; max-width: 66.666667%; }
  .col-md-12 { flex: 0 0 100%; max-width: 100%; }

  /* 表格横向滚动 */
  .table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* 模态框 */
  .modal {
    width: 95%;
    max-width: 95%;
  }

  /* 内容区域 */
  .content-area {
    padding: var(--spacing-md);
  }

  /* 新闻/资讯 */
  .newsletter-item {
    flex-direction: column;
  }

  .newsletter-thumb {
    width: 100%;
    height: 160px;
  }

  /* 客户卡片信息 */
  .customer-info {
    grid-template-columns: 1fr;
  }

  /* 参数行 */
  .param-row {
    grid-template-columns: 1fr 100px;
  }
}

/* ==========================================================
 * 小屏 / 平板竖屏 (≤768px)
 * 移动端全适配
 * ========================================================== */
@media (max-width: 768px) {
  /* 侧边栏完全隐藏（移动端） */
  .sidebar {
    width: 0;
    min-width: 0;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: var(--z-sidebar);
    overflow: hidden;
  }

  .sidebar.expanded {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    box-shadow: var(--shadow-2xl);
  }

  .sidebar.expanded .sidebar-brand,
  .sidebar.expanded .nav-section-title,
  .sidebar.expanded .nav-item .nav-text,
  .sidebar.expanded .user-meta {
    display: block;
  }

  .sidebar.expanded .sidebar-header {
    justify-content: flex-start;
    padding: 0 var(--spacing-md);
  }

  .sidebar.expanded .nav-item {
    justify-content: flex-start;
    padding: 10px var(--spacing-md);
  }

  .sidebar.expanded .sidebar-footer {
    display: block;
  }

  /* 遮罩 */
  .sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-overlay);
    z-index: calc(var(--z-sidebar) - 1);
  }

  .sidebar-overlay.active {
    display: block;
  }

  /* 顶栏 */
  .topbar {
    padding: 0 var(--spacing-md);
    height: 48px;
    min-height: 48px;
  }

  .page-title {
    font-size: var(--font-size-lg);
  }

  /* 顶栏操作按钮 */
  .topbar-actions {
    gap: var(--spacing-xs);
  }

  /* 内容区域 */
  .content-area {
    padding: var(--spacing-md);
  }

  /* 页面头部 */
  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .page-header-right {
    width: 100%;
    justify-content: flex-start;
  }

  /* 栅格 - 全部单列 */
  .grid-2,
  .grid-3,
  .grid-4,
  .grid-auto {
    grid-template-columns: 1fr;
  }

  /* 看板 - 单列 */
  .kanban-board {
    grid-template-columns: 1fr;
  }

  .kanban-column {
    min-height: auto;
  }

  /* 12栅格 - 小屏全部100% */
  .col-sm-1,
  .col-sm-2,
  .col-sm-3,
  .col-sm-4,
  .col-sm-5,
  .col-sm-6,
  .col-sm-7,
  .col-sm-8,
  .col-sm-9,
  .col-sm-10,
  .col-sm-11,
  .col-sm-12 {
    flex: 0 0 100%;
    max-width: 100%;
  }

  .col-sm-6 {
    flex: 0 0 50%;
    max-width: 50%;
  }

  /* 偏移重置 */
  [class*="col-offset-"] {
    margin-left: 0;
  }

  /* 表格横向滚动 */
  .table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 calc(-1 * var(--spacing-md));
    padding: 0 var(--spacing-md);
  }

  .table th,
  .table td,
  .data-table th,
  .data-table td {
    padding: 8px 12px;
    font-size: var(--font-size-sm);
  }

  /* 模态框全屏 */
  .modal {
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
  }

  .modal-header {
    padding: 16px;
  }

  .modal-body {
    padding: 16px;
  }

  .modal-footer {
    padding: 12px 16px;
  }

  /* 表单行 - 单列 */
  .form-row {
    grid-template-columns: 1fr;
  }

  .form-row.cols-3,
  .form-row.cols-4 {
    grid-template-columns: 1fr;
  }

  /* 按钮 */
  .btn {
    padding: 8px 16px;
    font-size: var(--font-size-sm);
  }

  .btn-lg {
    padding: 10px 20px;
    font-size: var(--font-size-base);
  }

  /* 表单全宽 */
  .form-inline {
    flex-direction: column;
    align-items: stretch;
  }

  /* 卡片 */
  .card {
    padding: var(--spacing-md);
    margin-bottom: var(--spacing-md);
  }

  .card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--spacing-sm);
  }

  /* 统计卡片 */
  .stat-card .stat-value {
    font-size: var(--font-size-3xl);
  }

  /* 通知下拉 */
  .notification-dropdown {
    position: fixed;
    top: 48px;
    left: 0;
    right: 0;
    width: 100%;
    max-height: calc(100vh - 48px);
    border-radius: 0;
  }

  /* 搜索框 */
  .search-box {
    width: 100%;
  }

  .search-box .form-input {
    width: 100%;
  }

  /* 审批流程 */
  .approval-flow {
    flex-wrap: wrap;
    gap: var(--spacing-xs);
  }

  .approval-arrow {
    display: none;
  }

  /* 标签页 */
  .tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .tab-item {
    padding: 8px 14px;
    font-size: var(--font-size-sm);
  }

  /* 新闻/资讯 */
  .newsletter-thumb {
    width: 100%;
    height: 140px;
  }

  .newsletter-meta {
    flex-wrap: wrap;
    gap: var(--spacing-sm);
  }

  /* 客户卡片 */
  .customer-card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--spacing-xs);
  }

  .customer-info {
    grid-template-columns: 1fr;
  }

  /* 参数行 */
  .param-row {
    grid-template-columns: 1fr 80px;
  }

  /* 模型面板 */
  .model-panel-header {
    padding: var(--spacing-sm) var(--spacing-md);
  }

  .model-panel-body {
    padding: var(--spacing-md);
  }

  /* 3D建模 */
  .modeling-viewport {
    height: 300px;
  }

  /* 热力图 */
  .heatmap-container {
    height: 300px;
  }

  /* 图表容器 */
  .chart-container {
    min-height: 250px;
  }

  /* Toast通知 */
  .toast {
    left: var(--spacing-md);
    right: var(--spacing-md);
    max-width: none;
    transform: translateY(calc(-100% - 20px));
  }

  .toast.show {
    transform: translateY(0);
  }

  /* 页面标题 */
  h1 { font-size: var(--font-size-2xl); }
  h2 { font-size: var(--font-size-xl); }
  h3 { font-size: var(--font-size-lg); }
}

/* ==========================================================
 * 极小屏 (≤480px)
 * ========================================================== */
@media (max-width: 480px) {
  .topbar {
    padding: 0 var(--spacing-sm);
  }

  .page-title {
    font-size: var(--font-size-md);
  }

  .content-area {
    padding: var(--spacing-sm);
  }

  .card {
    padding: var(--spacing-sm);
    border-radius: var(--radius-md);
  }

  .modal-header,
  .modal-body,
  .modal-footer {
    padding: 12px;
  }

  .btn-group {
    flex-direction: column;
  }

  .btn-group .btn {
    border-radius: var(--radius-md) !important;
    margin-left: 0 !important;
  }

  .stat-card .stat-value {
    font-size: var(--font-size-2xl);
  }

  .col-sm-6 {
    flex: 0 0 100%;
    max-width: 100%;
  }
}

/* ==========================================================
 * 横屏移动端适配
 * ========================================================== */
@media (max-width: 1024px) and (orientation: landscape) {
  .sidebar {
    width: var(--sidebar-collapsed);
    min-width: var(--sidebar-collapsed);
  }

  .sidebar.expanded {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
  }

  .content-area {
    padding: var(--spacing-md);
  }

  .modal {
    max-height: 90vh;
  }
}

/* ==========================================================
 * 高分辨率 / Retina 屏幕
 * ========================================================== */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  /* 可在此处添加高清图片适配 */
}

/* ==========================================================
 * 打印样式
 * ========================================================== */
@media print {
  .sidebar,
  .topbar,
  .no-print {
    display: none !important;
  }

  .app-layout {
    display: block;
  }

  .main-content {
    margin-left: 0 !important;
    overflow: visible;
  }

  .content-area {
    overflow: visible;
    padding: 0;
  }

  .card {
    box-shadow: none;
    border: 1px solid #ccc;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  body {
    background: #ffffff;
    color: #000000;
  }
}