/* Import modern, premium fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@400;500;600;700;800&display=swap');

/* CSS Variables for default dark theme and core systems */
:root {
  --font-sans: 'Inter', sans-serif;
  --font-heading: 'Outfit', sans-serif;

  /* Color Palette */
  --bg-main: #0a0d16;
  --bg-gradient: radial-gradient(circle at 50% 0%, #151d30 0%, #0a0d16 100%);
  --card-bg: rgba(255, 255, 255, 0.03);
  --card-border: rgba(255, 255, 255, 0.07);
  --card-hover-border: rgba(255, 255, 255, 0.15);
  
  --text-primary: #f3f4f6;
  --text-secondary: #cbd5e1; /* Boosted contrast from #9ca3af */
  --text-muted: #94a3b8; /* Boosted contrast from #6b7280 */
  
  --accent-cyan: #06b6d4;
  --accent-purple: #8b5cf6;
  
  /* Status Colors */
  --color-success: #10b981;
  --color-error: #ef4444;
  --color-warning: #f59e0b;
  
  /* Shadow Systems */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 8px 32px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.15);
  
  /* Border Radius */
  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-full: 9999px;
  
  /* Transition timings */
  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  
  /* Default Gradient (Overwritten by themes dynamically) */
  --theme-gradient: linear-gradient(135deg, #3b82f6, #8b5cf6);
  --theme-glow: rgba(99, 102, 241, 0.3);
  --theme-glow-weak: rgba(99, 102, 241, 0.1);
}

/* Preset Gradient Themes */
.theme-default {
  --theme-gradient: linear-gradient(135deg, #3b82f6, #8b5cf6);
  --theme-glow: rgba(99, 102, 241, 0.3);
  --theme-glow-weak: rgba(99, 102, 241, 0.1);
}

.theme-sunset {
  --theme-gradient: linear-gradient(135deg, #f59e0b, #ef4444);
  --theme-glow: rgba(239, 68, 68, 0.3);
  --theme-glow-weak: rgba(239, 68, 68, 0.1);
}

.theme-emerald {
  --theme-gradient: linear-gradient(135deg, #10b981, #06b6d4);
  --theme-glow: rgba(6, 182, 212, 0.3);
  --theme-glow-weak: rgba(6, 182, 212, 0.1);
}

.theme-nebula {
  --theme-gradient: linear-gradient(135deg, #8b5cf6, #ec4899);
  --theme-glow: rgba(236, 72, 153, 0.3);
  --theme-glow-weak: rgba(236, 72, 153, 0.1);
}

.theme-ruby {
  --theme-gradient: linear-gradient(135deg, #f43f5e, #d946ef);
  --theme-glow: rgba(244, 63, 94, 0.3);
  --theme-glow-weak: rgba(244, 63, 94, 0.1);
}

.theme-ocean {
  --theme-gradient: linear-gradient(135deg, #0ea5e9, #0284c7);
  --theme-glow: rgba(14, 165, 233, 0.3);
  --theme-glow-weak: rgba(14, 165, 233, 0.1);
}

/* Reset and Base Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-main);
  background-image: var(--bg-gradient);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
}
::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Glassmorphism Containers */
.glass-panel {
  background: var(--card-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  transition: border-color var(--transition-normal), box-shadow var(--transition-normal);
}

.glass-panel:hover {
  border-color: var(--card-hover-border);
}

/* Interactive elements */
button, .btn {
  font-family: var(--font-sans);
  font-weight: 500;
  cursor: pointer;
  border: none;
  outline: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all var(--transition-fast);
  border-radius: var(--radius-md);
}

.btn-primary {
  background: var(--theme-gradient);
  color: #ffffff;
  box-shadow: var(--shadow-sm), var(--theme-glow-weak);
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md), var(--theme-glow);
}
.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--card-border);
  color: var(--text-primary);
}
.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--card-hover-border);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: #f87171;
}
.btn-danger:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.4);
}

.btn-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  padding: 0;
}

/* Inputs and Forms */
input[type="text"],
input[type="datetime-local"],
textarea,
select {
  width: 100%;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 1rem;
  transition: all var(--transition-fast);
  outline: none;
}

input[type="text"]:focus,
input[type="datetime-local"]:focus,
textarea:focus,
select:focus {
  border-color: rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.05);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.05);
}

label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

/* Nav & Layout */
header {
  padding: 24px;
  border-bottom: 1px solid var(--card-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(10, 13, 22, 0.5);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text-primary);
}

.logo-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--theme-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--theme-glow);
}

.logo-text {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-family: var(--font-heading);
}

main {
  flex: 1;
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
  padding: 60px 24px;
}

footer {
  text-align: center;
  padding: 24px;
  color: var(--text-muted);
  font-size: 0.875rem;
  border-top: 1px solid var(--card-border);
}

/* Spinner */
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-full);
  border-top-color: var(--accent-cyan);
  animation: spin 1s linear infinite;
  margin: 40px auto;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* App View Containers */
#loading-view {
  display: none;
}

#loading-view.active {
  display: block;
}

.view-container {
  display: none;
  animation: fadeIn var(--transition-normal);
}

.view-container.active {
  display: flex;
  flex-direction: column;
  gap: 40px;
}

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

/* Landing/Create Form Page */
.form-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 32px;
}

@media (max-width: 768px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
}

.form-card {
  padding: 40px; /* Increased from 32px for premium layout spacing */
}

.form-group {
  margin-bottom: 28px; /* Increased from 24px */
}

.theme-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.theme-option {
  cursor: pointer;
  padding: 16px 12px;
  border-radius: var(--radius-md);
  border: 2px solid transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  font-size: 0.8125rem;
  background: rgba(255, 255, 255, 0.02);
  transition: all var(--transition-fast);
}

.theme-option:hover {
  background: rgba(255, 255, 255, 0.05);
}

.theme-option.selected {
  border-color: var(--accent-cyan);
  background: rgba(255, 255, 255, 0.08);
}

.theme-preview-circle {
  width: 24px;
  height: 24px;
  border-radius: var(--radius-full);
}

/* Live View Elements */
.countdown-header-panel {
  padding: 40px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.countdown-header-panel::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--theme-gradient);
}

.countdown-title {
  font-size: 2.5rem;
  margin-bottom: 8px;
  font-family: var(--font-heading);
  background: var(--theme-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 2px 20px var(--theme-glow-weak);
}

.countdown-subtitle {
  color: var(--text-secondary);
  font-size: 1rem;
}

/* Large Clock Grid */
.clock-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

@media (max-width: 600px) {
  .clock-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
}

.clock-card {
  padding: 24px 16px;
  text-align: center;
  position: relative;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--card-border);
  box-shadow: inset 0 0 20px rgba(255, 255, 255, 0.01);
}

.clock-num {
  font-family: var(--font-heading);
  font-size: 3.5rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
  margin-bottom: 8px;
  text-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  animation: numTick var(--transition-normal);
}

.clock-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  font-weight: 600;
}

/* Master Progress Bar */
.progress-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.progress-track {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--theme-gradient);
  border-radius: var(--radius-full);
  width: 0%;
  transition: width 1s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 0 12px var(--theme-glow);
}

.progress-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Columnar details */
.detail-columns {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 32px;
}

@media (max-width: 768px) {
  .detail-columns {
    grid-template-columns: 1fr;
  }
}

.panel-card {
  padding: 24px;
}

.panel-title {
  font-size: 1.25rem;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--card-border);
  padding-bottom: 12px;
}

/* Markdown Description */
.markdown-content {
  color: var(--text-secondary);
  line-height: 1.6;
  white-space: pre-wrap;
}

/* Todos list UI */
.todo-list-wrapper {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.todo-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.01);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

.todo-item:hover {
  background: rgba(255, 255, 255, 0.03);
  border-color: rgba(255, 255, 255, 0.1);
}

.todo-checkbox-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  height: 20px;
}

.todo-checkbox {
  appearance: none;
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border: 2px solid var(--text-muted);
  border-radius: 6px;
  outline: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
}

.todo-checkbox:checked {
  background: var(--theme-gradient);
  border-color: transparent;
}

.todo-checkbox:checked::after {
  content: '✓';
  color: #fff;
  font-size: 12px;
  font-weight: bold;
}

.todo-text {
  font-size: 0.9375rem;
  color: var(--text-primary);
  line-height: 1.4;
  word-break: break-word;
  transition: all var(--transition-fast);
}

.todo-item.completed .todo-text {
  color: var(--text-muted);
  text-decoration: line-through;
}

/* Add new todo form inline */
.add-todo-inline {
  display: flex;
  gap: 8px;
}

/* Milestones Timeline & Nested elements */
.timeline {
  display: flex;
  flex-direction: column;
  gap: 28px; /* Increased from 20px for spacious nodes timeline */
  position: relative;
  padding-left: 20px;
}

.timeline::before {
  content: '';
  position: absolute;
  top: 8px;
  bottom: 8px;
  left: 5px;
  width: 2px;
  background: var(--card-border);
}

.milestone-node {
  position: relative;
  border-radius: var(--radius-md);
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.015);
  transition: all var(--transition-normal);
  cursor: pointer;
}

.milestone-node:hover {
  background: rgba(255, 255, 255, 0.03);
  border-color: rgba(255, 255, 255, 0.15);
}

.milestone-node.completed {
  border-color: rgba(16, 185, 129, 0.25);
  background: rgba(16, 185, 129, 0.01);
}

/* Timeline dot indicator */
.milestone-dot {
  position: absolute;
  left: -20px;
  top: 20px;
  width: 12px;
  height: 12px;
  border-radius: var(--radius-full);
  background: var(--text-muted);
  border: 2px solid var(--bg-main);
  z-index: 2;
  transition: all var(--transition-fast);
}

.milestone-node.completed .milestone-dot {
  background: var(--color-success);
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.5);
}

.milestone-node.active-dot .milestone-dot {
  background: var(--accent-cyan);
  box-shadow: 0 0 8px rgba(6, 182, 212, 0.5);
}

.milestone-header {
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.milestone-header-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.milestone-node-title {
  font-size: 1.05rem;
  font-family: var(--font-heading);
  display: flex;
  align-items: center;
  gap: 8px;
}

.milestone-badge {
  font-size: 0.6875rem;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--card-border);
  color: var(--text-secondary);
  font-weight: 600;
}

.milestone-node-date {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.milestone-chevron {
  width: 20px;
  height: 20px;
  color: var(--text-muted);
  transition: transform var(--transition-fast);
}

.milestone-node.expanded .milestone-chevron {
  transform: rotate(180deg);
}

.milestone-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height var(--transition-normal) ease;
  padding: 0 20px;
}

.milestone-node.expanded .milestone-body {
  max-height: 800px;
  padding: 0 20px 20px 20px;
  border-top: 1px solid var(--card-border);
  padding-top: 16px;
}

.milestone-notes {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 16px;
  white-space: pre-wrap;
}

.milestone-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 6px;
}

.milestone-progress-bar {
  flex: 1;
  height: 4px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.milestone-progress-fill {
  height: 100%;
  background: var(--theme-gradient);
  width: 0%;
  transition: width var(--transition-normal);
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal-overlay.active {
  display: flex;
  animation: fadeIn var(--transition-fast);
}

.modal-content {
  width: 100%;
  max-width: 500px;
  padding: 32px;
  position: relative;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-title {
  font-size: 1.5rem;
  margin-bottom: 24px;
}

.modal-close {
  position: absolute;
  top: 24px;
  right: 24px;
  background: none;
  color: var(--text-muted);
  font-size: 1.25rem;
  cursor: pointer;
}

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

/* Milestone creation list inside forms */
.form-milestone-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 12px;
}

.form-milestone-item {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.01);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.form-milestone-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-milestone-title {
  font-size: 0.9375rem;
  font-weight: 500;
}

.form-milestone-date {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Share modal details */
.share-link-box {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.share-link-input {
  font-family: monospace;
  font-size: 0.8125rem;
  background: rgba(0, 0, 0, 0.2) !important;
}

/* Toast Message */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 16px 24px;
  background: rgba(10, 13, 22, 0.9);
  border: 1px solid var(--card-border);
  border-left: 4px solid var(--accent-cyan);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 2000;
  display: flex;
  align-items: center;
  gap: 12px;
  transform: translateY(100px);
  opacity: 0;
  transition: all var(--transition-normal);
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

/* Welcome panel on create view */
.welcome-hero {
  padding: 40px 32px;
  text-align: center;
  border-radius: var(--radius-lg);
  margin-bottom: 32px;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.05), rgba(139, 92, 246, 0.05));
  border: 1px solid rgba(99, 102, 241, 0.15);
  box-shadow: 0 0 30px rgba(99, 102, 241, 0.05);
}

.welcome-title {
  font-size: 2.25rem;
  margin-bottom: 12px;
  font-family: var(--font-heading);
  background: linear-gradient(135deg, #60a5fa, #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.welcome-desc {
  color: var(--text-secondary);
  max-width: 600px;
  margin: 0 auto;
  line-height: 1.6;
}

/* Checklist manager within form */
.form-todo-item {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.form-todo-item input {
  flex: 1;
}

/* Empty State Styling */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.empty-state svg {
  width: 48px;
  height: 48px;
  opacity: 0.6; /* Boosted contrast from 0.3 */
  filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.08));
}

/* Inline Todo Editing Styles */
.todo-text-editable {
  cursor: pointer;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  border: 1px dashed transparent;
  display: inline-block;
  min-width: 120px;
}

.todo-text-editable:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.15);
}

.todo-edit-input {
  background: rgba(0, 0, 0, 0.3) !important;
  border: 1px solid rgba(255, 255, 255, 0.2) !important;
  color: var(--text-primary) !important;
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  padding: 3px 8px !important;
  border-radius: var(--radius-sm) !important;
  width: 100%;
  max-width: 400px;
  outline: none;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.5);
}

/* Spacing Adjustments */
.view-container.active {
  gap: 40px; /* Increased from 32px for more spacious design */
}

.detail-columns {
  gap: 40px; /* Increased from 32px for premium layout spacing */
}

.form-grid {
  gap: 40px; /* Increased from 32px */
}

.panel-card {
  padding: 28px; /* Increased from 24px */
}

.clock-card {
  padding: 28px 20px; /* Increased from 24px 16px */
}

