/* PWB Editor Styles */

:root {
  --pwb-editor-bg: #1e293b;
  --pwb-editor-text: #f8fafc;
  --pwb-editor-border: #334155;
  --pwb-editor-primary: #3b82f6;
  --pwb-editor-toolbar-height: 50px;
  --pwb-editor-panel-height: 200px;
}

body.pwb-editor-body {
  margin: 0;
  padding: 0;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #0f172a;
}

/* Main Area - takes full width, stacks vertically */
.pwb-editor-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  position: relative;
}

.pwb-editor-toolbar {
  height: var(--pwb-editor-toolbar-height);
  background: var(--pwb-editor-bg);
  border-bottom: 1px solid var(--pwb-editor-border);
  display: flex;
  align-items: center;
  padding: 0 1rem;
  justify-content: space-between;
  flex-shrink: 0;
}

.pwb-editor-logo {
  color: var(--pwb-editor-text);
  font-weight: 600;
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.pwb-editor-center {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex: 1;
  justify-content: center;
}

.pwb-editor-address-bar {
  background: rgba(255,255,255,0.1);
  padding: 0.4rem 1rem;
  border-radius: 20px;
  border: 1px solid var(--pwb-editor-border);
  font-size: 0.85rem;
  color: #94a3b8;
  flex: 1;
  max-width: 400px;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Language Selector */
.pwb-language-selector {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: #94a3b8;
}

.pwb-language-selector label {
  font-size: 0.9rem;
}

.pwb-select {
  background: rgba(255,255,255,0.1);
  border: 1px solid var(--pwb-editor-border);
  color: var(--pwb-editor-text);
  padding: 0.3rem 0.6rem;
  border-radius: 4px;
  font-size: 0.85rem;
  cursor: pointer;
}

.pwb-select:focus {
  outline: none;
  border-color: var(--pwb-editor-primary);
}

.pwb-select option {
  background: var(--pwb-editor-bg);
  color: var(--pwb-editor-text);
}

.pwb-btn-exit {
  color: #ef4444;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.pwb-btn-exit:hover {
  color: #dc2626;
}

.pwb-iframe-container {
  flex: 1;
  background: #e2e8f0;
  padding: 0;
  overflow: hidden;
  min-height: 0;
}

iframe#pwb-site-frame {
  width: 100%;
  height: 100%;
  border: none;
  background: white;
}

/* Bottom Panel */
.pwb-editor-panel {
  height: var(--pwb-editor-panel-height);
  min-height: 44px;
  max-height: 70vh;
  background: var(--pwb-editor-bg);
  color: var(--pwb-editor-text);
  border-top: 1px solid var(--pwb-editor-border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.pwb-editor-panel.pwb-panel-resizing {
  transition: none;
  user-select: none;
}

/* Resize Handle */
.pwb-panel-resize-handle {
  height: 12px;
  background: var(--pwb-editor-border);
  cursor: ns-resize;
  position: relative;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pwb-panel-resize-handle::before {
  content: '';
  width: 60px;
  height: 4px;
  background: var(--pwb-editor-border);
  border-radius: 2px;
  transition: background 0.2s;
}

.pwb-panel-resize-handle:hover::before,
.pwb-panel-resize-handle:active::before {
  background: var(--pwb-editor-primary);
}

.pwb-editor-panel.pwb-panel-collapsed {
  height: 44px;
}

.pwb-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--pwb-editor-border);
  flex-shrink: 0;
}

.pwb-panel-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.pwb-panel-header .pwb-language-selector {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.pwb-panel-header .pwb-language-selector label {
  color: #94a3b8;
  font-size: 0.85rem;
}

.pwb-panel-header .pwb-select {
  background: #1e293b;
  border: 1px solid var(--pwb-editor-border);
  color: var(--pwb-editor-text);
  padding: 0.3rem 0.5rem;
  border-radius: 4px;
  font-size: 0.85rem;
  cursor: pointer;
}

.pwb-panel-header .pwb-select:focus {
  outline: none;
  border-color: var(--pwb-editor-primary);
}

.pwb-panel-title {
  font-weight: 600;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.pwb-panel-toggle {
  background: transparent;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  transition: all 0.2s;
}

.pwb-panel-toggle:hover {
  background: rgba(255,255,255,0.1);
  color: var(--pwb-editor-text);
}

.pwb-panel-content {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
}

.pwb-panel-collapsed .pwb-panel-content {
  display: none;
}

.pwb-panel-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #64748b;
  text-align: center;
}

.pwb-panel-placeholder i {
  font-size: 2rem;
  margin-bottom: 0.5rem;
  opacity: 0.5;
}

.pwb-panel-placeholder p {
  margin: 0;
  font-size: 0.9rem;
}

/* Utilities */
.pwb-btn {
  border: none;
  padding: 0.6rem 1rem;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 600;
  font-family: inherit;
}

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

.pwb-btn-primary:hover {
  background: #2563eb;
}

.pwb-btn-block {
  display: block;
  width: 100%;
}

.pwb-muted {
  color: #94a3b8;
  font-size: 0.9rem;
}

.pwb-alert-info {
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.2);
  color: #60a5fa;
  padding: 0.8rem;
  border-radius: 4px;
  font-size: 0.9rem;
  display: flex;
  gap: 0.5rem;
  align-items: start;
}

/* Form Styles */
.pwb-editor-form {
  margin-top: 1rem;
}

.pwb-form-section {
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--pwb-editor-border);
}

.pwb-form-section:last-of-type {
  border-bottom: none;
}

.pwb-form-section h4 {
  margin: 0 0 1rem 0;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #94a3b8;
}

.pwb-form-group {
  margin-bottom: 1rem;
}

.pwb-form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
  font-weight: 500;
}

.pwb-form-group input[type="text"],
.pwb-form-group input[type="email"],
.pwb-form-group textarea,
.pwb-form-group select {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--pwb-editor-border);
  border-radius: 4px;
  background: #0f172a;
  color: var(--pwb-editor-text);
  font-size: 0.9rem;
  box-sizing: border-box;
}

.pwb-form-group input:focus,
.pwb-form-group textarea:focus,
.pwb-form-group select:focus {
  outline: none;
  border-color: var(--pwb-editor-primary);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

/* Color Input */
.pwb-color-input {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.pwb-color-input input[type="color"] {
  width: 40px;
  height: 36px;
  padding: 2px;
  border: 1px solid var(--pwb-editor-border);
  border-radius: 4px;
  cursor: pointer;
  background: transparent;
}

.pwb-color-input input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 2px;
}

.pwb-color-input input[type="color"]::-webkit-color-swatch {
  border-radius: 2px;
  border: none;
}

.pwb-color-input .pwb-color-text {
  flex: 1;
  text-transform: uppercase;
  font-family: 'Monaco', 'Consolas', monospace;
  font-size: 0.85rem;
}

.pwb-help-text {
  display: block;
  margin-top: 0.3rem;
  font-size: 0.8rem;
  color: #64748b;
}

/* Button styles */
.pwb-btn-secondary {
  background: transparent;
  border: 1px solid var(--pwb-editor-border);
  color: #94a3b8;
}

.pwb-btn-secondary:hover {
  background: rgba(255,255,255,0.05);
  color: var(--pwb-editor-text);
}

.pwb-form-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 1.5rem;
}

.pwb-form-actions .pwb-btn {
  padding: 0.75rem 1rem;
}

/* Notification */
.pwb-notification {
  position: fixed;
  bottom: 20px;
  right: 20px;
  padding: 1rem 1.5rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 9999;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.pwb-notification-visible {
  transform: translateY(0);
  opacity: 1;
}

.pwb-notification-success {
  background: #059669;
  color: white;
}

.pwb-notification-error {
  background: #dc2626;
  color: white;
}

/* Footer text */
.pwb-footer-text {
  font-size: 0.8rem;
  color: #64748b;
}

/* Spacing utilities */
.pwb-mt-lg {
  margin-top: 1.5rem;
}

/* Loading state */
.pwb-loading {
  text-align: center;
  padding: 2rem;
  color: #94a3b8;
}

.pwb-error {
  text-align: center;
  padding: 2rem;
  color: #ef4444;
}

/* Image Picker Modal */
.pwb-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 10000;
  align-items: center;
  justify-content: center;
}

.pwb-modal.pwb-modal-open {
  display: flex;
}

.pwb-modal-content {
  background: var(--pwb-editor-bg);
  border-radius: 8px;
  width: 90%;
  max-width: 800px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.pwb-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--pwb-editor-border);
}

.pwb-modal-header h3 {
  margin: 0;
  color: var(--pwb-editor-text);
  font-size: 1.1rem;
}

.pwb-modal-close {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.pwb-modal-close:hover {
  color: var(--pwb-editor-text);
}

.pwb-modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
}

.pwb-image-upload-section {
  margin-bottom: 1.5rem;
  text-align: center;
}

.pwb-upload-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--pwb-editor-primary);
  color: white;
  padding: 0.75rem 1.5rem;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
  transition: background 0.2s;
}

.pwb-upload-btn:hover {
  background: #2563eb;
}

.pwb-image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 1rem;
}

.pwb-image-item {
  aspect-ratio: 1;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.2s;
  position: relative;
}

.pwb-image-item:hover {
  border-color: var(--pwb-editor-primary);
  transform: scale(1.05);
}

.pwb-image-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.pwb-image-type {
  position: absolute;
  bottom: 4px;
  left: 4px;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  font-size: 0.65rem;
  padding: 2px 6px;
  border-radius: 3px;
  text-transform: capitalize;
}

/* Image input with picker button */
.pwb-image-input-group {
  display: flex;
  gap: 0.5rem;
}

.pwb-image-input-group input {
  flex: 1;
}

.pwb-image-picker-btn {
  background: var(--pwb-editor-primary);
  color: white;
  border: none;
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
}

.pwb-image-picker-btn:hover {
  background: #2563eb;
}

.pwb-image-preview {
  margin-top: 0.5rem;
  max-width: 200px;
  border-radius: 4px;
  overflow: hidden;
}

.pwb-image-preview img {
  width: 100%;
  height: auto;
  display: block;
}
