/* Responsive Design Implementation - Light Theme Integration */

/* Hide mobile-specific elements on desktop by default */
.mobile-header {
  display: none;
}
.drawer-overlay {
  display: none;
}

@media (max-width: 1024px) {
  .dashboard-summary-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .monitor-server-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 480px) {
  .dashboard-summary-grid {
    grid-template-columns: 1fr;
  }
  .monitor-server-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  /* Layout Shell spacing for Mobile Header + 2-line Topbar */
  .layout-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding-top: 136px; /* 56px (header) + ~80px (two-line topbar) */
  }
  
  /* Mobile Header */
  .mobile-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 16px;
    height: 56px;
    background: var(--bg-2);
    border-bottom: 1px solid var(--line-strong);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9997;
  }
  .mobile-header .brand {
    font-size: 20px;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.05em;
  }

  /* Two-line topbar */
  .topbar {
    position: fixed;
    top: 56px;
    left: 0;
    right: 0;
    height: auto;
    padding: 12px 16px !important;
    z-index: 9996;
    background: var(--bg);
    border-bottom: 1px solid var(--line-strong);
    display: flex !important;
    flex-direction: column !important; /* Stack vertically */
    align-items: stretch;
    gap: 12px;
  }

  /* Ticker takes full width on the first line */
  .patch-ticker-wrap {
    margin-right: 0 !important;
    width: 100% !important;
    padding: 0 12px !important;
    height: 36px !important;
    background: var(--bg-2) !important;
    border-radius: 6px;
  }
  .patch-ticker span {
    font-size: 12px !important;
  }

  /* Action Buttons take the second line */
  .topbar-actions {
    display: flex !important;
    flex-direction: row !important;
    align-items: center;
    justify-content: space-between !important; /* Spread items evenly */
    gap: 8px !important;
    width: 100%;
  }
  
  .topbar-actions .ghost-button {
    padding: 6px !important;
  }
  .topbar-actions .ghost-button svg {
    width: 18px !important;
    height: 18px !important;
  }
  
  .topbar-actions #user-name-display {
    font-size: 13px !important;
  }
  .topbar-actions span[style*="font-size: 11px"] {
    font-size: 11px !important;
  }
  
  .topbar-actions .status-chip {
    padding: 4px 8px !important;
    font-size: 11px !important;
  }

  /* Drawer Overlay */
  .drawer-overlay.active {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 9998;
    backdrop-filter: blur(2px);
  }

  /* Hamburger Slide-in Drawer */
  .sidebar {
    position: fixed !important;
    top: 0 !important;
    bottom: 0 !important;
    left: -280px !important; /* Start hidden */
    width: 280px !important;
    height: 100vh;
    z-index: 9999 !important;
    background: var(--bg-2) !important;
    border-right: 1px solid var(--line-strong) !important;
    transition: left 0.3s ease-in-out;
    padding: 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
  }
  
  body.menu-open .sidebar {
    left: 0 !important;
  }
  body.menu-open {
    overflow: hidden;
  }

  .sidebar-top {
    display: flex; /* Bring back logo */
    padding: 24px;
  }

  /* Reset nav styles for vertical layout */
  .nav-menu {
    display: flex;
    flex-direction: column;
    padding: 12px 16px;
    gap: 4px;
    background: transparent;
    box-shadow: none;
  }

  .nav-item {
    width: 100% !important;
    min-height: 48px;
    border-radius: 8px;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    flex: none;
    background: transparent;
    padding: 0 16px;
  }

  .nav-item.active {
    background: rgba(0,0,0,0.05) !important;
    border-bottom: none !important;
    border-right: 3px solid var(--accent) !important;
  }

  .nav-item.active::before {
    display: none !important;
  }

  .nav-item .nav-label {
    font-size: 13px;
    font-weight: 600;
  }

  .nav-divider {
    display: block;
    height: 1px;
    background: var(--line-soft);
    margin: 12px 0;
  }

  .nav-section-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-disabled);
    margin: 8px 16px 4px;
  }

  .main-panel {
    order: 1;
    margin-bottom: 0;
    padding: 12px;
  }

  .dashboard-bottom-grid {
    grid-template-columns: 1fr;
  }

  /* login responsive */
  .login-screen {
    grid-template-columns: 1fr;
    padding: 24px;
    text-align: center;
    gap: 24px;
  }
  
  .login-hero h1 {
    font-size: 42px;
  }
  
  .login-copy {
    margin: 0 auto;
  }

  /* Mobile Card Layout for all tables (Stitch MCP 'Obsidian Sentinel' Style) */
  .table-wrap {
    overflow-x: visible;
    background: transparent;
    border: none;
    padding-bottom: 8px; /* avoid cutting off shadow */
  }
  .table-wrap table {
    min-width: 0 !important;
    width: 100%;
    display: block;
    table-layout: auto !important;
  }
  /* Hide the table headers instead of displaying them */
  .table-wrap thead {
    display: none;
  }
  .table-wrap tbody, .table-wrap tr, .table-wrap td {
    display: block;
    width: 100%;
  }
  /* Style each row as a card */
  .table-wrap tr {
    margin-bottom: 16px;
    background: var(--bg-2); /* Surface container */
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15); /* Lifted appearance */
    overflow: hidden;
  }
  /* Treat cells as vertical blocks inside the card */
  .table-wrap table td {
    border: none !important;
    border-bottom: 1px solid var(--line-soft) !important;
    padding: 12px 16px !important; /* Unified spacing */
    position: relative;
    text-align: left;
    display: flex;
    flex-direction: column; /* Stack Label and Value vertically */
    align-items: flex-start;
    justify-content: flex-start;
    gap: 4px;
    /* Prevent text overflow by breaking words if strictly necessary */
    word-break: break-word; 
    line-height: 1.4;
  }
  .table-wrap table td:last-child {
    border-bottom: none !important;
  }
  /* Generate the label using data-label attribute at the top of the cell */
  .table-wrap table td::before {
    content: attr(data-label);
    position: static; /* Removed absolute positioning */
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    transform: none;
    white-space: nowrap;
  }
  /* Value elements within td take up remaining space naturally */
  .table-wrap table td > span,
  .table-wrap table td > div,
  .table-wrap table td > button {
    width: 100%; /* Force content to take full width available for maximum readability */
    align-self: flex-start;
  }
  /* Adjusting buttons in card */
  .table-wrap table td button {
    width: auto;
    margin-top: 4px;
  }
  /* Fallback for empty table states without labels */
  .table-wrap table td.table-empty, .table-wrap table td[colspan] {
    padding-left: 12px !important;
    text-align: center;
    align-items: center;
    justify-content: center;
  }

  /* 모바일 해상도에서 기존 테이블을 숨기고 모바일 전용 이슈 피드를 노출 */
  .table-wrap {
    display: none !important;
  }
  #mobile-issue-monitor-feed {
    display: flex !important;
  }
  .monitor-head .monitor-actions {
    display: none !important; /* 모바일 관제 전용 액션 버튼들 숨김 */
  }

  /* [모바일 전용 모니터링 피드 스타일] */
  .mobile-only-feed {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 12px 0;
  }
  .section-heading-compact {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
  }
  .section-bar-compact {
    display: inline-block;
    width: 3px;
    height: 14px;
    background: var(--accent);
    border-radius: 2px;
  }
  .section-heading-compact h4 {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
  }
  .mobile-feed-servers, .mobile-feed-cards {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  /* Server Status Card */
  .mobile-server-card {
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-lg);
  }
  .mobile-server-info h5 {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 2px 0;
  }
  .mobile-server-info p {
    font-size: 11px;
    color: var(--text-secondary);
    margin: 0;
  }

  /* Issue Status Card */
  .mobile-issue-card {
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-left: 4px solid var(--neutral);
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    transition: transform 0.15s ease, background 0.15s ease;
  }
  .mobile-issue-card:active {
    transform: scale(0.98);
    background: var(--surface-hover);
  }
  .mobile-issue-card.issue-card-red {
    border-left-color: var(--danger);
  }
  .mobile-issue-card.issue-card-yellow {
    border-left-color: var(--warning);
  }
  .mobile-issue-card.issue-card-gray {
    border-left-color: var(--neutral);
  }
  .mobile-issue-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  .mobile-issue-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
  }
  .mobile-issue-desc {
    font-size: 12px;
    font-weight: 600;
    color: var(--danger);
  }
  .mobile-issue-card.issue-card-yellow .mobile-issue-desc {
    color: var(--warning);
  }
  .mobile-issue-card.issue-card-gray .mobile-issue-desc {
    color: var(--text-secondary);
  }
  .mobile-issue-details {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    background: var(--panel-3);
    padding: 10px;
    border-radius: var(--radius-sm);
    font-size: 12px;
  }
  .mobile-detail-item {
    color: var(--text-secondary);
  }
  .mobile-detail-item strong {
    color: var(--text-primary);
  }
}

/* [전역 드롭다운 & 알림 느낌표 스타일] */
.dropdown-wrap {
  position: relative;
  display: inline-block;
}
.dropdown-menu-custom {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 260px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  z-index: 10000;
  overflow: hidden;
  backdrop-filter: blur(8px);
  animation: slideDownCustom 0.2s ease-out;
}
@keyframes slideDownCustom {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}
.dropdown-menu-custom.hidden {
  display: none !important;
}
.dropdown-header {
  padding: 12px 16px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--line);
}
.dropdown-list {
  max-height: 280px;
  overflow-y: auto;
}
.dropdown-empty {
  padding: 24px 16px;
  text-align: center;
  font-size: 13px;
  color: var(--text-secondary);
}
.dropdown-item {
  width: 100%;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease;
}
.dropdown-item:hover {
  background: var(--surface-hover);
}
.dropdown-item.logout-item {
  color: var(--danger);
}
.dropdown-divider {
  height: 1px;
  background: var(--line);
  margin: 4px 0;
}
.profile-summary {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.profile-summary strong {
  font-size: 14px;
  color: var(--text-primary);
}
.profile-summary span {
  font-size: 11px;
  color: var(--text-secondary);
}
.noti-badge-dot {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 8px;
  height: 8px;
  background: var(--danger);
  border-radius: 50%;
}
.noti-badge-dot.hidden {
  display: none !important;
}

/* Notification Item */
.noti-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
  transition: background 0.15s ease;
}
.noti-item:hover {
  background: var(--surface-hover);
}
.noti-item strong {
  font-size: 13px;
  color: var(--text-primary);
}
.noti-item span {
  font-size: 11px;
  color: var(--text-secondary);
}
.noti-item:last-child {
  border-bottom: none;
}

