/* ================================================================
   layout.css — KT 미디어 대시보드 레이아웃 기반
   Phase 2 F-01: 다크 사이드바 + 상단 1줄 필터 바
================================================================ */

/* ── 페이지 로더 ──────────────────────────────────────────────── */
.page-loader-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: var(--tblr-bg-surface, #ffffff);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

body.page-loaded .page-loader-overlay {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* ── 기본 리셋 ────────────────────────────────────────────────── */
html {
  margin: 0 !important;
}

body {
  margin: 0;
  min-height: 100vh;
}

body.dashboard-page,
body.dashboard-page .page-wrapper,
body.dashboard-page .page-body,
body.dashboard-page .app-container--wide {
  background: var(--app-surface-1);
}

body.dashboard-page .page-body {
  margin-top: 0 !important;
  padding-top: 0.25rem;
}

.dashboard-page-header.page-header {
  margin-top: 0 !important;
  margin-bottom: 0.5rem !important;
}

.dashboard-page-header__scope {
  display: inline-block;
  margin-left: 0.375rem;
  color: var(--tblr-secondary-color, #616876);
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.2;
  vertical-align: baseline;
}

/* ── 인증된 레이아웃 (헤더 + 사이드바 Fixed) ─────────────────── */
body.authenticated {
  padding-top: 3.5rem;
  /* 상단 네비바 높이 */
}

/* 상단 네비바 고정 */
body.authenticated header.navbar {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  z-index: 1031 !important;
}

/* 사이드바 고정 */
body.authenticated .navbar-vertical.navbar-expand-lg {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  height: 100vh !important;
  width: 315px !important;
  overflow-y: hidden !important;
  z-index: 1029;
}

/* 사이드바 영역만큼 콘텐츠 영역 밀기 */
body.authenticated .page-wrapper {
  margin-left: 315px !important;
  min-width: 0;
}

body.authenticated .navbar-vertical .container-fluid {
  flex-direction: row !important;
  align-items: stretch !important;
  padding: 0 !important;
  height: 100% !important;
}

body.authenticated .navbar-vertical .navbar-collapse {
  width: 100%;
  height: 100%;
}

body.authenticated .navbar-vertical .navbar-nav {
  width: 100%;
}

body.authenticated .navbar-vertical .navbar-nav .nav-link {
  justify-content: flex-start !important;
}

/* 2단 사이드바 내부 상세 구조 스타일 */
.sidebar-tier1 {
  background-color: #f4f4f4 !important;
  border-right: 1px solid #e5e7eb !important;
}

.sidebar-tier1 .nav-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #7a7a7a !important;
  transition: all 0.2s ease;
  padding: 0.75rem 0.5rem;
  border-radius: 6px;
}

.sidebar-tier1 .nav-link:hover {
  background-color: rgba(0, 0, 0, 0.04) !important;
  color: #181818 !important;
}

.sidebar-tier1 .nav-link.active {
  background-color: rgba(32, 115, 176, 0.1) !important;
  color: #2073b0 !important;
  font-weight: 600;
}

.sidebar-tier2 {
  background-color: #ffffff !important;
  border-right: 1px solid #e5e7eb !important;
}

.sidebar-tier2 .nav-link {
  border-radius: 6px;
  margin: 0.125rem 0;
  transition: all 0.2s ease;
  color: #181818 !important;
}

.sidebar-tier2 .nav-link:hover {
  background-color: rgba(32, 115, 176, 0.05) !important;
  color: #2073b0 !important;
}

.sidebar-tier2 .nav-link.active {
  background-color: rgba(32, 115, 176, 0.1) !important;
  color: #2073b0 !important;
  font-weight: 500;
}


/* ── 상단 필터 바 (dashboard-filterbar) ──────────────────────── */
.dashboard-filterbar {
  background: var(--tblr-bg-surface);
  border-bottom: 1px solid var(--tblr-border-color);
  padding: 0.5rem 1rem;
  position: sticky;
  top: 3.5rem;
  z-index: 1020;
}

body.authenticated .dashboard-filterbar {
  margin-left: var(--tblr-navbar-width, 15rem);
}

.filterbar-inner {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.filterbar-inner::-webkit-scrollbar {
  display: none;
}

.dashboard-filter-controls {
  flex-wrap: nowrap;
  min-width: max-content;
}

.dashboard-filter-controls__title,
.dashboard-filter-controls__label {
  display: none;
}

.dashboard-filter-controls__field {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  flex-shrink: 0;
}

.dashboard-filter-controls__select {
  height: 28px;
  min-height: 28px;
  padding-right: 1.2rem;
  font-size: 0.75rem;
  line-height: 1.2;
}

.dashboard-filter-controls__field--group .dashboard-filter-controls__select,
.dashboard-filter-controls__field--media .dashboard-filter-controls__select {
  width: 92px;
}

.dashboard-filter-controls__field--campaign .dashboard-filter-controls__select {
  width: 105px;
}

.dashboard-filter-controls__field--creative .dashboard-filter-controls__select {
  width: 100px;
}

.dashboard-filter-controls > * {
  flex-shrink: 0;
}

.dashboard-filter-controls__date-range {
  white-space: nowrap;
}

.dashboard-filter-controls__date-input {
  width: 112px;
  min-width: 112px;
  height: 28px;
  min-height: 28px;
  padding: 0 0.375rem;
  font-size: 0.75rem;
  line-height: 1.2;
}

.dashboard-filter-controls__presets {
  flex-wrap: nowrap;
}

.dashboard-filter-controls__apply {
  align-self: center;
}

/* 필터 그룹 */
.filter-group {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-shrink: 0;
}

.filter-group--period {
  gap: 0.25rem;
}

/* 퀵버튼 */
.btn-preset {
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}

.btn-preset:hover,
.btn-preset.active {
  background: var(--tblr-primary);
  color: #fff;
  border-color: var(--tblr-primary);
}

/* 날짜 입력 */
.filterbar-inner input[type="date"] {
  height: 28px;
  min-height: 28px;
  padding: 0 0.375rem;
  font-size: 0.75rem;
  line-height: 1.2;
  border: 1px solid var(--tblr-border-color);
  border-radius: var(--tblr-border-radius);
  background: var(--tblr-bg-surface);
  color: var(--tblr-body-color);
  min-width: 112px;
  width: 112px;
}

/* 구분선 */
.filterbar-divider {
  width: 1px;
  height: 1.5rem;
  background: var(--tblr-border-color);
  flex-shrink: 0;
  margin: 0 0.25rem;
}

/* 데스크톱 기준 상단 헤더 숨김 및 사이드바 꽉 차게 처리 */
@media (min-width: 992px) {
  body.authenticated {
    padding-top: 0 !important;
  }
  body.authenticated header.navbar {
    display: none !important;
  }
}

/* ── 모바일 ──────────────────────────────────────────────────── */
@media (max-width: 991.98px) {
  body.authenticated {
    padding-top: 3.5rem !important;
  }
  body.authenticated header.navbar {
    display: flex !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    height: 3.5rem !important;
    z-index: 1030 !important;
  }
  body.authenticated .navbar-vertical.navbar-expand-lg {
    position: fixed !important;
    top: 3.5rem !important;
    left: 0 !important;
    width: 315px !important;
    height: calc(100vh - 3.5rem) !important;
    overflow-y: auto !important;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 1050;
  }
  body.authenticated .navbar-vertical.navbar-expand-lg.is-mobile-open {
    transform: translateX(0);
  }

  body.authenticated .navbar-vertical.navbar-expand-lg #sidebar-menu {
    height: 100% !important;
  }

  body.authenticated .navbar-vertical.navbar-expand-lg .sidebar-tier1,
  body.authenticated .navbar-vertical.navbar-expand-lg .sidebar-tier2 {
    height: 100% !important;
  }

  body.authenticated .page-wrapper,
  body.authenticated .dashboard-filterbar {
    margin-left: 0 !important;
  }

  .dashboard-filterbar {
    top: 3.5rem;
  }

  .filterbar-inner {
    overflow-x: visible;
  }

  .dashboard-filter-controls {
    width: 100%;
    min-width: 0;
    flex-direction: column;
    align-items: stretch !important;
    justify-content: flex-start !important;
    gap: 0.75rem;
  }

  .dashboard-filter-controls__title,
  .dashboard-filter-controls__label {
    display: block;
  }

  .dashboard-filter-controls__title {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--tblr-body-color);
    padding-bottom: 0.125rem;
  }

  .dashboard-filter-controls__field {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 0.375rem;
  }

  .dashboard-filter-controls__label {
    margin: 0;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--tblr-secondary-color, #616876);
  }

  .dashboard-filter-controls__field .form-select,
  .dashboard-filter-controls__field .form-control,
  .dashboard-filter-controls__apply {
    width: 100% !important;
  }

  .dashboard-filter-controls__presets {
    display: grid !important;
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .dashboard-filter-controls__date-range {
    width: 100%;
  }

  .dashboard-filter-controls__date-range .text-muted {
    align-self: center;
    flex-shrink: 0;
  }

  .filterbar-divider {
    display: none !important;
  }
}

/* ── 공용 (비인증 페이지) ────────────────────────────────────── */
body:not(.authenticated) .page-wrapper {
  margin-left: 0 !important;
}

/* ── Map 전용 레이아웃 ───────────────────────────────────────── */
.map-page-wrapper {
  display: flex;
  overflow: hidden;
}

@media (min-width: 992px) {
  .map-page-wrapper {
    height: calc(100vh - 125px) !important;
  }
}

@media (max-width: 991.98px) {
  .map-page-wrapper {
    height: calc(100vh - 250px) !important;
    flex-direction: column-reverse;
  }
  .map-side-panel {
    width: 100% !important;
    height: 300px;
    border-left: none !important;
    border-top: 1px solid var(--tblr-border-color);
  }
}


.map-container-full {
  flex: 1;
  min-width: 0;
}

.map-side-panel {
  width: 300px;
  flex-shrink: 0;
  border-left: 1px solid var(--tblr-border-color);
  background: var(--tblr-bg-surface-secondary, #f8fafc);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* Use inner scroll instead */
  z-index: 5;
}
