/* Body styles consolidated in theme.css */

#app {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.app-shell {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
}

.app-topbar {
  --topbar-pad-y: 3px;
  --topbar-inner-pad-y: 6px;
  width: 100%;
  display: flex;
  justify-content: center;
  padding: var(--topbar-pad-y) 0;
  margin-bottom: 0;
  position: relative;
  z-index: 10004;
  background: #ffffff;
  border-bottom: 1px solid rgba(0,0,0,0.28);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
  backdrop-filter: none;
}

.app-topbar-inner {
  width: min(1200px, calc(100% - 20px));
  display: flex;
  align-items: center;
  gap: calc(var(--topbar-pad-y) + var(--topbar-inner-pad-y));
  padding: var(--topbar-inner-pad-y) 10px;
}

.app-topbar-debug {
  flex: 0 0 auto;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(0, 0, 0, 0.2);
  background: rgba(0, 0, 0, 0.06);
  color: rgba(0, 0, 0, 0.8);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
}

.app-topbar-debug:hover {
  background: rgba(0, 0, 0, 0.1);
}

.app-topbar-debug:active {
  background: rgba(0, 0, 0, 0.16);
}

.element-picker-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  border: 2px solid rgba(37, 99, 235, 0.9);
  background: rgba(37, 99, 235, 0.12);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.6) inset;
  pointer-events: none;
  z-index: 99999;
  transition: transform 0.04s ease, width 0.04s ease, height 0.04s ease;
}

.element-picker-label {
  position: fixed;
  top: 0;
  left: 0;
  padding: 4px 8px;
  border-radius: 6px;
  background: rgba(17, 24, 39, 0.92);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  pointer-events: none;
  z-index: 100000;
  transform: translate(-9999px, -9999px);
}

.app-topbar-status {
  --status-bg: rgba(0, 0, 0, 0.04);
  --status-border: rgba(0, 0, 0, 0.08);
  --status-color: rgba(0, 0, 0, 0.55);
  --status-fade-left: 2px;
  flex: 1 1 auto;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  height: 35px;
  box-sizing: border-box;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.25;
  color: var(--status-color);
  background: var(--status-bg);
  border: 1px solid var(--status-border);
  position: relative;
  overflow: hidden;
  scrollbar-width: none;
}

.app-topbar-status.clickable {
  cursor: pointer;
}

.app-topbar-status.has-tuner {
  overflow: visible;
  z-index: 2;
}

.app-topbar-status.has-spinner {
  --status-fade-left: 2px;
}

.app-topbar-status .status-spinner {
  flex: 0 0 auto;
  display: inline-block !important;
  visibility: visible !important;
  width: 16px !important;
  height: 16px !important;
  min-width: 16px !important;
  min-height: 16px !important;
  opacity: 1 !important;
  position: relative;
  z-index: 10;
  /* Ensure spinner is visible - override any mask issues */
  -webkit-mask: radial-gradient(circle, transparent 72%, #000 73%) !important;
  mask: radial-gradient(circle, transparent 72%, #000 73%) !important;
  animation: spin 1s linear infinite !important;
  /* Ensure background is visible - use a more visible color for debugging */
  background: conic-gradient(
    transparent 0deg 90deg,
    rgba(157, 185, 231, 0) 90deg,
    rgba(157, 185, 231, 0.35) 110deg,
    #5a86d8 170deg,
    #266bd9 260deg,
    #266bd9 360deg
  ) !important;
  /* Ensure it's not clipped */
  overflow: visible;
  /* Debug: add a border to see if element is there */
  border-radius: 50%;
}

.app-topbar-status.status-spinner-green .status-spinner {
  background: conic-gradient(
    transparent 0deg 90deg,
    rgba(22, 163, 74, 0) 90deg,
    rgba(22, 163, 74, 0.35) 110deg,
    #86efac 170deg,
    #16a34a 260deg,
    #16a34a 360deg
  );
}

.app-topbar-status .status-text {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}


.app-topbar-status:hover {
  overflow-x: auto;
}

.app-topbar-status::-webkit-scrollbar {
  height: 0;
  width: 0;
}

.app-topbar-status::before,
.app-topbar-status::after {
  content: '';
  position: absolute;
  top: 2px;
  bottom: 2px;
  width: 18px;
  pointer-events: none;
  opacity: 0;
}

.app-topbar-status::before {
  left: var(--status-fade-left);
  background: linear-gradient(270deg, rgba(255, 255, 255, 0), var(--status-bg));
}

.app-topbar-status::after {
  right: 2px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0), var(--status-bg));
}

.app-topbar-status[data-overflow='start']::before,
.app-topbar-status[data-overflow='both']::before {
  opacity: 1;
}

.app-topbar-status[data-overflow='end']::after,
.app-topbar-status[data-overflow='both']::after {
  opacity: 1;
}

/* Shared tone styles for status bar and status log items */
/* Text color is consistent across all tones - only background colors indicate message types */
.app-topbar-status.info,
.app-topbar-status-log-item.info {
  --status-color: #000000;
  --status-bg: rgba(0, 122, 255, 0.12);
  --status-border: rgba(0, 122, 255, 0.25);
}

.app-topbar-status.warning,
.app-topbar-status-log-item.warning {
  --status-color: #000000;
  --status-bg: rgba(255, 59, 48, 0.12);
  --status-border: rgba(255, 59, 48, 0.35);
}

.app-topbar-status.error,
.app-topbar-status-log-item.error {
  --status-color: #000000;
  --status-bg: rgba(255, 59, 48, 0.22);
  --status-border: rgba(255, 59, 48, 0.55);
}

.app-topbar-status.caution,
.app-topbar-status-log-item.caution {
  --status-color: #000000;
  --status-bg: rgba(255, 199, 0, 0.18);
  --status-border: rgba(255, 199, 0, 0.35);
}

.app-topbar-status.loading,
.app-topbar-status-log-item.loading {
  --status-color: #000000;
  --status-bg: rgba(0, 122, 255, 0.12);
  --status-border: rgba(0, 122, 255, 0.25);
}

/* Status bar wrapper for status log extension */
.app-topbar-status-wrapper {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 100;
}


/* Status Log Toggle Button - inside status bar */
.app-topbar-status-log-toggle {
  flex: 0 0 auto;
  width: 35px;
  height: 35px;
  margin: -10px -10px -10px auto;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0 7px 7px 0;
  border: none;
  background: #e5e5e5;
  color: #666666;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.app-topbar-status-log-toggle:hover {
  background: #d4d4d4;
  color: #333333;
}

.app-topbar-status-log-toggle.expanded {
  background: #007aff;
  color: #ffffff;
  border-radius: 0 7px 0 0;
}

/* Status Log Panel - extends from status bar, overlays content */
.app-topbar-status-log {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.35);
  border-radius: var(--radius-sm);
  max-height: 75vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35), 0 8px 20px rgba(0, 0, 0, 0.25), 0 2px 6px rgba(0, 0, 0, 0.15);
}

.app-topbar-status-log-list {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}

.app-topbar-status-log-item {
  --status-bg: rgba(0, 0, 0, 0.04);
  --status-border: rgba(0, 0, 0, 0.08);
  --status-color: #000000;
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
  background: var(--status-bg);
  border-bottom: 1px solid var(--status-border);
  color: var(--status-color);
}

.app-topbar-status-log-item:last-child {
  border-bottom: none;
}

.app-topbar-status-log-item .status-log-time {
  flex: 0 0 auto;
  color: rgba(0, 0, 0, 0.4);
  font-family: ui-monospace, monospace;
  font-size: 10px;
  min-width: 65px;
  font-weight: 500;
}

.app-topbar-status-log-item .status-log-text {
  flex: 1;
  word-break: break-word;
  color: var(--status-color);
}

/* Status suffix colors for inline status indicators */
.status-suffix-completed {
  color: #16a34a;
  font-weight: 600;
}

.status-suffix-retrying {
  color: #f97316;
  font-weight: 600;
}

.status-suffix-failed {
  color: #dc2626;
  font-weight: 600;
}

.app-container {
  max-width: 1200px;
  margin: 10px auto;
  background-color: white;
  border-radius: 14px;
  border: 1px solid var(--separator-opaque);
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
  width: calc(100% - 20px);
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.app-container.settings-mode {
  overflow: auto;
}

.app-container.planner-mode {
  max-width: none;
  margin: 10px;
  width: calc(100% - 20px);
  background: transparent;
  border: 1px solid rgba(0,0,0,0.28);
  box-shadow: 0 16px 38px rgba(0,0,0,0.12);
  border-radius: 8px;
  padding: 0;
  overflow: hidden;
}

.app-container.bare-mode {
  max-width: none;
  margin: 0;
  width: 100%;
  background: transparent;
  border: none;
  box-shadow: none;
  border-radius: 0;
  padding: 0;
}

.app-content {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.app-container:not(.planner-mode) .app-content {
  overflow: auto;
}

/* Blockers */
.app-blocker {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.app-blocker-card {
  width: 100%;
  max-width: 520px;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 14px;
  padding: 18px 18px 16px;
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.12);
}

.app-blocker-title {
  font-size: 18px;
  font-weight: 800;
  margin-bottom: 8px;
}

.app-blocker-body {
  font-size: 13px;
  color: rgba(0, 0, 0, 0.7);
  line-height: 1.4;
  margin-bottom: 14px;
}

.app-blocker-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
}

/* Logo menu */
.logo-menu {
  --logo-top: #266bd9;
  --logo-bottom: #9db9e7;
  --logo-bottom-light: #ffffff;
  --logo-button-width: 0px;
  position: relative;
  z-index: 10003;
}

.logo-menu-button {
  border: none;
  background: transparent;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  cursor: pointer;
  position: relative;
  z-index: 3;
}

.logo-menu-button:hover .logo-menu-title {
  filter: none;
}

.logo-menu:hover .logo-menu-title,
.logo-menu:focus-within .logo-menu-title {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  border-bottom-color: transparent;
  border-bottom-width: 0;
  box-shadow: none;
}

.logo-menu-title {
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  height: 35px;
  padding: 0 8px;
  background: linear-gradient(180deg, var(--logo-top), var(--logo-bottom));
  color: #ffffff;
  border: 1px solid var(--logo-border);
  box-shadow: none;
  border-radius: var(--radius-sm);
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 18px;
}

.logo-menu-panel {
  position: absolute;
  top: 100%;
  left: 0;
  width: max-content;
  max-width: calc(100vw - 24px);
  max-height: calc(100vh - 70px);
  overflow-x: visible;
  overflow-y: auto;
  background: linear-gradient(180deg, var(--logo-bottom), var(--logo-top));
  border: 1px solid var(--logo-border);
  border-radius: 0 8px 8px 8px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.18);
  clip-path: inset(0 -40px -40px -40px);
  padding: 0;
}

.logo-menu-panel::before {
  content: '';
  position: absolute;
  top: -1px;
  left: 0;
  width: var(--logo-button-width);
  height: 1px;
  background: var(--logo-bottom);
  pointer-events: none;
  z-index: 2;
}

.logo-menu:hover .logo-menu-panel,
.logo-menu:focus-within .logo-menu-panel {
  margin-top: -1px;
}

.logo-menu-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  width: max-content;
}

.logo-menu-item-row {
  position: relative;
}

.logo-menu-item {
  position: relative;
  width: 100%;
  text-align: left;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.875rem;
  font-weight: 700;
  color: #ffffff;
  white-space: nowrap;
  text-shadow: none;
  box-shadow: none;
  transition: color 0.2s ease;
}

.logo-menu-item::before {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0;
  background: rgba(255, 255, 255, 0.9);
  transition: opacity 0.2s ease;
  z-index: 0;
  border-radius: 0;
}

.logo-menu-item > * {
  position: relative;
  z-index: 1;
}

.logo-menu-item-row.has-children .logo-menu-item {
  padding-right: 28px;
}

.logo-menu-item-meta {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.logo-menu-item-chevron {
  font-size: 12px;
  opacity: 0.7;
}

.logo-menu-item:hover {
  color: #2E6EA6;
}

.logo-menu-item.active {
  color: inherit;
  font-weight: 700;
}

.logo-menu-item:hover::before {
  opacity: 1;
}

.logo-menu-list > .logo-menu-item-row:first-child .logo-menu-item::before {
  border-top-left-radius: 0;
  border-top-right-radius: 8px;
}

.logo-menu-list > .logo-menu-item-row:last-child .logo-menu-item::before {
  border-bottom-left-radius: 8px;
  border-bottom-right-radius: 8px;
}

.logo-menu-item.readonly {
  color: rgba(0, 0, 0, 0.55);
}

.logo-menu-item.readonly .logo-menu-item-badge {
  background: rgba(90, 90, 90, 0.16);
  color: rgba(0, 0, 0, 0.6);
}

.logo-menu-item.locked {
  color: rgba(0, 0, 0, 0.35);
  cursor: default;
}

.logo-menu-item.locked:hover {
  background-color: transparent;
}

.logo-menu-item-label {
  flex: 1;
}

.logo-menu-item-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(90, 90, 90, 0.12);
  color: rgba(30, 41, 59, 0.7);
}

.logo-menu-submenu {
  display: none;
  position: absolute;
  top: 0;
  left: calc(100% + 8px);
  min-width: 220px;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: var(--radius-md);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.2);
  padding: 10px;
  z-index: 10005;
}

.logo-menu-item-row.has-children:hover > .logo-menu-submenu,
.logo-menu-item-row.has-children:focus-within > .logo-menu-submenu {
  display: block;
}

.logo-menu-locked-toggle {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.35);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.logo-menu-locked-toggle button {
  width: 100%;
  border: 1px solid var(--system-gray5);
  background-color: #ffffff;
  background-image: none;
  border-radius: var(--radius-sm);
  padding: 0 12px;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 700;
  color: #1e293b;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 35px;
  white-space: nowrap;
  text-shadow: none;
  box-shadow: 0 4px 10px rgba(0,0,0,0.14), 0 1px 2px rgba(0,0,0,0.10);
  transition: box-shadow 0.15s ease, background-color 0.15s ease;
}

.logo-menu-locked-toggle button:hover {
  background-color: rgb(245, 245, 245);
  background-image: linear-gradient(to bottom, rgb(255, 255, 255), rgb(238, 238, 238));
}

.logo-menu-locked-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo-menu-arrow {
  font-size: 12px;
  opacity: 0.7;
}

/* Access pills (Security UI) */
.access-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  background: rgba(0, 0, 0, 0.06);
  color: rgba(0, 0, 0, 0.7);
}

.access-full {
  background: rgba(52, 199, 89, 0.14);
  color: rgba(0, 0, 0, 0.75);
}

.access-read {
  background: rgba(90, 90, 90, 0.12);
  color: rgba(0, 0, 0, 0.65);
}

.access-none {
  background: rgba(255, 59, 48, 0.12);
  color: rgba(0, 0, 0, 0.55);
}
