/* /public/css/mailbox.css */

/* 우편함 섹션 전체 컨테이너 */
.mailbox-section {
  background: var(--surface);
  border-radius: var(--border-radius);
  padding: 0;
  margin-top: 24px;
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

/* 우편함 헤더 */
.mailbox-header {
  padding: 20px 24px;
  background: linear-gradient(135deg, var(--surface-light), var(--surface));
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.mailbox-title {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
}

.mailbox-title i {
  font-size: 24px;
  color: var(--primary-color);
}

.mailbox-title h3 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
}

.unread-badge {
  background: var(--error);
  color: white;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  min-width: 24px;
  text-align: center;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
}

.mailbox-actions {
  display: flex;
  gap: 8px;
}

.btn-icon {
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-secondary);
  width: 40px;
  height: 40px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  font-size: 16px;
}

.btn-icon:hover {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

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

/* 필터 버튼 */
.mailbox-filters {
  display: flex;
  gap: 8px;
  padding: 16px 24px;
  background: var(--background);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.filter-btn {
  padding: 10px 18px;
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-btn i {
  font-size: 14px;
}

.filter-btn:hover {
  background: var(--surface-light);
  color: var(--text-primary);
  transform: translateY(-1px);
}

.filter-btn.active {
  background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
  border-color: var(--primary-color);
  color: white;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

/* 메일 리스트 */
.mail-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  max-height: 600px;
  overflow-y: auto;
  padding: 0;
}

/* 스크롤바 스타일링 */
.mail-list::-webkit-scrollbar {
  width: 8px;
}

.mail-list::-webkit-scrollbar-track {
  background: var(--background);
}

.mail-list::-webkit-scrollbar-thumb {
  background: var(--surface-light);
  border-radius: 4px;
}

.mail-list::-webkit-scrollbar-thumb:hover {
  background: var(--primary-color);
}

/* 메일 아이템 */
.mail-item {
  background: var(--surface);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  overflow: hidden;
  transition: var(--transition);
  position: relative;
}

.mail-item:last-child {
  border-bottom: none;
}

.mail-item:hover {
  background: var(--surface-light);
}

.mail-item.unread {
  background: linear-gradient(90deg, rgba(102, 126, 234, 0.15) 0%, var(--surface) 20px);
  border-left: 4px solid var(--primary-color);
}

.mail-item.unread::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--primary-color);
  box-shadow: 0 0 10px var(--primary-color);
}

.mail-item.read {
  opacity: 0.8;
}

/* 메일 헤더 */
.mail-header {
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  cursor: pointer;
  transition: var(--transition);
}

.mail-header:hover {
  background: rgba(255, 255, 255, 0.02);
}

.mail-header-left {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
  min-width: 0; /* 텍스트 오버플로우를 위해 필요 */
}

.mail-icon {
  font-size: 20px;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}

/* 메일 타입별 색상 */
.mail-type-notice .mail-icon { 
  color: var(--warning); 
  filter: drop-shadow(0 0 4px var(--warning));
}
.mail-type-warning .mail-icon { 
  color: var(--error); 
  filter: drop-shadow(0 0 4px var(--error));
}
.mail-type-general .mail-icon { 
  color: var(--primary-color); 
  filter: drop-shadow(0 0 4px var(--primary-color));
}
.mail-type-other .mail-icon { 
  color: var(--text-muted); 
}

.mail-info {
  flex: 1;
  min-width: 0; /* 텍스트 오버플로우를 위해 필요 */
}

.mail-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.mail-title {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.mail-item.unread .mail-title {
  font-weight: 700;
  color: white;
}

.mail-type-badge {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
  flex-shrink: 0;
}

.badge-notice {
  background: rgba(251, 191, 36, 0.2);
  color: var(--warning);
  border: 1px solid var(--warning);
}

.badge-warning {
  background: rgba(248, 113, 113, 0.2);
  color: var(--error);
  border: 1px solid var(--error);
}

.badge-general {
  background: rgba(102, 126, 234, 0.2);
  color: var(--primary-color);
  border: 1px solid var(--primary-color);
}

.badge-other {
  background: rgba(136, 136, 170, 0.2);
  color: var(--text-muted);
  border: 1px solid var(--text-muted);
}

.mail-date {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

.mail-delete-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  width: 36px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  flex-shrink: 0;
  font-size: 14px;
}

.mail-delete-btn:hover {
  background: var(--error);
  color: white;
  transform: scale(1.1);
  box-shadow: var(--shadow-md);
}

.mail-delete-btn:active {
  transform: scale(0.95);
}

/* 메일 내용 */
.mail-content {
  padding: 0 24px 16px 64px; /* 왼쪽 패딩은 아이콘과 정렬 */
  background: var(--background);
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  animation: expandContent 0.3s ease-out;
}

@keyframes expandContent {
  from {
    opacity: 0;
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
  }
  to {
    opacity: 1;
    max-height: 500px;
    padding-top: 16px;
    padding-bottom: 16px;
  }
}

.mail-body {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-secondary);
  white-space: pre-wrap; /* 줄바꿈 유지 */
  word-wrap: break-word;
  margin-bottom: 16px;
  padding: 16px;
  background: var(--surface);
  border-radius: 8px;
  border-left: 3px solid var(--primary-color);
}

.mail-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
}

.mail-expiry {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 8px 12px;
  background: var(--surface);
  border-radius: 6px;
}

.mail-expiry i {
  font-size: 11px;
}

/* 빈 우편함 */
.empty-mailbox {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  text-align: center;
}

.empty-icon {
  font-size: 72px;
  color: var(--surface-light);
  margin-bottom: 24px;
  opacity: 0.5;
}

.empty-text {
  font-size: 16px;
  color: var(--text-muted);
  margin: 0;
}

/* 에러 메시지 */
.error-message {
  text-align: center;
  color: var(--error);
  padding: 40px;
  font-size: 16px;
}

/* 슬라이드 아웃 애니메이션 */
@keyframes slideOut {
  from {
    opacity: 1;
    transform: translateX(0);
    max-height: 200px;
  }
  to {
    opacity: 0;
    transform: translateX(100%);
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    margin-top: 0;
    margin-bottom: 0;
  }
}

/* 상단 메일 버튼 알림 */
.mail-btn {
  position: relative;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 20px;
  padding: 8px;
  margin-right: 12px;
  transition: var(--transition);
  border-radius: 8px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mail-btn:hover {
  background: var(--surface-light);
  color: var(--primary-color);
}

.notification-dot {
  position: absolute;
  top: 4px;
  right: 4px;
  background: var(--error);
  color: white;
  border-radius: 10px;
  min-width: 18px;
  height: 18px;
  font-size: 10px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  border: 2px solid var(--background);
  animation: bounce 2s infinite;
}

@keyframes bounce {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
}

.notification-dot.hidden {
  display: none;
}

/* 모바일 대응 */
@media (max-width: 768px) {
  .mailbox-header {
    padding: 16px;
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .mailbox-title {
    font-size: 18px;
  }

  .mailbox-title i {
    font-size: 20px;
  }

  .mailbox-title h3 {
    font-size: 18px;
  }

  .mailbox-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .mailbox-filters {
    padding: 12px;
    gap: 6px;
  }

  .filter-btn {
    font-size: 13px;
    padding: 8px 14px;
  }

  .mail-list {
    max-height: 500px;
  }

  .mail-header {
    padding: 12px 16px;
  }

  .mail-header-left {
    gap: 12px;
  }

  .mail-icon {
    font-size: 18px;
    width: 20px;
  }

  .mail-title {
    font-size: 14px;
  }

  .mail-date {
    font-size: 11px;
  }

  .mail-type-badge {
    font-size: 10px;
    padding: 2px 6px;
  }

  .mail-content {
    padding: 0 16px 12px 48px;
  }

  .mail-body {
    font-size: 13px;
    padding: 12px;
  }

  .empty-mailbox {
    padding: 60px 20px;
  }

  .empty-icon {
    font-size: 60px;
  }

  .empty-text {
    font-size: 14px;
  }
}
