/* styles.css */

/* Global Reset & Base Variables */
:root {
  /* Font Families */
  --font-title: 'Lora', Georgia, serif;
  --font-ui: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Courier New', monospace;

  /* Premium Light Theme Colors (Warm Alabaster & Cream) */
  --bg-primary: #fdfdfc;
  --bg-secondary: #f6f5f2;
  --bg-tertiary: #eeede8;
  --text-primary: #1c1b18;
  --text-secondary: #6e6b64;
  --text-tertiary: #a4a095;
  --accent: #5e50db;
  --accent-light: #ece9ff;
  --accent-hover: #483ac2;
  --border-color: #eae8e1;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.02);
  --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.08);

  /* Status Colors */
  --status-online: #10b981;
  --status-offline: #f59e0b;
  --status-syncing: #3b82f6;
  --status-error: #ef4444;

  --transition-smooth: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  --sidebar-width: 320px;
}

[data-theme="dark"] {
  /* Premium Dark Theme Colors (Deep Charcoal & Obsidian) */
  --bg-primary: #121210;
  --bg-secondary: #1a1a17;
  --bg-tertiary: #262622;
  --text-primary: #f3f2ee;
  --text-secondary: #a4a095;
  --text-tertiary: #65635b;
  --accent: #a29bfe;
  --accent-light: rgba(162, 155, 254, 0.12);
  --accent-hover: #b3aeff;
  --border-color: #242420;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.4);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-ui);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 0.4s ease, color 0.4s ease, border-color 0.4s ease;
}

/* App Container Layout */
.app-container {
  display: flex;
  height: 100vh;
  width: 100vw;
  position: relative;
}

/* Sidebar Styling */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  height: 100%;
  position: relative;
  z-index: 10;
  transition: transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1), background-color 0.4s ease, border-color 0.4s ease;
}

.sidebar-header {
  padding: 32px 24px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.app-logo {
  font-family: var(--font-title);
  font-size: 1.5rem;
  font-weight: 500;
  letter-spacing: -0.5px;
  color: var(--text-primary);
}

/* Search Container */
.search-container {
  padding: 8px 24px 16px;
  position: relative;
}

.search-container input {
  width: 100%;
  padding: 12px 16px 12px 40px;
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 0.9rem;
  outline: none;
  transition: var(--transition-smooth);
}

.search-container input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.search-icon {
  position: absolute;
  left: 36px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--text-tertiary);
  pointer-events: none;
}

/* Notes List */
.notes-list-wrapper {
  flex-grow: 1;
  overflow-y: auto;
  padding: 0 16px 16px;
}

/* Custom Minimalist Scrollbar */
.notes-list-wrapper::-webkit-scrollbar,
.writing-area::-webkit-scrollbar,
textarea::-webkit-scrollbar {
  width: 4px;
}

.notes-list-wrapper::-webkit-scrollbar-track,
textarea::-webkit-scrollbar-track {
  background: transparent;
}

.notes-list-wrapper::-webkit-scrollbar-thumb,
textarea::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 2px;
}

.notes-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Note Item Row */
.note-item {
  padding: 18px 20px;
  border-radius: 12px;
  background: transparent;
  cursor: pointer;
  border: 1px solid transparent;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: var(--transition-smooth);
  user-select: none;
}

.note-item:hover {
  background-color: var(--bg-tertiary);
}

.note-item.active {
  background-color: var(--bg-primary);
  border-color: var(--border-color);
  box-shadow: var(--shadow-sm);
}

.note-item-title {
  font-family: var(--font-title);
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.note-item-snippet {
  font-size: 0.85rem;
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
}

.note-item-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  color: var(--text-tertiary);
  margin-top: 4px;
}

.note-badge-pending {
  background-color: var(--accent-light);
  color: var(--accent);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 500;
}

/* Sidebar Footer Controls */
.sidebar-footer {
  padding: 20px 24px 32px;
  display: flex;
  gap: 12px;
  border-top: 1px solid var(--border-color);
}

/* Buttons Styling */
button {
  cursor: pointer;
  border: none;
  outline: none;
  font-family: var(--font-ui);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-smooth);
}

.primary-btn {
  flex-grow: 1;
  background-color: var(--text-primary);
  color: var(--bg-primary);
  padding: 12px 16px;
  border-radius: 12px;
  font-weight: 500;
  font-size: 0.9rem;
  gap: 8px;
}

.primary-btn:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.primary-btn:active {
  transform: translateY(0);
}

.primary-btn svg {
  width: 18px;
  height: 18px;
}

.secondary-btn {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
  padding: 12px;
  border-radius: 12px;
  font-weight: 500;
  font-size: 0.9rem;
  gap: 8px;
}

.secondary-btn:hover {
  background-color: var(--border-color);
}

.secondary-btn svg {
  width: 18px;
  height: 18px;
}

.icon-btn {
  background: transparent;
  color: var(--text-secondary);
  width: 40px;
  height: 40px;
  border-radius: 50%;
}

.icon-btn:hover {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
}

.theme-toggle svg {
  width: 20px;
  height: 20px;
}

.sun-icon {
  display: block;
}
.moon-icon {
  display: none;
}

[data-theme="dark"] .sun-icon {
  display: none;
}
[data-theme="dark"] .moon-icon {
  display: block;
}

/* Main Editor Panel */
.editor-panel {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  background-color: var(--bg-primary);
  position: relative;
  transition: background-color 0.4s ease;
}

/* Editor Header */
.editor-header {
  padding: 24px 40px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid transparent; /* Keeps layout clean */
}

.menu-toggle-btn {
  display: none; /* Desktop hidden */
}

/* Sync Status Indicator Badge */
.sync-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background-color: var(--bg-secondary);
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  background-color: var(--text-tertiary);
  transition: background-color 0.3s ease;
}

.status-dot.online {
  background-color: var(--status-online);
}

.status-dot.offline {
  background-color: var(--status-offline);
}

.status-dot.syncing {
  background-color: var(--status-syncing);
  animation: pulse 1.5s infinite ease-in-out;
}

.status-dot.error {
  background-color: var(--status-error);
}

@keyframes pulse {
  0% { transform: scale(0.85); opacity: 0.5; }
  50% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(0.85); opacity: 0.5; }
}

.editor-header-actions {
  display: flex;
  gap: 8px;
}

.editor-header-actions svg {
  width: 20px;
  height: 20px;
}

/* Writing Sandbox (Centered Reading Container) */
.writing-area {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  padding: 0 40px 40px;
  max-width: 800px;
  width: 100%;
  margin: 0 auto;
  overflow-y: auto;
}

.note-title {
  font-family: var(--font-title);
  font-size: 2.2rem;
  font-weight: 400;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text-primary);
  padding: 24px 0 16px;
  width: 100%;
  letter-spacing: -0.5px;
}

.note-title::placeholder {
  color: var(--text-tertiary);
  font-style: italic;
  opacity: 0.5;
}

.note-content {
  font-family: var(--font-ui);
  font-size: 1.1rem;
  line-height: 1.7;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text-primary);
  resize: none;
  flex-grow: 1;
  width: 100%;
  padding-bottom: 60px;
}

.note-content::placeholder {
  color: var(--text-tertiary);
  opacity: 0.5;
}

/* Mono Mode toggle can be custom styling later if requested */

/* Editor Footer */
.editor-footer {
  padding: 16px 40px 24px;
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-tertiary);
  border-top: 1px solid transparent;
  max-width: 800px;
  width: 100%;
  margin: 0 auto;
}

/* Modal Styling */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(5px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

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

.modal-card {
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  width: 90%;
  max-width: 520px;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px);
  transition: transform 0.35s cubic-bezier(0.25, 0.8, 0.25, 1);
  overflow: hidden;
}

.modal-overlay.open .modal-card {
  transform: translateY(0);
}

.modal-header {
  padding: 24px 32px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
  font-family: var(--font-title);
  font-weight: 500;
  font-size: 1.3rem;
}

.close-modal-btn {
  font-size: 1.8rem;
  width: 32px;
  height: 32px;
  color: var(--text-secondary);
}

.modal-body {
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.modal-body p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.key-display-group,
.key-input-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.modal-body label {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
}

.input-copy-wrapper {
  display: flex;
  gap: 8px;
}

.input-copy-wrapper input {
  flex-grow: 1;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  outline: none;
  transition: var(--transition-smooth);
}

.input-copy-wrapper input:focus {
  border-color: var(--accent);
  background-color: var(--bg-primary);
}

.tip-text,
.warning-text {
  font-size: 0.75rem;
  color: var(--text-tertiary);
}

.warning-text {
  color: var(--status-offline);
}

.modal-divider {
  border: none;
  border-top: 1px solid var(--border-color);
}

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

.toast {
  background-color: var(--text-primary);
  color: var(--bg-primary);
  padding: 12px 24px;
  border-radius: 12px;
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  gap: 10px;
  transform: translateY(100px);
  opacity: 0;
  animation: slideIn 0.35s cubic-bezier(0.25, 0.8, 0.25, 1) forwards;
  transition: var(--transition-smooth);
}

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

.toast.fade-out {
  opacity: 0;
  transform: translateY(20px);
}

/* Responsive Media Queries (Mobile layout support) */
@media (max-width: 768px) {
  .menu-toggle-btn {
    display: inline-flex;
  }

  .sidebar {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .editor-header {
    padding: 16px 20px;
  }

  .writing-area {
    padding: 0 20px 20px;
  }

  .note-title {
    font-size: 1.8rem;
    padding: 16px 0 8px;
  }

  .editor-footer {
    padding: 12px 20px 16px;
  }
}
