/**
 * ============================================================================
 * AG STUDIO PRO - UNIVERSAL WORLD-CLASS DESIGN SYSTEM
 * Inspired by Coohom & top-tier CAD design platforms with AG Smart Design identity
 * ============================================================================
 */

:root {
  --ag-bg-void: #060911;
  --ag-bg-base: #090d16;
  --ag-bg-surface: #0f172a;
  --ag-bg-card: #151f32;
  --ag-bg-hover: #1e293b;
  --ag-bg-active: #24344d;
  --ag-border: rgba(255, 255, 255, 0.08);
  --ag-border-focus: rgba(56, 189, 248, 0.6);
  --ag-border-accent: rgba(2, 132, 199, 0.4);
  --ag-cyan: #38bdf8;
  --ag-cyan-glow: rgba(56, 189, 248, 0.35);
  --ag-blue: #0284c7;
  --ag-cobalt: #2563eb;
  --ag-amber: #f59e0b;
  --ag-emerald: #10b981;
  --ag-rose: #f43f5e;
  --ag-text: #f8fafc;
  --ag-text-muted: #94a3b8;
  --ag-text-dim: #64748b;
  --ag-radius-sm: 6px;
  --ag-radius: 10px;
  --ag-radius-lg: 16px;
  --ag-radius-full: 9999px;
  --ag-shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --ag-shadow: 0 4px 20px rgba(0, 0, 0, 0.45);
  --ag-shadow-lg: 0 10px 35px rgba(0, 0, 0, 0.6);
  --ag-shadow-cyan: 0 0 20px rgba(56, 189, 248, 0.25);
  --ag-font: 'Cairo', system-ui, -apple-system, sans-serif;
}

/* === Global Resets & Typography === */
*, *::before, *::after {
  box-sizing: border-box;
}

body.ag-studio-body {
  margin: 0;
  padding: 0;
  font-family: var(--ag-font);
  background-color: var(--ag-bg-void);
  color: var(--ag-text);
  direction: rtl;
  text-align: right;
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* === Studio Main Grid Layout === */
.ag-studio-workspace {
  display: grid;
  grid-template-columns: 320px 1fr 340px;
  flex: 1;
  height: calc(100vh - 52px);
  min-height: 0;
  position: relative;
  overflow: hidden;
  margin-top: 52px;
}

@media (max-width: 1200px) {
  .ag-studio-workspace {
    grid-template-columns: 280px 1fr 300px;
  }
}

@media (max-width: 900px) {
  .ag-studio-workspace {
    grid-template-columns: 1fr;
    position: relative;
  }
}

/* === Collapsible Sidebars === */
.ag-sidebar {
  background: var(--ag-bg-surface);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 20;
  position: relative;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), width 0.25s ease;
}

.ag-sidebar-left {
  border-left: 1px solid var(--ag-border);
}

.ag-sidebar-right {
  border-right: 1px solid var(--ag-border);
}

.ag-sidebar-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--ag-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
  flex-shrink: 0;
}

.ag-sidebar-title {
  font-size: 13.5px;
  font-weight: 800;
  color: var(--ag-text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.ag-sidebar-title span.badge {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: var(--ag-radius-full);
  background: rgba(56, 189, 248, 0.15);
  color: var(--ag-cyan);
  font-weight: 700;
  border: 1px solid rgba(56, 189, 248, 0.3);
}

.ag-sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.ag-sidebar-content::-webkit-scrollbar {
  width: 5px;
}
.ag-sidebar-content::-webkit-scrollbar-track {
  background: transparent;
}
.ag-sidebar-content::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 4px;
}
.ag-sidebar-content::-webkit-scrollbar-thumb:hover {
  background: rgba(56, 189, 248, 0.3);
}

/* === Segmented Tabs inside Sidebars === */
.ag-segmented-tabs {
  display: flex;
  background: var(--ag-bg-void);
  border: 1px solid var(--ag-border);
  border-radius: var(--ag-radius);
  padding: 3px;
  gap: 2px;
  margin-bottom: 4px;
}

.ag-tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--ag-text-muted);
  font-family: var(--ag-font);
  font-size: 11px;
  font-weight: 700;
  padding: 7px 4px;
  border-radius: calc(var(--ag-radius) - 3px);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.ag-tab-btn:hover {
  color: var(--ag-text);
  background: rgba(255, 255, 255, 0.04);
}

.ag-tab-btn.active {
  background: linear-gradient(135deg, rgba(2, 132, 199, 0.35) 0%, rgba(37, 99, 235, 0.25) 100%);
  color: var(--ag-cyan);
  border: 1px solid rgba(56, 189, 248, 0.4);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* === Visual Catalog Cards Grid === */
.ag-catalog-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.ag-catalog-card {
  background: var(--ag-bg-card);
  border: 1px solid var(--ag-border);
  border-radius: var(--ag-radius);
  padding: 10px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  text-align: right;
}

.ag-catalog-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 2px;
  background: transparent;
  transition: background 0.2s ease;
}

.ag-catalog-card:hover {
  background: var(--ag-bg-hover);
  border-color: var(--ag-border-focus);
  transform: translateY(-2px);
  box-shadow: var(--ag-shadow-cyan);
}

.ag-catalog-card:hover::before {
  background: linear-gradient(90deg, var(--ag-cyan), var(--ag-cobalt));
}

.ag-card-thumb {
  height: 64px;
  background: var(--ag-bg-void);
  border-radius: var(--ag-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  margin-bottom: 8px;
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.ag-card-title {
  font-size: 11.5px;
  font-weight: 800;
  color: var(--ag-text);
  line-height: 1.3;
  margin-bottom: 3px;
}

.ag-card-desc {
  font-size: 9.5px;
  color: var(--ag-text-muted);
  line-height: 1.25;
}

.ag-card-dims {
  font-size: 9px;
  font-family: monospace;
  color: var(--ag-cyan);
  margin-top: 4px;
  font-weight: 700;
  direction: ltr;
  text-align: right;
}

/* === Property Inspector Group Box === */
.ag-inspector-section {
  background: var(--ag-bg-card);
  border: 1px solid var(--ag-border);
  border-radius: var(--ag-radius);
  padding: 12px;
}

.ag-inspector-header {
  font-size: 12px;
  font-weight: 800;
  color: var(--ag-cyan);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--ag-border);
  padding-bottom: 6px;
}

.ag-form-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 8px;
}

.ag-form-row.full {
  grid-template-columns: 1fr;
}

.ag-form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ag-label {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--ag-text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ag-input, .ag-select {
  background: var(--ag-bg-void);
  border: 1px solid var(--ag-border);
  color: var(--ag-text);
  font-family: var(--ag-font);
  font-size: 11.5px;
  font-weight: 700;
  padding: 7px 10px;
  border-radius: var(--ag-radius-sm);
  outline: none;
  transition: all 0.15s ease;
  width: 100%;
}

.ag-input:focus, .ag-select:focus {
  border-color: var(--ag-cyan);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.25);
}

.ag-input[type="number"] {
  font-family: monospace;
  direction: ltr;
  text-align: right;
}

/* === Floating HUD Toolbar on Canvas === */
.ag-canvas-workspace {
  position: relative;
  background: #080d19;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.ag-canvas-viewport {
  flex: 1;
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
}

.ag-floating-top-bar,
.ag-hud-floating-bar {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  background: rgba(15, 23, 42, 0.88);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(56, 189, 248, 0.3);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.55);
  border-radius: var(--ag-radius-full);
  padding: 5px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
}

.ag-floating-btn,
.ag-hud-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--ag-text-muted);
  font-family: var(--ag-font);
  font-size: 11.5px;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: var(--ag-radius-full);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.ag-floating-btn:hover,
.ag-hud-btn:hover {
  color: var(--ag-text);
  background: rgba(255, 255, 255, 0.08);
}

.ag-floating-btn.active,
.ag-hud-btn.active {
  background: linear-gradient(135deg, #0284c7, #2563eb);
  color: #fff;
  border-color: rgba(56, 189, 248, 0.5);
  box-shadow: 0 2px 10px rgba(2, 132, 199, 0.4);
}

.ag-toolbar-divider,
.ag-hud-divider {
  width: 1px;
  height: 18px;
  background: rgba(255, 255, 255, 0.12);
  margin: 0 2px;
}

/* Floating Bottom Status / Quick Inspector Pill */
.ag-floating-bottom-pill {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  background: rgba(9, 13, 22, 0.92);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6);
  border-radius: var(--ag-radius-full);
  padding: 6px 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 11px;
  color: var(--ag-text-muted);
  white-space: nowrap;
}

.ag-pill-stat {
  display: flex;
  align-items: center;
  gap: 6px;
}
.ag-pill-stat strong {
  color: var(--ag-text);
  font-family: monospace;
}

/* === Transform Tool Cluster === */
.ag-transform-cluster {
  display: flex;
  gap: 6px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--ag-border);
  padding: 6px;
  border-radius: var(--ag-radius);
}

.ag-action-btn {
  flex: 1;
  background: var(--ag-bg-void);
  border: 1px solid var(--ag-border);
  color: var(--ag-text);
  font-family: var(--ag-font);
  font-size: 11px;
  font-weight: 700;
  padding: 6px 8px;
  border-radius: var(--ag-radius-sm);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  transition: all 0.15s ease;
}

.ag-action-btn:hover {
  background: var(--ag-bg-hover);
  border-color: var(--ag-cyan);
  color: var(--ag-cyan);
  transform: translateY(-1px);
}

.ag-action-btn.btn-danger:hover {
  border-color: var(--ag-rose);
  color: var(--ag-rose);
}

.ag-action-btn span.icon {
  font-size: 14px;
}

/* === Quick Door / Drawer Angle Slider Pill === */
.ag-door-slider-box {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
}

.ag-range-slider {
  -webkit-appearance: none;
  appearance: none;
  height: 5px;
  background: #1e293b;
  border-radius: 5px;
  outline: none;
  cursor: pointer;
  transition: background 0.2s;
}

.ag-range-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--ag-cyan);
  cursor: pointer;
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.8);
  border: 2px solid #fff;
}

/* === Interactive Canvas View Controls (Top Right Overlay) === */
.ag-view-cube-controls {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 25;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ag-gizmo-btn {
  width: 32px;
  height: 32px;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--ag-text-muted);
  border-radius: var(--ag-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
  transition: all 0.15s ease;
}

.ag-gizmo-btn:hover {
  background: rgba(56, 189, 248, 0.2);
  color: var(--ag-cyan);
  border-color: var(--ag-cyan);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.3);
}

.ag-gizmo-btn.active {
  background: var(--ag-blue);
  color: #fff;
  border-color: var(--ag-cyan);
}
