/* 
 * 航通社全站统一样式系统
 * 基于 Chakra UI 设计语言重新设计
 */

/* ===== 基础变量定义 ===== */
:root {
  /* 主色调 - Chakra UI 蓝色系 */
  --primary-blue: #3182CE;
  --primary-blue-light: #4299E1;
  --primary-blue-dark: #2C5282;
  --primary-blue-hover: #2B6CB0;
  
  /* 背景色系 - Chakra UI 灰色系 */
  --bg-primary: #F7FAFC;
  --bg-secondary: #EDF2F7;
  --bg-tertiary: #E2E8F0;
  --bg-white: #FFFFFF;
  --bg-hover: #EDF2F7;
  --bg-active: #E2E8F0;
  
  /* 文字色系 - Chakra UI 灰色系 */
  --text-primary: #1A202C;
  --text-secondary: #718096;
  --text-muted: #A0AEC0;
  --text-white: #FFFFFF;
  
  /* 边框和分割线 - Chakra UI 灰色系 */
  --border-light: #E2E8F0;
  --border-medium: #CBD5E0;
  --border-dark: #A0AEC0;
  
  /* 阴影系统 - Chakra UI 标准 */
  --shadow-xs: 0 0 0 1px rgba(0, 0, 0, 0.05);
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  
  /* 圆角系统 - Chakra UI 标准 */
  --radius-none: 0;
  --radius-sm: 0.125rem;    /* 2px */
  --radius-base: 0.25rem;   /* 4px */
  --radius-md: 0.375rem;    /* 6px */
  --radius-lg: 0.5rem;      /* 8px */
  --radius-xl: 0.75rem;     /* 12px */
  --radius-2xl: 1rem;       /* 16px */
  --radius-full: 9999px;
  
  /* 间距系统 - Chakra UI 4px 基础单位 */
  --space-1: 0.25rem;   /* 4px */
  --space-2: 0.5rem;    /* 8px */
  --space-3: 0.75rem;   /* 12px */
  --space-4: 1rem;      /* 16px */
  --space-5: 1.25rem;   /* 20px */
  --space-6: 1.5rem;    /* 24px */
  --space-8: 2rem;      /* 32px */
  --space-10: 2.5rem;   /* 40px */
  --space-12: 3rem;     /* 48px */
  
  /* 字体系统 - Chakra UI 标准 */
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
  --font-size-xs: 0.75rem;      /* 12px */
  --font-size-sm: 0.875rem;     /* 14px */
  --font-size-md: 1rem;         /* 16px */
  --font-size-lg: 1.125rem;     /* 18px */
  --font-size-xl: 1.25rem;      /* 20px */
  --font-size-2xl: 1.5rem;      /* 24px */
  
  /* 行高 - Chakra UI 标准 */
  --line-height-normal: 1.5;
  --line-height-short: 1.375;
  --line-height-tall: 1.625;
  
  /* 字重 */
  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;
  
  /* 动画时长 - Chakra UI 标准 */
  --duration-ultra-fast: 50ms;
  --duration-faster: 100ms;
  --duration-fast: 150ms;
  --duration-normal: 200ms;
  --duration-slow: 300ms;
  --duration-slower: 400ms;
  --duration-ultra-slow: 500ms;
}

/* ===== 基础重置和全局样式 ===== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  font-size: var(--font-size-md);
  line-height: var(--line-height-normal);
  color: var(--text-primary);
  background-color: var(--bg-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ===== 通用组件样式 ===== */

/* 统一的按钮样式 - Chakra UI 风格 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-2) var(--space-4);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-medium);
  line-height: var(--line-height-short);
  text-decoration: none;
  cursor: pointer;
  transition: all var(--duration-normal) ease;
  user-select: none;
  white-space: nowrap;
}

.btn:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(49, 130, 206, 0.6);
}

.btn-primary {
  background-color: var(--primary-blue);
  color: var(--text-white);
  border-color: var(--primary-blue);
}

.btn-primary:hover {
  background-color: var(--primary-blue-hover);
  border-color: var(--primary-blue-hover);
}

.btn-primary:active {
  background-color: var(--primary-blue-dark);
  border-color: var(--primary-blue-dark);
}

.btn-secondary {
  background-color: var(--bg-white);
  color: var(--text-primary);
  border-color: var(--border-medium);
}

.btn-secondary:hover {
  background-color: var(--bg-hover);
}

/* 统一的卡片样式 - Chakra UI 风格 */
.card {
  background-color: var(--bg-white);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-header {
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--border-light);
  background-color: var(--bg-secondary);
}

.card-body {
  padding: var(--space-6);
}

/* ===== 图片库专用样式 ===== */

/* 主容器 */
.gallery-container {
  display: flex;
  min-height: 100vh;
  background-color: var(--bg-primary);
}

/* 侧边栏 */
.gallery-sidebar {
  width: 280px;
  background-color: var(--bg-white);
  border-right: 1px solid var(--border-light);
  box-shadow: var(--shadow-md);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: fixed;
  left: 0;
  top: 0;
}

.gallery-sidebar-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-6);
  border-bottom: 1px solid var(--border-light);
  background-color: var(--bg-white);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 10;
}

.sidebar-logo-image {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  object-fit: cover;
  flex-shrink: 0;
  transition: transform var(--duration-fast) ease;
}

.sidebar-logo-image:hover {
  transform: scale(1.05);
}

.gallery-sidebar-title {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
  text-decoration: none;
  transition: color var(--duration-fast) ease;
}

.gallery-sidebar-title:hover {
  color: var(--primary-blue);
}

.gallery-sidebar-body {
  padding: var(--space-4);
  overflow-y: auto;
  flex: 1;
}

/* 年份月份选择器 - Chakra UI Accordion 风格 */
.date-selector {
  margin-bottom: var(--space-6);
}

/* 原图开关 - Chakra UI Switch 风格 */
.original-image-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-4);
  background-color: var(--bg-secondary);
  border-radius: var(--radius-md);
}

.toggle-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  cursor: pointer;
  user-select: none;
}

.toggle-text {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--text-primary);
}

.toggle-switch {
  position: relative;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.toggle-switch input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
  z-index: 2;
}

.toggle-slider {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--border-medium);
  border-radius: var(--radius-full);
  transition: background-color var(--duration-normal) ease;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  height: 20px;
  width: 20px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  border-radius: 50%;
  transition: transform var(--duration-normal) ease;
  box-shadow: var(--shadow-sm);
}

.toggle-switch input[type="checkbox"]:checked + .toggle-slider {
  background-color: var(--primary-blue);
}

.toggle-switch input[type="checkbox"]:checked + .toggle-slider::before {
  transform: translateX(20px);
}

.toggle-switch input[type="checkbox"]:focus-visible + .toggle-slider {
  outline: 2px solid var(--primary-blue);
  outline-offset: 2px;
}

.toggle-switch input[type="checkbox"]:disabled + .toggle-slider {
  opacity: 0.4;
  cursor: not-allowed;
}

.date-selector-label {
  display: block;
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  color: var(--text-secondary);
  margin-bottom: var(--space-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0 var(--space-2);
}

/* 年份区域 - 完全复用日期条目样式 */
.year-section {
  margin-bottom: var(--space-4);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  background-color: var(--bg-white);
  overflow: hidden;
}

/* 年份标题 - 与日期条目完全一致 */
.year-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  padding: 0 var(--space-6);
  background-color: var(--bg-white);
  cursor: pointer;
  transition: background-color var(--duration-fast) ease;
  user-select: none;
}

.year-header:hover {
  background-color: var(--bg-hover);
}

.year-header:active {
  background-color: var(--bg-active);
}

.year-header.expanded {
  background-color: var(--bg-hover);
  border-bottom: 1px solid var(--border-light);
}

.year-title {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
  line-height: var(--line-height-short);
}

.year-icon {
  width: 24px;
  height: 24px;
  color: var(--text-secondary);
  transition: transform var(--duration-normal) ease;
  flex-shrink: 0;
}

.year-icon.collapsed {
  transform: rotate(-90deg);
}

.year-icon.expanded {
  transform: rotate(0deg);
}

/* 月份网格 - 与照片网格一致的展开/折叠效果 */
.month-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-2);
  padding: 0;
  max-height: 0;
  overflow: hidden;
  transition: max-height var(--duration-slow) ease;
}

.month-grid.expanded {
  max-height: 300px;
  padding: var(--space-4);
}

/* 月份按钮 - Chakra UI Button 风格 */
.month-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 32px;
  padding: 0;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  background-color: var(--bg-white);
  color: var(--text-primary);
  text-decoration: none;
  text-align: center;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  line-height: var(--line-height-short);
  transition: all var(--duration-fast) ease;
  cursor: pointer;
}

.month-btn:hover {
  background-color: var(--bg-hover);
  border-color: var(--border-medium);
}

.month-btn:active {
  background-color: var(--bg-active);
}

.month-btn.active {
  background-color: var(--primary-blue);
  color: var(--text-white);
  border-color: var(--primary-blue);
}

.month-btn.active:hover {
  background-color: var(--primary-blue-hover);
  border-color: var(--primary-blue-hover);
}

.month-btn.disabled {
  background-color: var(--bg-secondary);
  color: var(--text-muted);
  border-color: var(--border-light);
  cursor: not-allowed;
  pointer-events: none;
}

/* 主内容区 */
.gallery-main {
  flex: 1;
  margin-left: 280px;
  padding: var(--space-8);
  overflow-y: auto;
  height: 100vh;
}

/* 日期条目 - Chakra UI Accordion 风格 */
.date-item {
  margin-bottom: var(--space-4);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  background-color: var(--bg-white);
  overflow: hidden;
}

.date-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  padding: 0 var(--space-6);
  background-color: var(--bg-white);
  cursor: pointer;
  transition: background-color var(--duration-fast) ease;
  user-select: none;
}

.date-header:hover {
  background-color: var(--bg-hover);
}

.date-header:active {
  background-color: var(--bg-active);
}

.date-header.expanded {
  background-color: var(--bg-hover);
  border-bottom: 1px solid var(--border-light);
}

.date-title {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
  line-height: var(--line-height-short);
}

.date-icon {
  width: 24px;
  height: 24px;
  color: var(--text-secondary);
  transition: transform var(--duration-normal) ease;
  flex-shrink: 0;
}

.date-icon.collapsed {
  transform: rotate(-90deg);
}

.date-icon.expanded {
  transform: rotate(0deg);
}

/* 照片网格 */
.photos-grid {
  max-height: 0;
  overflow: hidden;
  transition: max-height var(--duration-slow) ease;
  background-color: var(--bg-white);
}

.photos-grid.expanded {
  max-height: 8000px;
}

.photos-container {
  padding: var(--space-6);
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: var(--space-4);
}

.photo-item {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: all var(--duration-normal) ease;
  cursor: pointer;
}

.photo-item:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.photo-item img {
  width: 100%;
  height: 150px;
  object-fit: cover;
  display: block;
}

.empty-state {
  padding: var(--space-8);
  text-align: center;
  color: var(--text-muted);
  font-size: var(--font-size-sm);
  font-style: italic;
}

/* ===== 响应式设计 ===== */

/* 移动端适配 */
@media (max-width: 768px) {
  .gallery-container {
    flex-direction: column;
  }
  
  /* 隐藏桌面端侧边栏标题 */
  .gallery-sidebar-header {
    display: none;
  }
  
  /* 侧边栏从左侧滑入 */
  .gallery-sidebar {
    position: fixed;
    top: 0;
    left: -100%;
    width: 280px;
    height: 100vh;
    z-index: 1001;
    transition: left var(--duration-normal) ease;
    box-shadow: var(--shadow-xl);
  }
  
  .gallery-sidebar.active {
    left: 0;
  }
  
  .gallery-sidebar-body {
    overflow-y: auto;
    height: calc(100vh - 64px);
  }
  
  .gallery-main {
    width: 100%;
    margin-left: 0;
    padding: var(--space-4);
    padding-top: 72px;
    height: auto;
  }
  
  /* 移动端标题栏 - Chakra UI 风格 */
  .mobile-header {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 999;
    background-color: var(--bg-white);
    border-bottom: 1px solid var(--border-light);
    box-shadow: var(--shadow-sm);
    padding: var(--space-3) var(--space-4);
    height: 64px;
    align-items: center;
    justify-content: space-between;
  }
  
  .mobile-header-logo {
    display: flex;
    align-items: center;
    gap: var(--space-3);
  }
  
  .logo-image {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    object-fit: cover;
  }
  
  .logo-text {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary);
    text-decoration: none;
    transition: color var(--duration-fast) ease;
  }
  
  .logo-text:hover {
    color: var(--primary-blue);
  }
  
  .hamburger-button {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 40px;
    height: 40px;
    background: none;
    border: none;
    cursor: pointer;
    padding: var(--space-2);
    border-radius: var(--radius-md);
    transition: background-color var(--duration-fast) ease;
  }
  
  .hamburger-button:hover {
    background-color: var(--bg-hover);
  }
  
  .hamburger-button:active {
    background-color: var(--bg-active);
  }
  
  .hamburger-line {
    width: 24px;
    height: 2px;
    background-color: var(--text-primary);
    border-radius: var(--radius-full);
    transition: all var(--duration-normal) ease;
    margin: 3px 0;
  }
  
  .hamburger-button.active .hamburger-line:nth-child(1) {
    transform: translateY(8px) rotate(45deg);
  }
  
  .hamburger-button.active .hamburger-line:nth-child(2) {
    opacity: 0;
  }
  
  .hamburger-button.active .hamburger-line:nth-child(3) {
    transform: translateY(-8px) rotate(-45deg);
  }
  
  /* 移动端遮罩层 */
  .sidebar-overlay {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    opacity: 0;
    transition: opacity var(--duration-normal) ease;
    pointer-events: none;
  }
  
  .sidebar-overlay.active {
    opacity: 1;
    pointer-events: auto;
  }
  
  /* 移动端关闭按钮 */
  .close-button {
    position: fixed;
    top: var(--space-4);
    right: var(--space-4);
    width: 48px;
    height: 48px;
    background-color: var(--bg-white);
    border: none;
    border-radius: var(--radius-full);
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1002;
    opacity: 0;
    pointer-events: none;
    transition: all var(--duration-normal) ease;
    color: var(--text-primary);
  }
  
  .close-button:hover {
    background-color: var(--bg-hover);
    transform: scale(1.05);
  }
  
  .close-button:active {
    background-color: var(--bg-active);
    transform: scale(0.95);
  }
  
  .sidebar-overlay.active .close-button {
    opacity: 1;
    pointer-events: auto;
  }
  
  /* 移动端照片网格调整 */
  .photos-container {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: var(--space-3);
  }
  
  .photo-item img {
    height: 120px;
  }
  
  /* 移动端日期条目 */
  .date-header {
    height: 48px;
    padding: 0 var(--space-4);
  }
  
  .date-title {
    font-size: var(--font-size-md);
  }
  
  .date-icon {
    width: 20px;
    height: 20px;
  }
}

/* 桌面端隐藏移动端元素 */
@media (min-width: 769px) {
  .mobile-header,
  .sidebar-overlay {
    display: none !important;
  }
}

/* 大屏幕优化 */
@media (min-width: 1440px) {
  .gallery-sidebar {
    width: 320px;
  }
  
  .photos-container {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: var(--space-6);
  }
  
  .photo-item img {
    height: 180px;
  }
}

/* ===== 通用图标样式 ===== */
.icon-chevron-down {
  width: 1em;
  height: 1em;
  fill: currentColor;
}

/* ===== 加载状态 - Chakra UI Spinner 风格 ===== */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-8);
  color: var(--text-muted);
  font-size: var(--font-size-sm);
}

.loading::after {
  content: '';
  width: 24px;
  height: 24px;
  border: 3px solid var(--border-light);
  border-top-color: var(--primary-blue);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-left: var(--space-3);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ===== 版权信息 ===== */
.copyright {
  padding: var(--space-6);
  text-align: center;
  color: var(--text-muted);
  font-size: var(--font-size-xs);
  border-top: 1px solid var(--border-light);
  background-color: var(--bg-white);
  margin-top: auto;
}

/* ===== 滚动条样式 - Chakra UI 风格 ===== */
.gallery-sidebar::-webkit-scrollbar,
.gallery-main::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.gallery-sidebar::-webkit-scrollbar-track,
.gallery-main::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

.gallery-sidebar::-webkit-scrollbar-thumb,
.gallery-main::-webkit-scrollbar-thumb {
  background: var(--border-medium);
  border-radius: var(--radius-full);
}

.gallery-sidebar::-webkit-scrollbar-thumb:hover,
.gallery-main::-webkit-scrollbar-thumb:hover {
  background: var(--border-dark);
}

/* ===== 焦点可见性 - Chakra UI 可访问性标准 ===== */
*:focus-visible {
  outline: 2px solid var(--primary-blue);
  outline-offset: 2px;
}

button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--primary-blue);
  outline-offset: 2px;
}

