/* ============================================================
   gas-style.css — GOREA Control Tower (GAS UI 복제본)
   Pretendard + 사이드바 + CSS 변수 (계정관리/재고/매출/공구 공용)
   ============================================================ */

@import url('https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.8/dist/web/variable/pretendardvariable.css');

:root {
  --primary: #5b58ff;
  --primary-hover: #4f46e5;
  --sidebar-bg: #0f172a;
  --sidebar-hover: #1e293b;
  --bg-color: #f1f5f9;
  --surface: #ffffff;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --danger: #ef4444;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.08);
  --radius-md: 8px;
  --radius-lg: 12px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Pretendard Variable', Pretendard, -apple-system, BlinkMacSystemFont, system-ui, Roboto, 'Helvetica Neue', sans-serif;
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: #f1f5f9; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; border: 2px solid #f1f5f9; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

html, body {
  margin: 0 !important;
  padding: 0 !important;
  width: 100% !important;
  height: 100% !important;
  min-width: 1280px !important;
  overflow-x: auto !important;
  overflow-y: hidden;
}
body {
  display: flex !important;
  flex-direction: row !important;
  align-items: stretch !important;
  background: var(--bg-color);
  color: var(--text-main);
  min-width: 1280px !important;
}

/* ──────── 로그인 페이지 (body display:flex 무시) ──────── */
body.login-page {
  display: grid !important;
  place-items: center !important;
  min-height: 100vh !important;
  overflow: auto !important;
  background: linear-gradient(135deg, #5b58ff 0%, #4f46e5 100%) !important;
}
.login-card {
  background: #fff;
  padding: 40px 36px;
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
  width: 380px;
}
.login-card h1 { font-size: 1.6rem; font-weight: 900; color: var(--text-main); margin-bottom: 4px; }
.login-card .subtitle { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 24px; }
.login-card input {
  width: 100%; padding: 12px 14px; border: 1px solid #cbd5e1;
  border-radius: var(--radius-md); font-size: 1rem; margin-bottom: 12px;
  outline: none; transition: 0.2s; background: #f8fafc; font-weight: 600;
}
.login-card input:focus { border-color: var(--primary); background: #fff; box-shadow: 0 0 0 3px rgba(91,88,255,0.1); }
.login-card button {
  width: 100%; padding: 13px; background: var(--primary); color: #fff;
  border: 0; border-radius: var(--radius-md); font-size: 1rem; font-weight: 800;
  cursor: pointer; transition: 0.2s;
}
.login-card button:hover { background: var(--primary-hover); }
.login-card .err {
  background: #fee2e2; color: var(--danger); padding: 10px 12px;
  border-radius: 6px; font-size: 0.85rem; font-weight: 700; margin-bottom: 12px;
}

/* ──────── 사이드바 ──────── */
.sidebar {
  width: 260px;
  min-width: 260px;
  max-width: 260px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  box-shadow: 4px 0 15px rgba(0,0,0,0.05);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
  white-space: nowrap;
  justify-content: space-between;
  z-index: 50;
}
.sidebar.collapsed { width: 72px; min-width: 72px; max-width: 72px; }
.sidebar-header {
  padding: 24px 20px;
  font-size: 1.4rem; font-weight: 900;
  display: flex; align-items: center; gap: 12px;
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  letter-spacing: -0.5px;
}
.sidebar-header i { color: #818cf8; font-size: 1.6rem; }
.sidebar.collapsed .sidebar-header { padding: 24px 0; justify-content: center; }
.sidebar.collapsed .sidebar-header span { display: none; }

.nav-menu {
  list-style: none; padding: 14px 10px; margin: 0;
  flex: 1; overflow-y: auto; overflow-x: hidden;
}
.nav-item {
  padding: 13px 16px; margin-bottom: 5px;
  cursor: pointer; font-size: 0.95rem; font-weight: 700;
  color: #94a3b8; border-radius: 10px; transition: all 0.2s ease;
  display: flex; align-items: center; gap: 12px;
  position: relative; text-decoration: none;
}
.nav-item i.menu-icon { font-size: 1.1rem; min-width: 24px; text-align: center; }
.nav-item:hover { background: rgba(255,255,255,0.08); color: #f8fafc; transform: translateX(3px); }
.nav-item.active { background: var(--primary); color: #fff; box-shadow: 0 4px 12px rgba(91,88,255,0.35); }
.nav-item.active i.menu-icon { color: #fff; }

.nav-section-label {
  padding: 14px 16px 6px; font-size: 0.7rem; font-weight: 800;
  color: #475569; text-transform: uppercase; letter-spacing: 0.5px;
}

.sidebar-footer {
  border-top: 1px solid rgba(255,255,255,0.06);
  padding: 8px;
  display: flex; flex-direction: column; gap: 4px;
}
.footer-btn {
  padding: 13px 14px; cursor: pointer; color: #cbd5e1;
  display: flex; align-items: center; gap: 12px;
  font-size: 0.9rem; font-weight: 700; transition: 0.2s;
  background: none; border: none; border-radius: 10px;
  text-align: left; width: 100%; white-space: nowrap;
  text-decoration: none;
  font-family: inherit;
}
.footer-btn:hover { background: rgba(255,255,255,0.08); color: #fff; }
.footer-btn i { font-size: 1.05rem; min-width: 24px; text-align: center; transition: transform 0.3s; }

/* 사이드바 접기 상태 */
.sidebar.collapsed .nav-item .nav-text,
.sidebar.collapsed .nav-section-label,
.sidebar.collapsed .footer-btn .nav-text { display: none; }
.sidebar.collapsed .nav-item { padding: 14px 0; justify-content: center; overflow: visible; }
.sidebar.collapsed .nav-item:hover { transform: scale(1.08); }
.sidebar.collapsed .nav-item i.menu-icon { margin: 0; font-size: 1.3rem; }
.sidebar.collapsed .footer-btn { padding: 14px 0; justify-content: center; }
.sidebar.collapsed .footer-btn i { margin: 0; font-size: 1.2rem; }
.sidebar.collapsed #toggleBtn i { transform: rotate(180deg); }
.sidebar.collapsed .sidebar-header span { display: none; }
.sidebar.collapsed .sidebar-header { padding: 24px 0; justify-content: center; }

/* 접힌 상태에서 hover 시 툴팁 표시 */
.sidebar.collapsed .nav-item::after,
.sidebar.collapsed .footer-btn::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 72px;
  top: 50%;
  transform: translateY(-50%);
  background: #1e293b;
  color: #fff;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 800;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: 0.2s ease;
  box-shadow: 0 4px 10px rgba(0,0,0,0.25);
  z-index: 1050;
  border: 1px solid #334155;
}
.sidebar.collapsed .nav-item:hover::after,
.sidebar.collapsed .footer-btn:hover::after {
  opacity: 1;
  visibility: visible;
  left: 78px;
}

/* 상단 일반 버튼 */
.topbar-btn {
  padding: 6px 14px;
  background: #475569;
  color: #fff;
  border: 0;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: 0.2s;
  font-family: inherit;
}
.topbar-btn:hover { background: #334155; }
.topbar-btn.active { background: #0ea5e9; }
.topbar-btn.active:hover { background: #0284c7; }
.topbar-btn-cache { background: #ef4444 !important; }
.topbar-btn-cache:hover { background: #dc2626 !important; }

/* 상단 로그아웃 버튼 */
.topbar-logout {
  margin-left: 4px;
  padding: 6px 14px;
  background: #fee2e2;
  color: var(--danger);
  border-radius: 6px;
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: 0.2s;
}
.topbar-logout:hover { background: var(--danger); color: #fff; text-decoration: none; }

/* ═══════════════════════════════════════════════════════════
   탭 모드 (Tablet Mode) — 좌우 2열 → 위아래 1열 스택
   ═══════════════════════════════════════════════════════════ */
body.tablet-mode { overflow-y: auto !important; }
body.tablet-mode html { overflow-y: auto !important; }
body.tablet-mode .main-wrap { overflow-y: auto !important; height: auto !important; min-height: 100vh; }
body.tablet-mode .content { overflow-y: visible !important; height: auto !important; }
body.tablet-mode { min-width: 768px !important; }

/* 좌우 분할 그리드를 1열로 — 모든 -split 클래스 */
body.tablet-mode .acc-split,
body.tablet-mode .inv-split {
  grid-template-columns: 1fr !important;
  min-height: auto !important;
  gap: 20px !important;
}
body.tablet-mode .acc-panel,
body.tablet-mode .inv-panel {
  width: 100% !important;
  max-width: 100% !important;
}
/* 탭 모드에서 사이드바도 좀더 좁게 */
body.tablet-mode .sidebar { width: 200px; min-width: 200px; max-width: 200px; }

/* ═══════════════════════════════════════════════════════════
   모바일 반응형 (768px 이하)
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 1024px) {
  html, body { min-width: 100% !important; overflow-x: auto; }
  body { min-width: 100% !important; }
  .sidebar { width: 200px; min-width: 200px; max-width: 200px; }
  .topbar { padding: 0 14px; flex-wrap: wrap; height: auto; min-height: 56px; }
  .topbar .user { gap: 4px; }
  .topbar-btn, .topbar-logout { padding: 5px 10px; font-size: 0.75rem; }
  .content { padding: 12px; }
  .acc-split, .inv-split, .rev-split { grid-template-columns: 1fr !important; min-height: auto !important; }
  .acc-panel, .inv-panel, .rev-panel { width: 100% !important; max-width: 100% !important; }
}

@media (max-width: 768px) {
  /* 사이드바 자동 접기 */
  .sidebar:not(.collapsed) { width: 72px; min-width: 72px; max-width: 72px; }
  .sidebar:not(.collapsed) .nav-item .nav-text,
  .sidebar:not(.collapsed) .nav-section-label,
  .sidebar:not(.collapsed) .footer-btn .nav-text,
  .sidebar:not(.collapsed) .sidebar-header span { display: none; }
  .sidebar:not(.collapsed) .nav-item { padding: 14px 0; justify-content: center; }
  .sidebar:not(.collapsed) .sidebar-header { padding: 24px 0; justify-content: center; }
  .sidebar:not(.collapsed) .footer-btn { padding: 14px 0; justify-content: center; }

  /* 모바일 인터랙션 — 사이드바 펼침 시 오버레이 모드 */
  .sidebar.collapsed { width: 0; min-width: 0; max-width: 0; visibility: hidden; }

  /* 페이지 타이틀 짧게 */
  .topbar h1 { font-size: 0.95rem; }
  .topbar h1 span { display: none; }

  /* 카드/테이블 압축 */
  .gb-grid.cols-3, .gb-grid.cols-4 { grid-template-columns: 1fr !important; }
  .gb-tabs { flex-wrap: wrap; padding: 4px; }
  .gb-tab { padding: 7px 11px; font-size: 12px; }

  .inv-table th, .inv-table td { padding: 4px 5px; font-size: 0.74rem; }
  .acc-thead, .acc-row {
    grid-template-columns: 24px 30px 1fr 1fr 1fr 1fr 1.5fr 1.2fr !important;
    font-size: 0.72rem;
  }

  /* 모달 */
  .modal-card, .inv-modal-card, .gb-modal { width: calc(100vw - 16px) !important; padding: 16px; }
  .gb-form-row { grid-template-columns: 1fr; gap: 4px; }

  /* 리본 (파일함) */
  .fx-ribbon { padding: 6px 8px; }
  .fx-rb-group { padding: 0 4px; }
  .fx-rb-btn { padding: 4px 8px; font-size: 0.72rem; }
  .fx-rb-lbl { display: none; }
  .fx-tree { width: 180px; min-width: 180px; }
}

@media (max-width: 480px) {
  /* 매우 좁은 화면 — 사이드바 완전 숨김 (햄버거 메뉴 없으니 collapsed 강제) */
  .sidebar { width: 0; min-width: 0; max-width: 0; visibility: hidden; }
  .topbar { padding: 0 10px; }
  .acc-grid-2 { grid-template-columns: 1fr !important; }
  .inv-grid-2, .inv-grid-3 { grid-template-columns: 1fr !important; }
  .rev-form { grid-template-columns: 1fr 1fr !important; }
  .rev-form .full { grid-column: 1 / -1; }
  .rev-tab-nav button { padding: 8px 12px; font-size: 0.78rem; }
  .gb-toolbar { padding: 8px 10px; }
  .fx-tree { display: none; }
  .login-card { width: calc(100vw - 32px); padding: 28px 22px; }
}

/* ──────── 메인 콘텐츠 ──────── */
.main-wrap {
  flex: 1;
  display: flex; flex-direction: column;
  overflow: hidden;
  height: 100vh;
}
.topbar {
  height: 60px;
  background: var(--surface);
  border-bottom: 1px solid var(--border-color);
  display: flex; align-items: center;
  padding: 0 20px;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
  z-index: 10;
}
.topbar h1 {
  font-size: 1.15rem; font-weight: 800; color: var(--text-main);
  margin-right: 24px;
  display: flex; align-items: center;
}
.topbar .user {
  margin-left: auto; font-size: 0.85rem; color: var(--text-muted);
  display: flex; align-items: center; gap: 8px;
  flex-wrap: wrap;
}
.user-badge {
  padding: 5px 12px; background: #f1f5f9;
  border-radius: 16px; font-weight: 700; color: var(--text-main);
}

.content {
  flex: 1; overflow-y: auto; padding: 20px 24px;
  background: var(--bg-color);
}

/* 토스트 */
#toast-area {
  position: fixed; top: 24px; right: 24px;
  z-index: 5000; display: flex; flex-direction: column; gap: 8px;
}
.toast {
  background: #1e293b; color: #fff;
  padding: 12px 18px; border-radius: var(--radius-md);
  font-size: 0.9rem; font-weight: 700;
  box-shadow: var(--shadow-md);
  max-width: 380px;
  animation: toastSlide 0.25s ease;
}
@keyframes toastSlide {
  from { transform: translateX(100px); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

/* 메시지 */
.flash-msg {
  background: #d1fae5; color: #065f46;
  padding: 10px 14px; border-radius: var(--radius-md);
  font-size: 0.9rem; font-weight: 700;
  margin-bottom: 16px; border-left: 4px solid #10b981;
}
.flash-msg.err {
  background: #fee2e2; color: #991b1b;
  border-left-color: var(--danger);
}
