/* ===================================
   Form Design Enhancer - Main Styles
   =================================== */

:root {
  --bg: #05070d;
  --panel: rgba(10, 20, 40, 0.75);
  --accent: #00b2ff;
  --muted: #bfeaff;
  --glass: rgba(255, 255, 255, 0.03);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Rajdhani", sans-serif;
  background: var(--bg);
  color: #fff;
  overflow-x: hidden;
}

/* ===================================
   Background Layers
   =================================== */

.grid-bg,
.gradient-overlay,
.scanlines {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

.grid-bg {
  background: linear-gradient(rgba(0, 180, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 180, 255, 0.03) 1px, transparent 1px);
  background-size: 50px 50px;
}

.gradient-overlay {
  background: radial-gradient(
    ellipse at center,
    transparent 0%,
    rgba(5, 7, 13, 0.8) 100%
  );
}

/* ===================================
   App Layout - FIXED
   =================================== */

.app-wrapper {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 100vh;
  padding: 20px;
  position: relative;
  z-index: 1;
}

.app-container {
  display: flex;
  gap: 0;
  max-width: 1400px;
  width: 100%;
  align-items: stretch;
  height: auto;
}

/* ===================================
   Sidebar Styles - FIXED
   =================================== */

.sidebar {
  width: 300px;
  background: linear-gradient(
    180deg,
    rgba(10, 20, 40, 0.95),
    rgba(8, 12, 25, 0.95)
  );
  border: 1px solid rgba(0, 180, 255, 0.3);
  border-radius: 16px 0 0 16px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  backdrop-filter: blur(8px);
  box-shadow: -5px 0 20px rgba(0, 180, 255, 0.15);
  flex-shrink: 0;
  position: relative;
  max-height: none;
  overflow-y: auto;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(0, 180, 255, 0.2);
}

.sidebar-header h1 {
  font-family: "Orbitron", sans-serif;
  font-size: 1rem;
  letter-spacing: 1px;
  color: var(--accent);
  text-shadow: 0 0 8px var(--accent);
}

.icon-btn {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--muted);
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.3s;
}

.icon-btn:hover {
  background: rgba(0, 180, 255, 0.1);
  border-color: var(--accent);
  transform: scale(1.1);
}

.sidebar-section {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(0, 180, 255, 0.15);
  border-radius: 10px;
  padding: 14px;
}

.sidebar-section h2 {
  font-size: 0.9rem;
  color: #00eaff;
  font-weight: 600;
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sidebar-input input[type="file"] {
  width: 100%;
  background: rgba(0, 0, 0, 0.4);
  border: 1px dashed rgba(0, 180, 255, 0.5);
  border-radius: 6px;
  padding: 8px;
  color: #00b2ff;
  font-size: 0.85rem;
  margin-bottom: 10px;
}

/* ===================================
   History List
   =================================== */

.history-list {
  max-height: 250px;
  overflow-y: auto;
  padding: 6px;
}

.history-item {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(0, 178, 255, 0.08);
  padding: 10px;
  margin-bottom: 8px;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-meta {
  flex: 1;
}

.history-title {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--accent);
}

.history-time {
  font-size: 0.75rem;
  opacity: 0.7;
  color: var(--muted);
}

.history-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* ===================================
   Buttons
   =================================== */

.small-btn,
.tiny-btn {
  background: linear-gradient(90deg, var(--accent), #0066ff);
  color: #fff;
  border: none;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  font-family: "Orbitron", sans-serif;
  font-weight: 600;
  transition: all 0.3s;
}

.small-btn:hover,
.tiny-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 0 15px rgba(0, 180, 255, 0.6);
}

.tiny-btn {
  padding: 5px 8px;
  font-size: 0.75rem;
}

.small-btn.full {
  width: 100%;
}

.btn {
  background: linear-gradient(90deg, var(--accent), #0066ff);
  color: #fff;
  border: none;
  padding: 12px 20px;
  border-radius: 24px;
  cursor: pointer;
  font-family: "Orbitron", sans-serif;
  font-weight: 600;
  transition: all 0.3s;
}

.btn:hover {
  transform: scale(1.05);
  box-shadow: 0 0 20px rgba(0, 180, 255, 0.7);
}

.btn.alt {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

/* ===================================
   Sidebar Footer
   =================================== */

.sidebar-footer {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid rgba(0, 180, 255, 0.2);
  font-size: 0.75rem;
  opacity: 0.8;
  color: var(--muted);
}

/* ===================================
   Main Content Area - FIXED
   =================================== */

.main {
  flex: 1;
  background: var(--panel);
  border: 1px solid rgba(0, 180, 255, 0.3);
  border-left: none;
  border-radius: 0 16px 16px 0;
  padding: 30px;
  backdrop-filter: blur(8px);
  box-shadow: 5px 0 20px rgba(0, 180, 255, 0.15);
  display: flex;
  flex-direction: column;
}

.main h2 {
  font-family: "Orbitron", sans-serif;
  font-size: 1.8rem;
  color: #00b2ff;
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 24px;
  text-shadow: 0 0 10px #00b2ff;
  text-align: center;
}

/* ===================================
   Editor Layout
   =================================== */

.top-row {
  display: grid;
  grid-template-columns: 1fr 420px;
  gap: 20px;
  margin-bottom: 20px;
  flex: 1;
}

.editor-panel,
.preview-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

label.muted {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
}

#userInput,
#designPrompt {
  width: 100%;
  font-family: monospace;
  font-size: 0.92rem;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid rgba(0, 180, 255, 0.2);
  background: rgba(0, 0, 0, 0.4);
  color: #e6fbff;
  resize: vertical;
  transition: all 0.3s;
}

#userInput:focus,
#designPrompt:focus {
  border-color: var(--accent);
  box-shadow: 0 0 12px rgba(0, 180, 255, 0.4);
  outline: none;
}

#userInput {
  min-height: 200px;
  flex: 1;
}

#designPrompt {
  min-height: 80px;
}

.editor-actions {
  display: flex;
  gap: 10px;
  margin-top: auto;
}

/* ===================================
   Preview Panel
   =================================== */

#previewFrame {
  flex: 1;
  width: 100%;
  border-radius: 8px;
  border: 1px solid rgba(0, 180, 255, 0.2);
  background: #fff;
  min-height: 300px;
}

.response-box {
  min-height: 80px;
  max-height: 150px;
  overflow: auto;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 8px;
  padding: 12px;
  border: 1px solid rgba(0, 180, 255, 0.15);
  color: #bff8ff;
  font-family: monospace;
  font-size: 0.85rem;
  white-space: pre-wrap;
}

/* ===================================
   Bottom Row - Code & Guide
   =================================== */

.bottom-row {
  display: flex;
  gap: 20px;
}

.code-box {
  flex: 1;
  background: rgba(0, 0, 0, 0.5);
  padding: 16px;
  border-radius: 10px;
  border: 1px solid rgba(0, 180, 255, 0.2);
  max-height: 350px;
  overflow-y: auto;
}

.code-box pre {
  white-space: pre-wrap;
  font-family: monospace;
  font-size: 0.9rem;
  color: #aef0ff;
  margin-bottom: 12px;
}

.code-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.guide-panel {
  width: 320px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 10px;
  padding: 16px;
  border: 1px solid rgba(0, 180, 255, 0.15);
  max-height: 350px;
  overflow-y: auto;
}

.guide-panel h3 {
  color: var(--accent);
  font-family: "Orbitron", sans-serif;
  margin-bottom: 12px;
  font-size: 1.1rem;
}

.guide-content {
  font-size: 0.9rem;
  color: #c7f6ff;
  white-space: pre-wrap;
  line-height: 1.5;
}

/* ===================================
   Loading Animation
   =================================== */

.loading-container {
  display: flex;
  align-items: center;
  gap: 10px;
}

.loading-circle {
  width: 24px;
  height: 24px;
  border: 3px solid rgba(0, 180, 255, 0.3);
  border-top: 3px solid #00b4ff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  flex-shrink: 0;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.loading-message {
  color: var(--accent);
}

/* ===================================
   Mobile Toggle Button
   =================================== */

.mobile-toggle {
  display: none;
  position: fixed;
  top: 15px;
  left: 15px;
  z-index: 100;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 50%;
  width: 45px;
  height: 45px;
  font-size: 20px;
  cursor: pointer;
  box-shadow: 0 2px 15px rgba(0, 178, 255, 0.5);
  align-items: center;
  justify-content: center;
  line-height: 1;
  padding: 0;
}

.mobile-toggle:hover {
  background: #00eaff;
  transform: scale(1.05);
  box-shadow: 0 4px 20px rgba(0, 178, 255, 0.7);
}

.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  z-index: 98;
}

.sidebar-overlay.active {
  display: block;
}

.sidebar-close {
  display: none;
}

/* ===================================
   Scrollbar Styling
   =================================== */

.sidebar::-webkit-scrollbar,
.history-list::-webkit-scrollbar,
.response-box::-webkit-scrollbar,
.code-box::-webkit-scrollbar,
.guide-panel::-webkit-scrollbar {
  width: 6px;
}

.sidebar::-webkit-scrollbar-thumb,
.history-list::-webkit-scrollbar-thumb,
.response-box::-webkit-scrollbar-thumb,
.code-box::-webkit-scrollbar-thumb,
.guide-panel::-webkit-scrollbar-thumb {
  background: #00b4ff;
  border-radius: 8px;
}

.sidebar::-webkit-scrollbar-track,
.history-list::-webkit-scrollbar-track,
.response-box::-webkit-scrollbar-track,
.code-box::-webkit-scrollbar-track,
.guide-panel::-webkit-scrollbar-track {
  background: transparent;
}

/* ===================================
   Utility Classes
   =================================== */

.muted {
  color: #99d9ff;
  font-size: 0.9rem;
}

/* ===================================
   RESPONSIVE DESIGN
   =================================== */

@media (max-width: 1200px) {
  .top-row {
    grid-template-columns: 1fr 360px;
  }

  .guide-panel {
    width: 280px;
  }
}

@media (max-width: 900px) {
  .app-wrapper {
    padding: 20px 10px;
  }

  .app-container {
    flex-direction: column;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 85%;
    max-width: 320px;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    z-index: 99;
  }

  .sidebar.active {
    transform: translateX(0);
  }

  .main {
    border-radius: 16px;
    border-left: 1px solid rgba(0, 180, 255, 0.3);
  }

  .mobile-toggle {
    display: flex;
  }

  .sidebar-close {
    display: block;
    margin-top: auto;
  }

  .top-row {
    grid-template-columns: 1fr;
  }

  .guide-panel {
    display: none;
  }
}

@media (max-width: 600px) {
  .main h2 {
    font-size: 1.3rem;
  }

  .bottom-row {
    flex-direction: column;
  }

  .code-actions {
    justify-content: center;
  }

  .main {
    padding: 20px;
  }

  .app-wrapper {
    padding: 15px 10px;
  }
}

@media (max-width: 480px) {
  .sidebar-header h1 {
    font-size: 0.9rem;
  }

  .main h2 {
    font-size: 1.1rem;
    letter-spacing: 1px;
  }

  .btn {
    padding: 10px 16px;
    font-size: 0.85rem;
  }

  #userInput {
    min-height: 150px;
  }

  #previewFrame {
    min-height: 250px;
  }
}