/* Global Reset & Base Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg-primary: #121212;
  --bg-secondary: #181818;
  --bg-glass: rgba(28, 28, 30, 0.7);
  --border-color: rgba(255, 255, 255, 0.05);
  --border-color-hover: rgba(255, 255, 255, 0.12);
  
  --text-primary: #f4f4f5;
  --text-secondary: #a1a1aa;
  --text-muted: #52525b;
  
  --accent-color: #6366f1; /* Indigo */
  --accent-gradient: linear-gradient(135deg, #6366f1 0%, #3b82f6 100%);
  --accent-hover: #4f46e5;
  --accent-glow: rgba(99, 102, 241, 0.25);
  
  --danger-color: #ef4444;
  --success-color: #22c55e;
  
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  
  --header-height: 48px;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-sans);
  height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* App Container */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* Header - Dynamic & Semi-transparent */
.main-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background-color: transparent;
  border-bottom: 1px solid transparent;
  backdrop-filter: blur(0px);
  -webkit-backdrop-filter: blur(0px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  z-index: 90;
  transition: background-color 0.3s ease, border-color 0.3s ease, backdrop-filter 0.3s ease;
}

.main-header.scrolled {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0.01) 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  box-shadow: 
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 4px 20px rgba(0, 0, 0, 0.2);
}

.logo {
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: -0.025em;
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 0.1rem;
}

.logo-haste {
  color: var(--text-primary);
}

.logo-bin {
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Document Status Badge */
.document-badge {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.04) 0%, rgba(255, 255, 255, 0.01) 100%);
  border: 1px solid rgba(255, 255, 255, 0.06);
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 500;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.badge-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background-color: var(--accent-color);
  box-shadow: 0 0 6px var(--accent-color);
}

.document-badge.saved .badge-dot {
  background-color: var(--success-color);
  box-shadow: 0 0 6px var(--success-color);
}

.document-badge.editing .badge-dot {
  background-color: #f59e0b; /* Amber */
  box-shadow: 0 0 6px #f59e0b;
}

/* Main Workspace */
.workspace {
  flex: 1;
  position: relative;
  background-color: var(--bg-secondary);
  overflow: hidden;
}

/* Floating Actions Bar */
.floating-actions {
  position: absolute;
  top: 4rem;
  right: 1.5rem;
  z-index: 100;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.08) 0%, rgba(255, 255, 255, 0.02) 100%);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 0.35rem;
  border-radius: 16px;
  box-shadow: 
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    0 10px 30px -5px rgba(0, 0, 0, 0.4), 
    0 8px 15px -6px rgba(0, 0, 0, 0.4);
  display: flex;
  gap: 0.35rem;
  align-items: center;
}

.action-btn {
  position: relative;
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.08) 0%,
    rgba(255, 255, 255, 0.02) 100%
  );
  backdrop-filter: blur(12px) saturate(150%);
  -webkit-backdrop-filter: blur(12px) saturate(150%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.8rem;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  outline: none;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    inset 0 -1px 0 rgba(0, 0, 0, 0.1),
    0 2px 8px rgba(0, 0, 0, 0.2);
}

.action-btn i {
  width: 14px;
  height: 14px;
}

.action-btn:hover {
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.14) 0%,
    rgba(255, 255, 255, 0.05) 100%
  );
  border-color: rgba(255, 255, 255, 0.15);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    inset 0 -1px 0 rgba(0, 0, 0, 0.1),
    0 6px 16px rgba(0, 0, 0, 0.25);
  transform: translateY(-1px);
}

.action-btn:active {
  transform: translateY(0);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    inset 0 2px 4px rgba(0, 0, 0, 0.15);
}

.action-btn.btn-primary {
  background: linear-gradient(
    135deg,
    rgba(120, 122, 255, 0.85) 0%,
    rgba(59, 130, 246, 0.75) 100%
  );
  backdrop-filter: blur(12px) saturate(180%);
  -webkit-backdrop-filter: blur(12px) saturate(180%);
  border: 1px solid rgba(150, 152, 255, 0.35);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.25),
    inset 0 -1px 0 rgba(0, 0, 0, 0.15),
    0 4px 14px rgba(99, 102, 241, 0.35);
}

.action-btn.btn-primary:hover {
  background: linear-gradient(
    135deg,
    rgba(140, 142, 255, 0.9) 0%,
    rgba(80, 150, 255, 0.8) 100%
  );
  border-color: rgba(180, 182, 255, 0.45);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    inset 0 -1px 0 rgba(0, 0, 0, 0.1),
    0 6px 20px rgba(99, 102, 241, 0.5);
  transform: translateY(-1px);
}

.action-btn.btn-primary:active {
  transform: translateY(0);
  box-shadow:
    inset 0 2px 4px rgba(0, 0, 0, 0.2),
    0 2px 8px rgba(99, 102, 241, 0.3);
}

/* Editor & Viewer Styling - Prevent overlapping the floating actions */
.editor, .viewer-container {
  width: 100%;
  height: 100%;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  line-height: 1.6;
}

.editor {
  background-color: transparent;
  color: var(--text-primary);
  border: none;
  outline: none;
  resize: none;
  padding: 4.5rem 14rem 2rem 2.5rem;
  caret-color: var(--accent-color);
  overflow-y: auto;
}

.editor::placeholder {
  color: var(--text-muted);
  opacity: 0.6;
}

/* Viewer Container */
.viewer-container {
  overflow: auto;
  padding: 4.5rem 14rem 2rem 2.5rem;
}

.viewer-container pre {
  margin: 0;
}

.viewer-container code {
  font-family: var(--font-mono) !important;
  background-color: transparent !important;
  padding: 0 !important;
}

/* Custom Scrollbar Styles */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.06);
  border-radius: 9999px;
  border: 2px solid var(--bg-secondary);
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* Custom HighlightJS Line Numbers styling */
.hljs-ln {
  border-collapse: collapse;
  width: 100%;
  table-layout: fixed;
}

.hljs-ln td {
  padding: 0;
}

.hljs-ln-numbers {
  user-select: none;
  -webkit-user-select: none;
  text-align: left; /* Align numbers to the left */
  color: var(--text-muted);
  opacity: 0.5;
  border-right: 1px solid var(--border-color);
  padding-right: 1rem !important;
  width: 3rem; /* Static width for the numbers column */
  min-width: 3rem;
  max-width: 3rem;
  vertical-align: top;
}

.hljs-ln-code {
  padding-left: 1.5rem !important;
  white-space: pre-wrap;
  word-break: break-all;
  vertical-align: top;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  z-index: 100;
}

.toast {
  background-color: var(--bg-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 0.85rem 1.25rem;
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
  transform: translateY(20px);
  opacity: 0;
  animation: slideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  max-width: 320px;
}

.toast i {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.toast-success i {
  color: var(--success-color);
}

.toast-error i {
  color: var(--danger-color);
}

.toast-info i {
  color: var(--accent-color);
}

.toast.fade-out {
  animation: fadeOut 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Keyframes */
@keyframes slideIn {
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes fadeOut {
  to {
    transform: translateY(-10px);
    opacity: 0;
  }
}

/* Responsive adjustments */
@media (max-width: 640px) {
  .main-header {
    padding: 0 1rem;
  }
  
  .document-badge {
    padding: 0.25rem 0.5rem;
  }
  
  .badge-text {
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  
  .floating-actions {
    position: fixed;
    top: auto;
    bottom: 1.5rem;
    right: 50%;
    transform: translateX(50%);
    border-radius: 9999px;
    padding: 0.4rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  }
  
  .floating-actions .action-btn {
    padding: 0.5rem;
    border-radius: 50%;
  }
  
  .floating-actions .action-btn span {
    display: none;
  }
  
  .editor, .viewer-container {
    padding: 1.5rem 1.5rem 6rem 1.5rem;
  }
}
