/* Modern Dark Theme with Orange Accents */

:root {
  /* Color Palette */
  --bg-primary: #1a1a1a;
  --bg-secondary: #2a2a2a;
  --bg-tertiary: #1e1e1e;
  --bg-panel: #252525;

  --text-primary: #ffffff;
  --text-secondary: #b0b0b0;
  --text-muted: #888888;

  --accent-orange: #ff8c00;
  --accent-orange-hover: #ff9f1a;
  --accent-orange-dark: #cc7000;

  --border-color: #3a3a3a;
  --border-light: #4a4a4a;

  --input-bg: #2d2d2d;
  --input-border: #404040;

  /* Spacing */
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;

  /* Border Radius */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  height: 100vh;
  width: 100vw;
  background-color: var(--bg-primary);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto",
    sans-serif;
  color: var(--text-primary);
  overflow: hidden;
}

/* App Container */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
}

/* Top Navigation Bar */
.top-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--spacing-md) var(--spacing-lg);
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  height: 60px;
  flex-shrink: 0;
}

.nav-left,
.nav-right {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  flex: 1;
}

.nav-right {
  justify-content: flex-end;
}

.nav-center {
  flex: 1;
  display: flex;
  justify-content: center;
}

.page-title {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: var(--text-primary);
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
  padding: 8px 16px;
  background-color: transparent;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.nav-btn:hover {
  background-color: var(--bg-tertiary);
  border-color: var(--border-light);
  color: var(--text-primary);
}

.save-btn,
.export-btn {
  background-color: var(--accent-orange);
  border-color: var(--accent-orange);
  color: white;
  font-weight: 500;
}

.save-btn:hover,
.export-btn:hover {
  background-color: var(--accent-orange-hover);
  border-color: var(--accent-orange-hover);
}

.username-dropdown {
  position: relative;
}

.username-btn {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
  padding: 8px 12px;
  background-color: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: color 0.2s ease;
  border-radius: var(--radius-md);
}

.username-btn:hover {
  color: var(--text-primary);
  background-color: var(--bg-tertiary);
}

.username-btn svg {
  transition: transform 0.2s ease;
}

.username-btn.active svg {
  transform: rotate(180deg);
}

/* Dropdown Menu */
.dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 240px;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  z-index: 1000;
  animation: dropdownFadeIn 0.2s ease;
}

@keyframes dropdownFadeIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: 12px 16px;
  color: var(--text-secondary);
  font-size: 13px;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  cursor: default;
  transition: all 0.2s ease;
}

.dropdown-item svg {
  flex-shrink: 0;
  color: var(--text-muted);
}

.user-info {
  padding: 16px;
  cursor: default;
}

.user-details {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.user-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.user-role {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: capitalize;
}

.session-info {
  font-size: 12px;
  color: var(--text-muted);
  cursor: default;
}

.session-info svg {
  color: var(--accent-orange);
}

.session-info.warning {
  color: var(--accent-orange);
}

.session-info.warning svg {
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

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

.logout-item {
  color: #ff6b6b;
  cursor: pointer;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
}

.logout-item:hover {
  background-color: rgba(255, 68, 68, 0.1);
  color: #ff4444;
}

.logout-item svg {
  color: #ff6b6b;
}

.logout-item:hover svg {
  color: #ff4444;
}

/* Main Content Area */
.main-content {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Side Panels */
.left-panel,
.right-panel {
  width: 200px;
  background-color: var(--bg-panel);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.right-panel {
  width: 280px;
  border-right: none;
  border-left: 1px solid var(--border-color);
}

.panel-header {
  padding: var(--spacing-md);
  border-bottom: 1px solid var(--border-color);
}

.panel-header h2 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

/* Search Box */
.search-box {
  padding: var(--spacing-xs);
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
}

.search-input {
  flex: 1;
  padding: 8px 12px;
  background-color: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
}

.search-input:focus {
  border-color: var(--border-light);
}

.search-button {
  padding: 8px;
  background-color: var(--accent-orange);
  color: var(--text-primary);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background-color 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 32px;
  height: 32px;
}

.search-button svg {
  stroke: currentColor;
}

.search-button:hover {
  background-color: var(--accent-orange-hover);
}

.search-button:active {
  background-color: var(--accent-orange-dark);
}

/* Asset Grid */
.asset-grid {
  flex: 1;
  padding: var(--spacing-md);
  overflow-y: auto;
}

.empty-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  font-size: 13px;
}

/* Center Panel */
.center-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-tertiary);
  overflow: hidden;
}

/* Prompt Section */
.prompt-section {
  padding: var(--spacing-lg);
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: flex-start;
  gap: var(--spacing-md);
}

.prompt-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  padding-top: 8px;
}

.prompt-input-container {
  flex: 1;
  position: relative;
}

.prompt-input {
  width: 100%;
  padding: 10px 12px;
  background-color: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  outline: none;
  min-height: 60px;
}

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

.prompt-counter {
  position: absolute;
  bottom: 8px;
  right: 12px;
  font-size: 11px;
  color: var(--text-muted);
}

.generate-btn {
  padding: 10px 32px;
  background-color: var(--accent-orange);
  border: none;
  border-radius: var(--radius-md);
  color: white;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s ease;
  white-space: nowrap;
  margin-top: 6px;
}

.generate-btn:hover {
  background-color: var(--accent-orange-hover);
}

.generate-btn:active {
  background-color: var(--accent-orange-dark);
}

/* Viewport Section */
.viewport-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.pixel-stream-container {
  flex: 1;
  background-color: #0a0a0a;
  position: relative;
  overflow: hidden;
}

/* Viewport Controls */
.viewport-controls {
  display: flex;
  gap: var(--spacing-lg);
  padding: var(--spacing-md) var(--spacing-lg);
  background-color: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
}

.control-group {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
}

.control-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  min-width: 60px;
}

.control-inputs {
  display: flex;
  gap: var(--spacing-sm);
}

.input-group {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
}

.input-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
}

.control-input {
  width: 60px;
  padding: 6px 8px;
  background-color: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  text-align: center;
  outline: none;
}

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

/* Environment Controls */
.environment-controls {
  display: flex;
  gap: var(--spacing-xl);
  padding: var(--spacing-md) var(--spacing-lg);
  background-color: var(--bg-panel);
  border-top: 1px solid var(--border-color);
}

.env-control {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  flex: 1;
}

.env-select {
  flex: 1;
  padding: 6px 10px;
  background-color: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
}

.env-select:focus {
  border-color: var(--accent-orange);
}

/* Sliders */
.slider-group {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  flex: 1;
}

.slider-label {
  font-size: 12px;
  color: var(--text-muted);
  min-width: 45px;
}

.slider {
  flex: 1;
  height: 4px;
  background: var(--input-border);
  border-radius: 2px;
  outline: none;
  -webkit-appearance: none;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  background: var(--text-secondary);
  cursor: pointer;
  border-radius: 50%;
  transition: background 0.2s ease;
}

.slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  background: var(--text-secondary);
  cursor: pointer;
  border-radius: 50%;
  border: none;
  transition: background 0.2s ease;
}

.orange-slider::-webkit-slider-thumb {
  background: var(--accent-orange);
}

.orange-slider::-moz-range-thumb {
  background: var(--accent-orange);
}

.orange-slider::-webkit-slider-thumb:hover {
  background: var(--accent-orange-hover);
}

.orange-slider::-moz-range-thumb:hover {
  background: var(--accent-orange-hover);
}

.slider-value {
  font-size: 13px;
  color: var(--text-primary);
  min-width: 30px;
  text-align: right;
}

/* Unit Preview */
.unit-preview {
  flex: 1;
  padding: var(--spacing-md);
  overflow-y: auto;
}

/* Unit Card Styles */
.unit-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: var(--spacing-md);
  margin-bottom: var(--spacing-md);
  transition: all 0.2s ease;
  user-select: none;
  touch-action: none;
}

.unit-card:hover {
  border-color: var(--primary-color);
  box-shadow: 0 2px 8px rgba(0, 170, 255, 0.2);
  transform: translateY(-2px);
}

.unit-card:active {
  transform: scale(0.98);
}

.unit-card.dragging {
  opacity: 0.4;
  cursor: grabbing !important;
}

.unit-card.selected {
  border-color: var(--primary-color);
  background: rgba(0, 170, 255, 0.1);
}

.unit-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--spacing-sm);
}

.unit-header h3 {
  margin: 0;
  font-size: 14px;
  color: var(--text-primary);
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.unit-id {
  font-size: 11px;
  color: var(--text-secondary);
  background: rgba(0, 170, 255, 0.2);
  padding: 2px 8px;
  border-radius: 4px;
}

.unit-info {
  margin: var(--spacing-sm) 0;
  font-size: 11px;
  color: var(--text-secondary);
}

.unit-info p {
  margin: 4px 0;
  word-break: break-all;
}

.unit-info strong {
  color: var(--text-primary);
}

.unit-actions {
  display: flex;
  gap: var(--spacing-sm);
  margin-top: var(--spacing-sm);
}

.unit-actions button {
  flex: 1;
  padding: 6px 12px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

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

.btn-select:hover {
  background: #0099dd;
}

.btn-delete {
  background: #cc3333;
  color: white;
}

.btn-delete:hover {
  background: #dd4444;
}

.delete-btn {
  position: absolute;
  bottom: var(--spacing-md);
  right: var(--spacing-md);
  width: 40px;
  height: 40px;
  background-color: #cc3333;
  border: none;
  border-radius: var(--radius-md);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s ease;
}

.delete-btn:hover {
  background-color: #dd4444;
}

.right-panel {
  position: relative;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-panel);
}

::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #5a5a5a;
}

/* Responsive Design */
@media (max-width: 1200px) {
  .left-panel,
  .right-panel {
    width: 180px;
  }

  .right-panel {
    width: 240px;
  }

  .viewport-controls {
    flex-wrap: wrap;
  }
}

@media (max-width: 768px) {
  .top-nav {
    flex-direction: column;
    height: auto;
    padding: var(--spacing-sm);
  }

  .nav-left,
  .nav-center,
  .nav-right {
    width: 100%;
    justify-content: center;
    margin-bottom: var(--spacing-sm);
  }

  .left-panel,
  .right-panel {
    display: none;
  }

  .environment-controls {
    flex-direction: column;
  }
}

/* Pixel Streaming Specific Styles */
#playercontainer {
  width: 100%;
  height: 100%;
  position: relative;
  transition: box-shadow 0.3s ease;
}

#playercontainer.drag-over {
  box-shadow: inset 0 0 0 4px var(--accent-orange);
}

#playercontainer.drag-over::before {
  content: "Drop unit here";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(255, 140, 0, 0.9);
  color: white;
  padding: 16px 32px;
  border-radius: 8px;
  font-size: 18px;
  font-weight: 600;
  z-index: 1000;
  pointer-events: none;
  animation: dropHint 0.6s ease-in-out infinite alternate;
}

@keyframes dropHint {
  from {
    transform: translate(-50%, -50%) scale(1);
  }
  to {
    transform: translate(-50%, -55%) scale(1.05);
  }
}

/* Make sure pixel streaming video fills the container */
#playercontainer video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background-color: #000;
}

/* Generic Confirmation Dialog Styles */
.dialog-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10000;
  backdrop-filter: blur(4px);
}

.dialog-box {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  min-width: 400px;
  max-width: 500px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  animation: dialogSlideIn 0.2s ease-out;
}

@keyframes dialogSlideIn {
  from {
    opacity: 0;
    transform: translateY(-20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.dialog-header {
  padding: var(--spacing-lg);
  border-bottom: 1px solid var(--border-color);
}

.dialog-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.dialog-body {
  padding: var(--spacing-lg);
}

.dialog-body p {
  margin: 0;
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.dialog-footer {
  padding: var(--spacing-md) var(--spacing-lg);
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: var(--spacing-md);
}

.dialog-btn {
  padding: 10px 24px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.dialog-btn-cancel {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-light);
}

.dialog-btn-cancel:hover {
  background-color: var(--bg-panel);
  border-color: var(--border-color);
}

.dialog-btn-confirm {
  background-color: var(--accent-orange);
  color: var(--text-primary);
}

.dialog-btn-confirm:hover {
  background-color: var(--accent-orange-hover);
}

.dialog-btn-confirm.danger {
  background-color: #cc3333;
}

.dialog-btn-confirm.danger:hover {
  background-color: #dd4444;
}

@media (max-width: 600px) {
  .dialog-box {
    min-width: 90%;
    margin: 0 var(--spacing-md);
  }
}

/* Hide any default UI from pixel streaming if needed */
#playercontainer .hiddenState {
  display: none !important;
}

/* Asset Item Wrapper with Download Icon */
.asset-item-wrapper {
  position: relative;
  padding: 8px;
  background: #2d2d2d;
  border: 1px solid #404040;
  border-radius: 4px;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s;
  margin-bottom: 8px;
  overflow: hidden;
}

.asset-item-wrapper:hover {
  border-color: #ff8c00;
  background: #353535;
}

.asset-item-wrapper img {
  width: 100%;
  height: 80px;
  object-fit: cover;
  border-radius: 4px;
  background: #1a1a1a;
  transition: filter 0.3s ease;
}

.asset-item-wrapper .asset-name {
  margin-top: 8px;
  font-size: 12px;
  color: #b0b0b0;
}

.asset-item-wrapper .download-overlay {
  position: absolute;
  top: 8px;
  left: 8px;
  right: 8px;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  opacity: 0;
  transition: opacity 0.3s ease;
  border-radius: 4px;
  pointer-events: none;
}

.asset-item-wrapper:hover .download-overlay {
  opacity: 1;
  pointer-events: auto;
}

.download-icon-btn {
  width: 48px;
  height: 48px;
  background: var(--accent-orange);
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  color: white;
}

.download-icon-btn:hover {
  background: var(--accent-orange-hover);
  transform: scale(1.1);
}

.download-icon-btn:active {
  background: var(--accent-orange-dark);
  transform: scale(0.95);
}

.download-icon-btn svg {
  width: 24px;
  height: 24px;
}

/* Asset downloading state */
.asset-item-wrapper.downloading {
  opacity: 0.7;
  pointer-events: none;
}

.asset-item-wrapper.downloading .download-overlay {
  opacity: 1 !important;
  pointer-events: none !important;
}

.asset-item-wrapper.downloading .download-icon-btn {
  background: #666;
  cursor: not-allowed;
}

/* Spin animation for loading */
@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* Asset cleared state */
.asset-item-wrapper.downloaded img {
  filter: blur(0) !important;
}

.asset-item-wrapper.downloaded .download-overlay {
  display: none !important;
}

.asset-item-wrapper.downloaded {
  cursor: grab;
}

.asset-item-wrapper.downloaded:active {
  cursor: grabbing;
}

/* Notification animations */
@keyframes slideIn {
  from {
    transform: translateX(400px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideOut {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(400px);
    opacity: 0;
  }
}
