/* ============================================
   Banavo Shared Layout CSS
   Light-mode first, full-width, left sidebar
   ============================================ */

/* --- Theme Variables (Light = default) --- */
:root {
  --bg-body: #f8fafc;
  --bg-panel: #ffffff;
  --bg-panel-solid: #ffffff;
  --bg-input: #f1f5f9;
  --bg-input-hover: #e2e8f0;

  --bg-panel-header: linear-gradient(90deg, rgba(20,140,130,0.8), rgba(52,128,255,0.8), rgba(10,20,40,0.8));

  --accent: #6366f1;
  --accent-soft: rgba(99, 102, 241, 0.10);

  --border: #e2e8f0;
  --border-soft: #e2e8f0;
  --border-input: #cbd5e1;

  --text-main: #1e293b;
  --text-muted: #64748b;
  --text-header: #ffffff;
  --text-placeholder: #94a3b8;

  --danger: #ef4444;

  --shadow-soft: 0 4px 6px -1px rgba(0,0,0,0.05);
  --shadow-subtle: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-card: 0 10px 15px -3px rgba(0,0,0,0.05);

  --radius-lg: 16px;
  --radius-sm: 8px;

  --sidebar-width: 260px;
  --topbar-height: 56px;
}

/* --- Dark Mode --- */
:root[data-theme="dark"] {
  --bg-body: #0f172a;
  --bg-panel: #1e293b;
  --bg-panel-solid: #1e293b;
  --bg-input: rgba(15, 23, 42, 0.6);
  --bg-input-hover: rgba(15, 23, 42, 0.8);

  --bg-panel-header: linear-gradient(90deg, rgba(20,140,130,0.45), rgba(52,128,255,0.42), rgba(10,20,40,0.1));

  --accent: #818cf8;
  --accent-soft: rgba(129, 140, 248, 0.16);

  --border: #334155;
  --border-soft: rgba(148,163,184,0.3);
  --border-input: #334155;

  --text-main: #e2e8f0;
  --text-muted: #94a3b8;
  --text-header: #e5f2ff;
  --text-placeholder: #64748b;

  --danger: #f87171;

  --shadow-soft: 0 22px 45px rgba(15,23,42,0.65);
  --shadow-subtle: 0 1px 3px rgba(15,23,42,0.8);
  --shadow-card: 0 28px 60px rgba(15,23,42,0.8);
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; }

html {
  overflow-x: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background: var(--bg-body);
  color: var(--text-main);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  transition: background 0.3s ease, color 0.3s ease;
}

/* --- App Layout Grid --- */
.app-layout {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  min-height: 100vh;
}

/* --- Sidebar --- */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow-y: auto;
  transition: transform 0.3s ease;
}

.sidebar-logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo img {
  height: 28px;
  display: block;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  transition: all 0.15s ease;
  border-left: 3px solid transparent;
}

.sidebar-nav a:hover {
  background: var(--bg-input);
  color: var(--text-main);
}

.sidebar-nav a.active {
  color: var(--accent);
  background: var(--accent-soft);
  border-left-color: var(--accent);
  font-weight: 600;
}

.sidebar-nav .nav-icon {
  width: 20px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-nav .nav-icon svg {
  width: 18px;
  height: 18px;
}

.sidebar-nav .nav-badge {
  margin-left: auto;
  font-size: 0.65rem;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

/* --- Nav divider & sidebar button --- */
.nav-divider {
  height: 1px;
  background: var(--border);
  margin: 8px 20px;
}

.sidebar-nav-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  color: var(--text-muted);
  background: none;
  border: none;
  border-left: 3px solid transparent;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  width: 100%;
  text-align: left;
  font-family: inherit;
}

.sidebar-nav-btn:hover {
  background: var(--bg-input);
  color: var(--text-main);
}

.sidebar-nav-btn .nav-icon {
  width: 20px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-nav-btn .nav-icon svg {
  width: 18px;
  height: 18px;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* --- Topbar Credit Info --- */
.topbar-credit {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.topbar-credit-badge {
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  background: #dcfce7;
  color: #16a34a;
}

:root[data-theme="dark"] .topbar-credit-badge {
  background: rgba(22, 163, 106, 0.2);
  color: #4ade80;
}

.topbar-credit-value {
  font-weight: 600;
  color: var(--text-main);
}

.topbar-credit-next {
  font-size: 0.72rem;
}

.sidebar-footer-links {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-footer-links a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.75rem;
  transition: color 0.15s;
}

.sidebar-footer-links a:hover {
  color: var(--text-main);
}

/* --- Main Area --- */
.main-area {
  grid-column: 2;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* --- Topbar --- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--topbar-height);
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 12px;
}

.topbar-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-badge {
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.65rem;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.topbar-spacer { flex: 1; }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-btn {
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-panel);
  color: var(--text-main);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  font-family: inherit;
}

.topbar-btn:hover {
  background: var(--bg-input);
  border-color: var(--accent);
}

.topbar-btn.accent {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.topbar-btn.accent:hover {
  opacity: 0.9;
}

.topbar-btn.success {
  background: #10b981;
  color: #fff;
  border-color: #10b981;
}

.topbar-btn.warning {
  background: linear-gradient(90deg, #8b5cf6, #d946ef);
  color: #fff;
  border-color: transparent;
}

.topbar-btn.icon-btn {
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.topbar-btn.icon-btn svg {
  width: 18px;
  height: 18px;
}

/* --- JP/US Locale Toggle --- */
.locale-toggle {
  display: flex;
  align-items: center;
  background: var(--bg-input);
  border-radius: 999px;
  padding: 2px;
  border: 1px solid var(--border);
  gap: 0;
  margin-right: 4px;
}

.locale-toggle-btn {
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
  letter-spacing: 0.03em;
}

.locale-toggle-btn.active {
  background: var(--accent);
  color: #fff;
}

.locale-toggle-btn:not(.active):hover {
  color: var(--text-main);
}

.hamburger-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text-main);
  font-size: 1.4rem;
  cursor: pointer;
  padding: 4px;
}

/* --- Page Content --- */
.page-content {
  flex: 1;
  padding: 24px;
}

/* --- Mobile Overlay --- */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
}

.sidebar-overlay.active {
  display: block;
}

/* --- Responsive --- */
@media (max-width: 1024px) {
  .app-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-area {
    grid-column: 1;
  }

  .hamburger-btn {
    display: block;
  }
}

@media (max-width: 768px) {
  .topbar {
    padding: 0 16px;
  }

  .topbar-credit {
    display: none;
  }

  .topbar-actions .topbar-btn-text {
    display: none;
  }

  .page-content {
    padding: 16px;
  }
}

@media (max-width: 480px) {
  .topbar {
    padding: 0 12px;
  }

  .page-content {
    padding: 12px;
  }

  /* トップバーの溢れ対策 */
  #logoutBtn {
    display: none;
  }

  .locale-toggle {
    display: none;
  }

  .topbar-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex-shrink: 1;
    min-width: 0;
  }
}
