/**
 * InternauticaMNGr - Main Layout & Theme Stylesheet
 * Elegant maritime color palette: Deep Navy, Ocean Azure, Yacht White, Amber Accents
 */

:root {
  --bg-app: #090d16;
  --bg-panel: #0f172a;
  --bg-card: #1e293b;
  --bg-input: #020617;
  --border-color: #334155;
  --border-light: #1e293b;
  
  --primary: #0284c7;
  --primary-hover: #0369a1;
  --primary-light: #38bdf8;
  --accent-gold: #f59e0b;
  --accent-green: #10b981;
  --accent-red: #ef4444;

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --sidebar-w-left: 310px;
  --sidebar-w-right: 320px;
  --topbar-h: 56px;
  --bottombar-h: 32px;

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-app);
  color: var(--text-main);
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* --- Top Navigation Bar --- */
.app-header {
  height: var(--topbar-h);
  background-color: var(--bg-panel);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 100;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon-img {
  width: 38px;
  height: 38px;
  object-fit: contain;
  filter: drop-shadow(0 2px 6px rgba(2, 132, 199, 0.4));
  flex-shrink: 0;
}

.brand-info {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 38px;
}

.brand-logo-img {
  height: 22px;
  max-width: 230px;
  object-fit: contain;
  object-position: left center;
  display: block;
}

.brand-logo {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, #0284c7, #38bdf8);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: white;
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.4);
}

.brand-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: #ffffff;
}

.brand-sub {
  font-size: 10.5px;
  color: var(--primary-light);
  font-weight: 500;
  display: block;
  white-space: nowrap;
  line-height: 1.2;
}

.header-center {
  display: flex;
  align-items: center;
  gap: 12px;
}

.view-mode-toggle {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  display: flex;
  padding: 3px;
}

.view-mode-toggle button {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

.view-mode-toggle button.active {
  background-color: var(--primary);
  color: #ffffff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

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

/* Standard Buttons */
.btn {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.btn:hover {
  background-color: #334155;
  border-color: #475569;
}

.btn-primary {
  background-color: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

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

.btn-secondary {
  background-color: var(--bg-card);
}

.btn-danger {
  background-color: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.4);
  color: #f87171;
}

.btn-danger:hover {
  background-color: var(--accent-red);
  color: #ffffff;
}

.btn-icon {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  font-size: 14px;
}

.btn-icon:hover {
  background-color: var(--border-color);
}

/* Dropdown menu container */
.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-menu {
  display: none;
  position: absolute;
  right: 0;
  top: 100%;
  background-color: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: 0 10px 25px rgba(0,0,0,0.5);
  min-width: 190px;
  z-index: 500;
  margin-top: 4px;
  padding: 6px 0;
}

/* Hover bridge to eliminate mousegap and prevent flaky menu disappearance */
.dropdown-menu::before {
  content: '';
  position: absolute;
  top: -8px;
  left: 0;
  right: 0;
  height: 8px;
}

.dropdown:hover .dropdown-menu,
.dropdown.open .dropdown-menu {
  display: block;
}

.dropdown-item {
  display: block;
  width: 100%;
  padding: 8px 14px;
  background: transparent;
  border: none;
  color: var(--text-main);
  text-align: left;
  font-size: 12px;
  cursor: pointer;
}

.dropdown-item:hover {
  background-color: #1e293b;
  color: var(--primary-light);
}

.dropdown-divider {
  height: 1px;
  background-color: var(--border-color);
  margin: 4px 0;
}

/* --- Main Viewport Grid --- */
.app-main {
  flex: 1;
  display: flex;
  position: relative;
  overflow: hidden;
}

/* Sidebars */
.sidebar {
  background-color: var(--bg-panel);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  z-index: 20;
}

.sidebar-left {
  width: var(--sidebar-w-left);
  min-width: var(--sidebar-w-left);
}

.sidebar-right {
  width: var(--sidebar-w-right);
  min-width: var(--sidebar-w-right);
  border-right: none;
  border-left: 1px solid var(--border-color);
}

/* Sidebar Split Tabs */
.sidebar-tabs {
  display: flex;
  background-color: var(--bg-app);
  border-bottom: 1px solid var(--border-color);
}

.sidebar-tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 10px 4px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}

.sidebar-tab-btn.active {
  color: var(--primary-light);
  border-bottom-color: var(--primary-light);
  background-color: var(--bg-panel);
}

.sidebar-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

/* Center Canvas / 3D Container */
.viewport-center {
  flex: 1;
  position: relative;
  background-color: #020617;
  overflow: hidden;
}

/* Status Bar */
.app-footer {
  height: var(--bottombar-h);
  background-color: var(--bg-panel);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  font-size: 11px;
  color: var(--text-muted);
  font-family: monospace;
  z-index: 100;
}

.status-left, .status-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.badge-success { background: rgba(16, 185, 129, 0.2); color: #34d399; }
.badge-danger { background: rgba(239, 68, 68, 0.2); color: #f87171; }
.badge-primary { background: rgba(2, 132, 199, 0.2); color: #38bdf8; }
.badge-cyan { background: rgba(56, 189, 248, 0.2); color: #38bdf8; border: 1px solid rgba(56, 189, 248, 0.3); }

/* Utilities */
.hidden { display: none !important; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }

/* Form inputs general */
.input-text, .input-num, .input-select {
  width: 100%;
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  user-select: text;
  -webkit-user-select: text;
}

.input-text:focus, .input-num:focus, .input-select:focus {
  outline: none;
  border-color: var(--primary);
}

.input-num.disabled {
  background-color: #1e293b;
  color: #94a3b8;
  cursor: not-allowed;
}

/* Toast Notifications Container */
#toast-container {
  position: fixed;
  bottom: 45px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1000;
  pointer-events: none;
}

.toast-pill {
  background-color: #1e293b;
  color: #ffffff;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.5);
  border-left: 4px solid var(--primary);
  animation: slideIn 0.2s ease-out;
  pointer-events: auto;
}

.toast-pill.success { border-left-color: var(--accent-green); }
.toast-pill.warning { border-left-color: var(--accent-gold); }
.toast-pill.error { border-left-color: var(--accent-red); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.toast-pill.fade-out {
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.3s ease;
}

/* Responsive adjustments */
@media (max-width: 1024px) {
  :root {
    --sidebar-w-left: 260px;
    --sidebar-w-right: 270px;
  }
}

@media (max-width: 768px) {
  .sidebar-left, .sidebar-right {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 85%;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    box-shadow: 0 0 30px rgba(0,0,0,0.8);
  }
  .sidebar-right {
    right: 0;
    left: auto;
    transform: translateX(100%);
  }
  .sidebar-left.open { transform: translateX(0); }
  .sidebar-right.open { transform: translateX(0); }
}
