/*
 * ==============================================================================
 * FormStudio - Premium Form Builder
 * Main Custom Stylesheet (assets/css/style.css)
 * ==============================================================================
 * WHAT DOES THIS FILE DO?
 * While the application predominantly uses Tailwind CSS utility classes for layout
 * and styling, this file handles advanced, pseudo-class, and custom visual 
 * properties that are either not natively supported by standard Tailwind classes 
 * or are better managed globally. 
 * 
 * Contents:
 * - Custom scrollbars
 * - Drag and Drop visual indicators
 * - Complex CSS animations (fade-in, slide-up, scale)
 * - Specific overrides for form elements (checkboxes, radio buttons)
 * ==============================================================================
 */

/* ===== TAILWIND V4 THEME CONFIGURATION ===== */
@theme {
  --color-builderBgLight: #f8fafc;
  --color-builderBgDark: #0f172a;
  --color-panelBgLight: #ffffff;
  --color-panelBgDark: #1e293b;
  --color-borderLight: #e2e8f0;
  --color-borderDark: #334155;
  
  --font-sans: 'Inter', sans-serif;
  --font-outfit: 'Outfit', sans-serif;
  --font-poppins: 'Poppins', sans-serif;
}




/* ===== CUSTOM SCROLLBAR ===== */
.custom-scrollbar::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}

.custom-scrollbar::-webkit-scrollbar-track {
  background: transparent;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
  background: rgba(99, 102, 241, 0.3);
  border-radius: 99px;
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
  background: rgba(99, 102, 241, 0.6);
}

/* ===== DRAG & DROP INDICATORS ===== */
.drag-over-section {
  border: 2px dashed #6366f1 !important;
  background: rgba(99, 102, 241, 0.06) !important;
}

.drag-indicator-before {
  border-top: 3px solid #6366f1 !important;
  position: relative;
}

.drag-indicator-before::before {
  content: '';
  position: absolute;
  left: -6px;
  top: -6px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #6366f1;
}

.drag-indicator-after {
  border-bottom: 3px solid #6366f1 !important;
  position: relative;
}

.drag-indicator-after::after {
  content: '';
  position: absolute;
  left: -6px;
  bottom: -6px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #6366f1;
}

/* ===== DEVICE PREVIEW FRAMES ===== */
.preview-desktop {
  width: 100%;
  height: 100%;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.preview-tablet {
  width: 768px;
  height: 1024px;
  border: 14px solid #1e1b4b;
  border-radius: 28px;
  box-shadow: 0 30px 60px -12px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(99, 102, 241, 0.2);
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  margin: 24px auto;
  overflow-y: auto;
}

.preview-mobile {
  width: 375px;
  height: 812px;
  border: 14px solid #1e1b4b;
  border-radius: 44px;
  box-shadow: 0 30px 60px -12px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(99, 102, 241, 0.2);
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  margin: 24px auto;
  overflow-y: auto;
  position: relative;
}

.preview-mobile::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 140px;
  height: 20px;
  background: #1e1b4b;
  border-bottom-left-radius: 14px;
  border-bottom-right-radius: 14px;
  z-index: 50;
}

/* ===== GLASS CARD ===== */
.glass-panel {
  background: rgba(15, 10, 40, 0.65);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(99, 102, 241, 0.18);
}

.glass-panel-light {
  background: rgba(30, 20, 80, 0.45);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(99, 102, 241, 0.12);
}

/* ===== GRADIENT ACCENT ===== */
.gradient-text {
  background: linear-gradient(135deg, #818cf8 0%, #a78bfa 50%, #c084fc 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.gradient-bg {
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a855f7 100%);
}

.gradient-border {
  border: 1px solid;
  border-image: linear-gradient(135deg, #6366f1, #a855f7) 1;
}

/* ===== NAV TABS ===== */
.nav-tab-active {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.25), rgba(168, 85, 247, 0.15));
  border-color: rgba(99, 102, 241, 0.5) !important;
  color: #a5b4fc !important;
}

.nav-tab {
  transition: all 0.2s ease;
  border: 1px solid transparent;
}

.nav-tab:hover {
  background: rgba(99, 102, 241, 0.1);
  border-color: rgba(99, 102, 241, 0.2);
  color: #c7d2fe;
}

/* ===== SIDEBAR COMPONENT CARD ===== */
.comp-card {
  background: rgba(30, 20, 80, 0.3);
  border: 1px solid rgba(99, 102, 241, 0.12);
  border-radius: 12px;
  transition: all 0.2s ease;
  cursor: grab;
}

.comp-card:hover {
  background: rgba(99, 102, 241, 0.15);
  border-color: rgba(99, 102, 241, 0.4);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.2);
}

.comp-card:active {
  cursor: grabbing;
  transform: scale(0.97);
}

/* ===== STAT CARDS ===== */
.stat-card {
  background: rgba(20, 15, 60, 0.6);
  border: 1px solid rgba(99, 102, 241, 0.15);
  border-radius: 16px;
  transition: all 0.3s ease;
}

.stat-card:hover {
  border-color: rgba(99, 102, 241, 0.35);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(99, 102, 241, 0.15);
}

/* ===== TOGGLE SWITCH ===== */
.toggle-track {
  width: 36px;
  height: 20px;
  background: rgba(99, 102, 241, 0.2);
  border-radius: 99px;
  position: relative;
  transition: background 0.2s;
  border: 1px solid rgba(99, 102, 241, 0.3);
}

.toggle-track.on {
  background: rgba(99, 102, 241, 0.8);
}

.peer:checked~.toggle-track {
  background: #6366f1;
}

.peer:checked~.toggle-track::after {
  transform: translateX(16px);
}

.toggle-track::after {
  content: '';
  position: absolute;
  left: 2px;
  top: 2px;
  width: 14px;
  height: 14px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* ===== INPUTS ===== */
.fs-input {
  background: rgba(15, 10, 40, 0.5);
  border: 1px solid rgba(99, 102, 241, 0.18);
  border-radius: 10px;
  color: #e0e7ff;
  transition: all 0.2s;
}

.fs-input:focus {
  outline: none;
  border-color: rgba(99, 102, 241, 0.6);
  background: rgba(99, 102, 241, 0.08);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

.fs-input::placeholder {
  color: rgba(148, 163, 184, 0.5);
}

/* ===== MODAL ===== */
.modal-glass {
  background: rgba(9, 5, 35, 0.92);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(99, 102, 241, 0.2);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(99, 102, 241, 0.1);
}

/* ===== ANIMATIONS ===== */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes glow-pulse {

  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(99, 102, 241, 0);
  }

  50% {
    box-shadow: 0 0 12px 2px rgba(99, 102, 241, 0.25);
  }
}

.animate-fade-in {
  animation: fadeIn 0.3s ease forwards;
}

.glow-on-hover:hover {
  animation: glow-pulse 1.5s ease-in-out infinite;
}

/* ===== BADGES ===== */
.badge-indigo {
  background: rgba(99, 102, 241, 0.2);
  border: 1px solid rgba(99, 102, 241, 0.3);
  color: #a5b4fc;
  border-radius: 99px;
  font-size: 9px;
  font-weight: 700;
  padding: 1px 7px;
}

/* ===== PAGE TABS ===== */
.page-tab {
  background: rgba(30, 20, 80, 0.3);
  border: 1px solid rgba(99, 102, 241, 0.12);
  border-radius: 10px;
  color: #94a3b8;
  transition: all 0.2s;
}

.page-tab:hover {
  border-color: rgba(99, 102, 241, 0.3);
  color: #c7d2fe;
}

.page-tab.active {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.3), rgba(168, 85, 247, 0.2));
  border-color: rgba(99, 102, 241, 0.5);
  color: #a5b4fc;
  box-shadow: 0 2px 12px rgba(99, 102, 241, 0.2);
}

/* ===== SECTION HEADER ===== */
.section-category {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(148, 163, 184, 0.5);
}

/* ===== RIGHT PANEL SECTION ===== */
.prop-section-title {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(99, 102, 241, 0.7);
  margin-bottom: 10px;
}

.prop-label {
  font-size: 10px;
  font-weight: 600;
  color: #94a3b8;
  display: block;
  margin-bottom: 4px;
}

/* ===== SUBMISSIONS TABLE ===== */
.sub-table thead tr {
  background: rgba(15, 10, 40, 0.8);
}

.sub-table tbody tr {
  transition: background 0.15s;
}

.sub-table tbody tr:hover {
  background: rgba(99, 102, 241, 0.06);
}

/* ===== THEME PRESET BUTTON ===== */
.theme-preset-btn {
  background: rgba(20, 15, 60, 0.5);
  border: 1px solid rgba(99, 102, 241, 0.15);
  border-radius: 12px;
  transition: all 0.2s;
}

.theme-preset-btn:hover {
  border-color: rgba(99, 102, 241, 0.4);
  background: rgba(99, 102, 241, 0.1);
  transform: translateY(-1px);
}

/* ===== PROGRESS BAR ===== */
.progress-bar-track {
  background: rgba(99, 102, 241, 0.1);
  border-radius: 99px;
  height: 3px;
}

.progress-bar-fill {
  background: linear-gradient(90deg, #6366f1, #a855f7);
  border-radius: 99px;
  height: 100%;
  transition: width 0.4s ease;
}

/* ===== DARK MODE SMOOTH TRANSITIONS ===== */
html {
  transition: background-color 0.2s ease, color 0.2s ease;
}

/* ===== RESPONSIVE: MOBILE SIDEBAR MANAGEMENT ===== */
/*
 * On mobile screens, the left and right sidebars are hidden by default.
 * The builder canvas takes full width. Sidebars slide in as drawers when toggled.
 */
@media (max-width: 767px) {
  /* Hide the desktop sidebars on mobile */
  #view-builder > aside {
    position: fixed;
    top: 0;
    bottom: 0;
    z-index: 40;
    width: 85vw !important;
    max-width: 320px;
    transform: translateX(-110%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 4px 0 24px rgba(0,0,0,0.18);
  }

  #view-builder > aside:first-of-type {
    left: 0;
    transform: translateX(-110%);
  }

  #view-builder > aside:last-of-type {
    right: 0;
    left: auto;
    transform: translateX(110%);
  }

  #view-builder > aside.sidebar-open {
    transform: translateX(0);
  }

  /* Overlay backdrop for open sidebar */
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 39;
    backdrop-filter: blur(2px);
  }

  .sidebar-overlay.active {
    display: block;
  }

  /* Canvas takes full width on mobile */
  #view-builder section {
    width: 100% !important;
    flex: 1 !important;
  }

  /* Mobile FAB buttons to open sidebars */
  .mobile-sidebar-fab {
    display: flex !important;
  }

  /* Preview tabs: make them wrap */
  .preview-tablet {
    width: 100% !important;
    height: auto !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    margin: 0 !important;
  }

  .preview-mobile {
    width: 100% !important;
    height: auto !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    margin: 0 !important;
  }

  /* Smaller padding on canvas */
  #canvas-main-area {
    padding-bottom: 6rem;
  }
}

/* ===== MOBILE FAB BUTTONS (hidden on desktop) ===== */
.mobile-sidebar-fab {
  display: none;
  position: fixed;
  bottom: 1rem;
  z-index: 38;
  gap: 0.5rem;
}

.mobile-sidebar-fab.left {
  left: 1rem;
}

.mobile-sidebar-fab.right {
  right: 1rem;
}

/* ===== BUILDER VIEW: FLEX LAYOUT FIX ===== */
#view-builder {
  min-width: 0;
  overflow: hidden;
}

/* ===== FULL-HEIGHT RESPONSIVE LAYOUT ===== */
html, body {
  height: 100%;
  min-height: 100%;
}

/* Ensure sidebars don't overflow on medium screens */
@media (min-width: 768px) and (max-width: 1024px) {
  #view-builder > aside {
    width: 240px !important;
  }
}

/* ===== VIEWPORT BREAK OVERLAY FOR TINY DEVICES ===== */
@media (max-width: 319px) {
  #viewport-break-screen {
    display: flex !important;
  }
}