/* ==========================================================================
   FLASH SERVER - Shiny Glassmorphism & Depth Theme
   ========================================================================== */

:root {
  --bg-dark: #080a10;
  --glass-bg: rgba(18, 22, 36, 0.65);
  --glass-card: rgba(255, 255, 255, 0.05);
  --glass-border: rgba(255, 255, 255, 0.12);
  --glass-inset: inset 0 1px 1px rgba(255, 255, 255, 0.2), inset 0 -1px 2px rgba(0, 0, 0, 0.5);
  --glass-shadow: 0 16px 40px rgba(0, 0, 0, 0.6), 0 0 20px rgba(0, 242, 254, 0.08);
  
  --accent-cyan: #00f2fe;
  --accent-blue: #4facfe;
  --accent-purple: #7f00ff;
  --accent-green: #00e676;
  --accent-red: #ff3366;
  
  --text-primary: #ffffff;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'Fira Code', monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  background-color: var(--bg-dark);
  background-image: 
    radial-gradient(circle at 10% 10%, rgba(79, 172, 254, 0.15) 0%, transparent 40%),
    radial-gradient(circle at 90% 90%, rgba(127, 0, 255, 0.15) 0%, transparent 40%),
    radial-gradient(circle at 50% 50%, rgba(0, 242, 254, 0.05) 0%, transparent 60%);
  font-family: var(--font-sans);
  color: var(--text-primary);
}

#app-wrapper {
  width: 100%;
  height: 100%;
  position: relative;
}

/* Screen Visibility Engine - FIXED FOR OVERLAPPING */
.screen {
  display: none !important; /* Force hide inactive screens */
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
  pointer-events: none; /* Prevent rogue clicks */
}

.screen.active {
  display: flex !important; /* Force show active screen */
  flex-direction: column;
  z-index: 10; /* Bring active screen to the absolute front */
  pointer-events: auto; /* Re-enable clicks for active screen */
}

/* Glass Card Component */
.glass-card {
  background: var(--glass-bg);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow), var(--glass-inset);
  border-radius: 20px;
}

/* Buttons & Inputs */
input, textarea {
  font-family: inherit;
  color: var(--text-primary);
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--glass-border);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5);
  border-radius: 12px;
  padding: 12px 16px;
  outline: none;
  transition: all 0.2s ease;
  width: 100%;
}

input:focus, textarea:focus {
  border-color: var(--accent-cyan);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5), 0 0 12px rgba(0, 242, 254, 0.3);
}

.btn-glow {
  position: relative;
  border: none;
  border-radius: 14px;
  padding: 12px 20px;
  font-weight: 700;
  font-size: 0.95rem;
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  box-shadow: 0 4px 15px rgba(0, 242, 254, 0.25), var(--glass-inset);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-blue));
}

.btn-success {
  background: linear-gradient(135deg, #00b09b, #96c93d);
}

.btn-danger {
  background: linear-gradient(135deg, #ff416c, #ff4b2b);
  border: none;
  color: white;
  padding: 12px;
  border-radius: 12px;
  font-weight: 600;
  cursor: pointer;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--glass-border);
  color: var(--text-secondary);
  padding: 12px 20px;
  border-radius: 14px;
  font-weight: 600;
  cursor: pointer;
}

.btn-glow:active, .btn-secondary:active, .btn-danger:active {
  transform: translateY(2px) scale(0.98);
}

.btn-icon {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--glass-inset);
}

.btn-icon-sm {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
}

.full-width {
  width: 100%;
}

/* Auth Screen */
#auth-screen {
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  padding: 32px 24px;
  text-align: center;
}

.brand-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 6px;
}

.glowing-icon {
  font-size: 1.8rem;
  color: var(--accent-cyan);
  filter: drop-shadow(0 0 10px var(--accent-cyan));
}

.login-card h1 {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: 1px;
  background: linear-gradient(90deg, #fff, var(--accent-cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 28px;
}

.input-group {
  position: relative;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  width: 100%;
}

.input-icon {
  position: absolute;
  left: 14px;
  color: var(--text-muted);
}

.input-group input {
  padding-left: 42px;
}

/* Dashboard Screen */
#dashboard-screen {
  display: flex;
  flex-direction: column;
}

.navbar {
  height: 60px;
  margin: 12px 12px 0 12px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: 16px;
  flex-shrink: 0;
}

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

.nav-title {
  font-weight: 800;
  letter-spacing: 0.5px;
}

.badge-user {
  font-size: 0.8rem;
  padding: 6px 12px;
  background: rgba(0, 242, 254, 0.1);
  border: 1px solid rgba(0, 242, 254, 0.2);
  border-radius: 20px;
  color: var(--accent-cyan);
  margin-right: 8px;
}

.dashboard-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 12px;
  gap: 12px;
  overflow: hidden;
  position: relative;
}

.toolbar {
  padding: 10px 14px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-shrink: 0;
}

.breadcrumbs-container {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  white-space: nowrap;
  font-size: 0.85rem;
  scrollbar-width: none;
}

.breadcrumbs-container::-webkit-scrollbar {
  display: none;
}

.crumb {
  color: var(--accent-cyan);
  cursor: pointer;
  font-weight: 600;
}

.crumb-separator {
  color: var(--text-muted);
}

.crumb-active {
  color: var(--text-primary);
  font-weight: 700;
}

/* Explorer Grid */
.explorer-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(105px, 1fr));
  grid-auto-rows: 110px;
  gap: 12px;
  overflow-y: auto;
  padding: 4px;
}

.grid-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.07);
  box-shadow: var(--glass-inset);
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.grid-item:active {
  transform: scale(0.95);
  background: rgba(255, 255, 255, 0.08);
}

.grid-item i.type-icon {
  font-size: 2.2rem;
}

.grid-item.folder i.type-icon {
  color: #ffca28;
  filter: drop-shadow(0 4px 8px rgba(255, 202, 40, 0.3));
}

.grid-item.file i.type-icon {
  color: var(--accent-cyan);
  filter: drop-shadow(0 4px 8px rgba(0, 242, 254, 0.3));
}

.item-name {
  font-size: 0.75rem;
  font-weight: 600;
  text-align: center;
  word-break: break-all;
  line-clamp: 2;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.delete-item-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(255, 51, 102, 0.2);
  border: 1px solid rgba(255, 51, 102, 0.4);
  color: var(--accent-red);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  opacity: 0.7;
}

.empty-state {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  gap: 10px;
}

.empty-state i {
  font-size: 2.5rem;
  opacity: 0.5;
}

/* FAB Button */
.fab-btn {
  position: absolute;
  bottom: 24px;
  right: 24px;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-purple));
  color: #fff;
  font-size: 1.5rem;
  box-shadow: 0 8px 25px rgba(0, 242, 254, 0.4), var(--glass-inset);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  z-index: 20;
}

.fab-btn:active {
  transform: scale(0.9);
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100dvh;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  width: 100%;
  max-width: 400px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-content.sm {
  max-width: 320px;
}

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

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.modal-footer.vertical {
  flex-direction: column;
}

.segmented-control {
  display: flex;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 12px;
  padding: 4px;
  gap: 4px;
  margin-bottom: 12px;
}

.segment-btn {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 8px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
}

.segment-btn.active {
  background: rgba(255, 255, 255, 0.1);
  color: var(--accent-cyan);
  box-shadow: var(--glass-inset);
}

.input-prefix {
  font-size: 0.75rem;
  color: var(--text-muted);
  padding-left: 12px;
  white-space: nowrap;
}

/* Full Screen Editor Modal */
.full-screen-modal {
  padding: 0;
}

.editor-card {
  width: 100vw;
  height: 100dvh;
  border-radius: 0;
  display: flex;
  flex-direction: column;
}

.editor-header {
  height: 50px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--glass-border);
}

.file-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-family: var(--font-mono);
}

.active-file-icon {
  color: var(--accent-cyan);
}

.unsaved-indicator {
  color: var(--accent-red);
  font-size: 1.5rem;
  line-height: 0;
}

.unsaved-indicator.hidden {
  display: none;
}

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

.btn-sm {
  padding: 6px 14px;
  font-size: 0.8rem;
  border-radius: 8px;
}

.editor-body {
  flex: 1;
  padding: 8px;
}

#code-editor-textarea {
  width: 100%;
  height: 100%;
  background: rgba(5, 7, 12, 0.95);
  font-family: var(--font-mono);
  font-size: 0.9rem;
  line-height: 1.5;
  color: #e2e8f0;
  border-radius: 12px;
  resize: none;
  padding: 14px;
  tab-size: 2;
}

/* Hosted / 404 Screens */
#hosted-view {
  width: 100vw;
  height: 100dvh;
}

#hosted-frame {
  width: 100%;
  height: 100%;
  border: none;
  background: #fff;
}

#not-found-screen {
  align-items: center;
  justify-content: center;
  padding: 20px;
  text-align: center;
}

.error-card {
  padding: 40px 24px;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.error-icon {
  font-size: 3rem;
  color: var(--accent-red);
  filter: drop-shadow(0 0 10px var(--accent-red));
}

/* Toast System */
#toast-container {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 2000;
  pointer-events: none;
}

.toast {
  padding: 10px 18px;
  border-radius: 30px;
  background: rgba(18, 22, 36, 0.9);
  backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
  font-size: 0.82rem;
  font-weight: 600;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: toastIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.toast.success i { color: var(--accent-green); }
.toast.error i { color: var(--accent-red); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(20px) scale(0.9); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

