/* ==========================================================================
   OpenPad — Material 3 Workspace Chrome, Tabs, Toolbar, Modals & OA Header
   ========================================================================== */

*, *::before, *::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: var(--font-sans);
  background: var(--page-bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.app-root {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------- Unified OpenAppsAI Header ---------- */
.oa-header {
  padding: 8px 14px 6px;
  flex-shrink: 0;
}

.oa-nav {
  max-width: 1440px;
  margin: 0 auto;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.oa-brand-group { display: flex; align-items: center; gap: 8px; }
.oa-prism-btn { display: inline-flex; text-decoration: none; border-radius: 10px; }
.oa-logo {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: linear-gradient(135deg, #4f46e5 0%, #06b6d4 52%, #f43f5e 100%);
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 3px;
  padding: 6px;
  flex-shrink: 0;
}
.oa-dot { background: #ffffff; display: block; }
.oa-dot.d1, .oa-dot.d4 { border-radius: 2px; }
.oa-dot.d2, .oa-dot.d3 { border-radius: 50%; opacity: 0.84; }
.oa-divider { width: 1px; height: 20px; background: var(--border); }
.oa-app-link { text-decoration: none; color: inherit; }
.oa-brand-text { display: flex; flex-direction: column; line-height: 1.08; }
.oa-brand-title { font-size: 0.96rem; font-weight: 800; letter-spacing: -0.02em; }
.oa-brand-sub { font-size: 0.67rem; font-weight: 700; color: var(--muted); }

.oa-suite-pills {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px;
  border-radius: 999px;
  background: var(--surface-container);
  border: 1px solid var(--border);
}

.oa-pill {
  padding: 5px 10px;
  border-radius: 999px;
  text-decoration: none;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
  transition: background-color 0.16s, color 0.16s;
}

.oa-pill:hover { color: var(--text); background: var(--surface-container-high); }
.oa-pill.is-active {
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  color: #ffffff;
}

/* Segmented Controls (White/Dark & Code/Split/Preview) */
.m3-segment {
  display: inline-flex;
  align-items: center;
  padding: 3px;
  border-radius: 999px;
  background: var(--surface-container);
  border: 1px solid var(--border);
}

.m3-seg-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: 0.76rem;
  font-weight: 700;
  padding: 5px 11px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 160ms ease, color 160ms ease;
}

.m3-seg-btn.is-active {
  background: var(--accent);
  color: #ffffff;
}

[data-theme="dark"] .m3-seg-btn.is-active {
  color: #0b1220;
}

/* ---------- Main Material 3 Editor Shell ---------- */
.workspace-outer {
  flex: 1;
  min-height: 0;
  padding: 4px 14px 8px;
  display: flex;
  flex-direction: column;
}

.editor-card {
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-radius: 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  position: relative;
}

/* Clean Material 3 Action Toolbar */
.m3-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.m3-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-container);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 650;
  cursor: pointer;
  white-space: nowrap;
  transition: background 150ms ease, transform 120ms ease, border-color 150ms ease;
}

.m3-btn:hover { background: var(--surface-container-high); }
.m3-btn:active { transform: scale(0.96); }
.m3-btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
  transform: none;
}

.m3-btn--danger {
  color: var(--danger);
}

.m3-btn--danger:hover:not(:disabled) {
  background: rgba(220, 38, 38, 0.12);
  border-color: rgba(220, 38, 38, 0.30);
}

.m3-btn--icon {
  width: 32px;
  padding: 0;
  justify-content: center;
}

.m3-btn--tonal {
  background: var(--accent-soft);
  border-color: transparent;
  color: var(--accent-text);
}

.m3-btn--filled {
  background: var(--accent);
  border-color: transparent;
  color: #ffffff;
}

[data-theme="dark"] .m3-btn--filled {
  color: #0b1220;
}

.m3-select {
  height: 32px;
  line-height: 30px;
  padding: 0 28px 0 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background-color: var(--surface-container);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b95a5' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  appearance: none;
  -webkit-appearance: none;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 650;
  outline: none;
  cursor: pointer;
}

/* Sleek VS Code–style Scrollbars */
::-webkit-scrollbar {
  width: 9px;
  height: 9px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(128, 128, 128, 0.28);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: content-box;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(128, 128, 128, 0.48);
  border: 2px solid transparent;
  background-clip: content-box;
}

/* Tools Dropdown Menu */
.menu-wrap { position: relative; }
.m3-menu {
  position: absolute;
  top: 38px;
  right: 0;
  z-index: 40;
  min-width: 215px;
  padding: 6px;
  border-radius: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.m3-menu.is-hidden { display: none; }

.m3-menu-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border: none;
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
}

.m3-menu-item:hover { background: var(--surface-container); }
.m3-menu-sep { height: 1px; background: var(--border); margin: 4px 8px; }

/* ---------- VS Code Multi-Tab Strip ---------- */
.tab-strip {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px 0;
  background: var(--surface-container);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  flex-shrink: 0;
}

.doc-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 12px 12px 0 0;
  border: 1px solid transparent;
  border-bottom: none;
  background: transparent;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 650;
  cursor: pointer;
  white-space: nowrap;
  transition: background 150ms ease, color 150ms ease;
}

.doc-tab:hover { background: var(--surface-container-high); color: var(--text); }
.doc-tab.is-active {
  background: var(--editor-bg);
  color: var(--text);
  border-color: var(--border);
  position: relative;
}

.tab-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

.tab-close {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 6px;
  cursor: pointer;
}

.tab-close:hover { background: var(--surface-container-high); color: var(--text); }

.tab-add-btn {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  margin-bottom: 4px;
}

.tab-add-btn:hover { background: var(--surface-container-high); color: var(--text); }

/* ---------- Find & Replace Bar ---------- */
.find-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--surface-container);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.find-bar.is-hidden { display: none; }

.find-input {
  height: 30px;
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  outline: none;
  min-width: 170px;
}

.find-input:focus { border-color: var(--accent); }

/* ---------- Split Content Area ---------- */
.editor-main {
  flex: 1;
  min-height: 0;
  display: flex;
  overflow: hidden;
}

.editor-main[data-view="code"] .preview-pane { display: none; }
.editor-main[data-view="preview"] .editor-pane { display: none; }

/* Drag & Drop Overlay */
.drop-overlay {
  position: absolute;
  inset: 0;
  z-index: 50;
  background: rgba(37, 99, 235, 0.14);
  backdrop-filter: blur(8px);
  border: 3px dashed var(--accent);
  border-radius: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--accent-text);
  pointer-events: none;
}

.drop-overlay.is-hidden { display: none; }

/* ---------- VS Code Status Bar ---------- */
.status-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 5px 14px;
  background: var(--status-bg);
  color: var(--status-text);
  border-top: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  flex-shrink: 0;
}

.status-group { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }

/* ---------- Compact Footer ---------- */
.oa-footer {
  padding: 6px 16px 8px;
  flex-shrink: 0;
}

.oa-footer-inner {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.76rem;
  color: var(--muted);
}

.oa-footer-links { display: flex; flex-wrap: wrap; gap: 14px; }
.oa-footer-links a { text-decoration: none; color: var(--muted); font-weight: 700; }
.oa-footer-links a:hover { color: var(--accent); }

/* ---------- Material 3 Modals (URL Loader & Cloud Drive/Dropbox) ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(8, 12, 24, 0.45);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-overlay.is-hidden { display: none; }

.modal-card {
  width: min(520px, 100%);
  border-radius: 26px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.modal-field { display: flex; flex-direction: column; gap: 6px; font-size: 0.8rem; font-weight: 700; }
.modal-input {
  width: 100%;
  padding: 10px 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface-container);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.84rem;
  outline: none;
}
.modal-input:focus { border-color: var(--accent); }
.modal-note {
  padding: 10px 12px;
  border-radius: 14px;
  background: var(--surface-container);
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.5;
}

.cloud-tabs { display: flex; gap: 6px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }

.toast {
  position: fixed;
  bottom: 44px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 90;
  padding: 9px 18px;
  border-radius: 999px;
  background: var(--text);
  color: var(--surface);
  font-size: 0.8rem;
  font-weight: 700;
  box-shadow: var(--shadow-md);
}
.toast.is-hidden { display: none; }

@media (max-width: 960px) {
  .oa-suite-pills { display: none; }
}

@media (max-width: 720px) {
  .editor-main[data-view="split"] { flex-direction: column; }
  .preview-pane { border-left: none; border-top: 1px solid var(--border); }
}
