/* Global Design System variables */
:root {
  --bg-app: #08060f;
  --text-primary: #f3f1f9;
  --text-secondary: #a29db7;
  --card-bg: rgba(18, 14, 34, 0.45);
  --card-border: rgba(255, 255, 255, 0.08);
  --accent: #d83b7f;
  --accent-glow: rgba(216, 59, 127, 0.35);
  --primary: #6c46f3;
  --primary-glow: rgba(108, 70, 243, 0.35);
  --danger: #ff4a5a;
  --success: #10b981;
  --font-sans: 'Outfit', sans-serif;
  --font-mono: 'Space Mono', monospace;
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 6px;
}

/* Reset and base styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-app);
  color: var(--text-primary);
  font-family: var(--font-sans);
  overflow-x: hidden;
  min-height: 100vh;
  position: relative;
}

/* Dynamic glow blobs */
.bg-glow {
  position: fixed;
  width: 45vw;
  height: 45vw;
  border-radius: 50%;
  filter: blur(140px);
  z-index: -1;
  opacity: 0.25;
  pointer-events: none;
}

.blob-1 {
  background: radial-gradient(circle, var(--primary) 0%, rgba(0,0,0,0) 70%);
  top: -10vw;
  left: -10vw;
}

.blob-2 {
  background: radial-gradient(circle, var(--accent) 0%, rgba(0,0,0,0) 70%);
  bottom: -15vw;
  right: -10vw;
}

/* Base structural layout */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px;
}

/* App Header styling */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--card-border);
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  font-size: 24px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--primary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logo-text {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 2px;
}

.logo-badge {
  background: rgba(216, 59, 127, 0.15);
  color: var(--accent);
  border: 1px solid rgba(216, 59, 127, 0.3);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 12px;
  letter-spacing: 1px;
}

/* Workspace main content */
.app-content {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 24px;
  flex: 1;
  min-height: 0;
}

/* Glassmorphism Cards */
.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  display: flex;
  flex-direction: column;
}

/* Sidebar and List styling */
.sidebar {
  min-height: 0;
}

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

.templates-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  flex: 1;
  padding-right: 4px;
}

/* Templates list custom scrollbar */
.templates-list::-webkit-scrollbar {
  width: 6px;
}

.templates-list::-webkit-scrollbar-thumb {
  background: var(--card-border);
  border-radius: 3px;
}

.list-placeholder {
  color: var(--text-secondary);
  font-size: 14px;
  text-align: center;
  padding: 40px 0;
}

.template-item {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: 16px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.template-item:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.1);
  transform: translateY(-2px);
}

.template-item.active {
  background: rgba(108, 70, 243, 0.15);
  border-color: var(--primary);
  box-shadow: 0 0 16px rgba(108, 70, 243, 0.25);
}

.template-item-name {
  font-weight: 600;
  font-size: 15px;
  color: var(--text-primary);
}

.template-item-desc {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Workspace Panel */
.workspace {
  min-height: 0;
  position: relative;
  overflow-y: auto;
}

.workspace-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  max-width: 460px;
  margin: 0 auto;
}

.empty-icon {
  font-size: 64px;
  margin-bottom: 20px;
  opacity: 0.6;
}

.workspace-empty h2 {
  font-size: 22px;
  font-weight: 600;
  margin-bottom: 10px;
}

.workspace-empty p {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.workspace-active {
  display: flex;
  flex-direction: column;
  height: 100%;
  gap: 20px;
}

.workspace-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.active-title {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 6px;
}

.active-description {
  font-size: 14px;
  color: var(--text-secondary);
}

.divider {
  height: 1px;
  background: var(--card-border);
}

.field-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.monospace {
  font-family: var(--font-mono);
  font-size: 13px;
}

.code-block {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 16px;
  word-break: break-all;
  white-space: pre-wrap;
  line-height: 1.6;
  max-height: 200px;
  overflow-y: auto;
}

/* Dynamic forms styling */
.params-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
}

.form-input {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--card-border);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  transition: all 0.2s ease;
}

.form-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 10px var(--primary-glow);
  background: rgba(0, 0, 0, 0.35);
}

.field-help {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 6px;
}

/* Real-Time output block */
.output-section .code-block {
  border-color: rgba(108, 70, 243, 0.3);
  background: rgba(108, 70, 243, 0.05);
  max-height: 120px;
}

/* Buttons styling */
.btn {
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 600;
  padding: 12px 24px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 4px 16px var(--primary-glow);
}

.btn-primary:hover {
  background: #7d59f5;
  box-shadow: 0 6px 20px rgba(108, 70, 243, 0.5);
  transform: translateY(-1px);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--card-border);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
  transform: translateY(-1px);
}

.btn-accent {
  background: var(--accent);
  color: #ffffff;
  box-shadow: 0 4px 16px var(--accent-glow);
}

.btn-accent:hover {
  background: #e24b8d;
  box-shadow: 0 6px 20px rgba(216, 59, 127, 0.5);
  transform: translateY(-1px);
}

.btn-danger-icon {
  background: rgba(255, 74, 90, 0.1);
  border: 1px solid rgba(255, 74, 90, 0.2);
  color: var(--danger);
  padding: 8px;
  border-radius: var(--radius-md);
}

.btn-danger-icon:hover {
  background: var(--danger);
  color: #ffffff;
  transform: translateY(-1px);
}

.workspace-footer {
  display: flex;
  justify-content: flex-end;
  gap: 16px;
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--card-border);
}

/* Modals overlays styling */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(4, 2, 8, 0.75);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.modal {
  max-width: 550px;
  width: 90%;
  animation: modalSlide 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes modalSlide {
  from {
    transform: translateY(30px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.modal-close-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 28px;
  cursor: pointer;
  line-height: 1;
}

.modal-close-btn:hover {
  color: var(--text-primary);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
}

.form-group + .form-group {
  margin-top: 16px;
}

.generated-link-container {
  background: rgba(108, 70, 243, 0.1);
  border: 1px dashed var(--primary);
  color: var(--text-primary);
  font-size: 15px;
  padding: 16px;
  text-align: center;
  border-radius: var(--radius-md);
  margin: 16px 0;
}

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

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 1000;
}

.toast {
  background: rgba(18, 14, 34, 0.9);
  border: 1px solid var(--card-border);
  backdrop-filter: blur(10px);
  color: var(--text-primary);
  padding: 16px 24px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toastIn 0.25s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes toastIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.toast-success {
  border-left: 4px solid var(--success);
}

.toast-info {
  border-left: 4px solid var(--primary);
}

.toast-danger {
  border-left: 4px solid var(--danger);
}

/* Selection helper classes */
.select-all {
  user-select: all;
  cursor: pointer;
}

.hidden {
  display: none !important;
}

@media (max-width: 900px) {
  .app-content {
    grid-template-columns: 1fr;
  }
  .app-container {
    height: auto;
  }
}
