/* 
 * Neumorphic Design System & Responsive Apple Fluid Interaction Engine 
 * 100% Self-Contained, Zero-Dependency, Fully Responsive on Mobile, Tablet & Desktop
 */

:root {
  /* Neumorphic Light Theme */
  --bg-main: #e8edf5;
  --surface: #e8edf5;
  --surface-alt: #edf2f8;
  --surface-grad-start: #f2f7fe;
  --surface-grad-end: #dfe4ec;
  
  --shadow-light: #ffffff;
  --shadow-dark: #cad5e2;
  --shadow-ambient: rgba(0, 0, 0, 0.04);
  
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  
  /* Apple Signature Colors */
  --accent: #0071e3;
  --accent-hover: #0077ed;
  --accent-glow: rgba(0, 113, 227, 0.28);
  --accent-text: #ffffff;
  
  --holiday: #ff3b30;
  --holiday-bg: rgba(255, 59, 48, 0.1);
  --holiday-border: rgba(255, 59, 48, 0.2);
  
  --today: #10b981;
  --today-glow: rgba(16, 185, 129, 0.35);
  
  --gold: #f59e0b;
  --purple: #8b5cf6;
  
  --radius-xs: 8px;
  --radius-sm: 12px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --radius-xl: 28px;
  --radius-pill: 9999px;
  
  --ease-apple: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
  --duration-fast: 160ms;
  --duration-normal: 260ms;
}

html.dark {
  /* Neumorphic Dark Theme */
  --bg-main: #16181f;
  --surface: #16181f;
  --surface-alt: #1a1d26;
  --surface-grad-start: #1a1d26;
  --surface-grad-end: #121419;
  
  --shadow-light: #212530;
  --shadow-dark: #0b0c10;
  --shadow-ambient: rgba(0, 0, 0, 0.4);
  
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --accent: #2997ff;
  --accent-hover: #47a3ff;
  --accent-glow: rgba(41, 151, 255, 0.35);
  --accent-text: #ffffff;
  
  --holiday: #ff453a;
  --holiday-bg: rgba(255, 69, 58, 0.15);
  --holiday-border: rgba(255, 69, 58, 0.3);
  
  --today: #34d399;
  --today-glow: rgba(52, 211, 153, 0.35);
}

/* ==========================================================================
   Base & Reset
   ========================================================================== */

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  background-color: var(--bg-main);
  color: var(--text-primary);
  font-family: 'Vazirmatn', -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif;
  min-height: 100vh;
  min-height: -webkit-fill-available;
  overflow-x: hidden;
  line-height: 1.5;
  transition: background-color 0.35s var(--ease-apple), color 0.35s var(--ease-apple);
}

/* Responsive Main Shell */
.app-container {
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
  padding: 10px 12px 28px 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

@media (min-width: 640px) {
  .app-container {
    padding: 20px 24px 36px 24px;
    gap: 16px;
  }
}

@media (min-width: 768px) {
  .app-container {
    padding: 28px 32px 48px 32px;
    gap: 20px;
  }
}

/* ==========================================================================
   Neumorphic Shadow Engines
   ========================================================================== */

.neu-flat {
  background: var(--surface);
  box-shadow: 6px 6px 14px var(--shadow-dark), -6px -6px 14px var(--shadow-light);
  border-radius: var(--radius-md);
  transition: all var(--duration-normal) var(--ease-apple);
}

.neu-flat-sm {
  background: var(--surface);
  box-shadow: 3px 3px 8px var(--shadow-dark), -3px -3px 8px var(--shadow-light);
  border-radius: var(--radius-sm);
  transition: all var(--duration-fast) var(--ease-apple);
}

.neu-flat-lg {
  background: var(--surface);
  box-shadow: 10px 10px 22px var(--shadow-dark), -10px -10px 22px var(--shadow-light);
  border-radius: var(--radius-lg);
  transition: all var(--duration-normal) var(--ease-apple);
}

.neu-pressed {
  background: var(--surface);
  box-shadow: inset 3px 3px 7px var(--shadow-dark), inset -3px -3px 7px var(--shadow-light);
  border-radius: var(--radius-md);
}

.neu-pressed-sm {
  background: var(--surface);
  box-shadow: inset 2px 2px 5px var(--shadow-dark), inset -2px -2px 5px var(--shadow-light);
  border-radius: var(--radius-sm);
}

.neu-well {
  background: var(--surface);
  box-shadow: inset 4px 4px 10px var(--shadow-dark), inset -4px -4px 10px var(--shadow-light);
  border-radius: var(--radius-md);
}

.neu-convex {
  background: linear-gradient(145deg, var(--surface-grad-start), var(--surface-grad-end));
  box-shadow: 4px 4px 10px var(--shadow-dark), -4px -4px 10px var(--shadow-light);
  border-radius: var(--radius-md);
}

/* ==========================================================================
   Header Bar Layout (Mobile First)
   ========================================================================== */

.app-header {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px;
}

@media (min-width: 560px) {
  .app-header {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
  }
}

.header-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

@media (min-width: 560px) {
  .header-top-row {
    width: auto;
    gap: 16px;
  }
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  flex-shrink: 0;
}

.brand-text h1 {
  font-size: 1rem;
  font-weight: 800;
  line-height: 1.2;
}

.brand-text p {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 500;
}

.header-actions-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  width: 100%;
}

@media (min-width: 560px) {
  .header-actions-row {
    width: auto;
    justify-content: flex-end;
    gap: 8px;
  }
}

.clock-badge {
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  display: inline-flex;
  align-items: baseline;
  gap: 2px;
  font-family: 'Inter', monospace;
  font-weight: 700;
  font-size: 0.85rem;
  white-space: nowrap;
}

.clock-seconds {
  font-size: 0.72rem;
  color: var(--accent);
}

.action-buttons-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ==========================================================================
   Tactile Interactive Buttons
   ========================================================================== */

.neu-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  background: linear-gradient(145deg, var(--surface-grad-start), var(--surface-grad-end));
  color: var(--text-primary);
  border: none;
  outline: none;
  cursor: pointer;
  border-radius: var(--radius-sm);
  box-shadow: 4px 4px 9px var(--shadow-dark), -4px -4px 9px var(--shadow-light);
  font-family: inherit;
  font-weight: 600;
  font-size: 0.88rem;
  transition: all var(--duration-fast) var(--ease-apple);
  position: relative;
  white-space: nowrap;
}

.neu-btn:hover {
  transform: translateY(-1px);
  box-shadow: 5px 5px 12px var(--shadow-dark), -5px -5px 12px var(--shadow-light);
  color: var(--accent);
}

.neu-btn:active {
  transform: scale(0.95);
  box-shadow: inset 3px 3px 6px var(--shadow-dark), inset -3px -3px 6px var(--shadow-light);
}

.neu-btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
  flex-shrink: 0;
}

@media (min-width: 640px) {
  .neu-btn-icon {
    width: 40px;
    height: 40px;
  }
}

.neu-btn-accent {
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  color: var(--accent-text) !important;
  box-shadow: 4px 4px 12px var(--shadow-dark), -4px -4px 12px var(--shadow-light), 0 3px 10px var(--accent-glow);
}

.neu-btn-accent:hover {
  box-shadow: 5px 5px 14px var(--shadow-dark), -5px -5px 14px var(--shadow-light), 0 5px 14px var(--accent-glow);
}

.neu-btn-accent:active {
  box-shadow: inset 3px 3px 6px rgba(0, 0, 0, 0.35);
}

/* ==========================================================================
   Hero Today Card
   ========================================================================== */

.hero-card {
  padding: 14px 16px;
}

@media (min-width: 640px) {
  .hero-card {
    padding: 18px 24px;
  }
}

.hero-content {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

@media (min-width: 640px) {
  .hero-content {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

.hero-info-stack {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.hero-badge-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.today-chip {
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: rgba(16, 185, 129, 0.12);
  color: var(--today);
  font-weight: 700;
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.zodiac-badge {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.hero-primary-date {
  font-size: 1.25rem;
  font-weight: 900;
  color: var(--accent);
  line-height: 1.2;
}

@media (min-width: 640px) {
  .hero-primary-date {
    font-size: 1.6rem;
  }
}

.hero-secondary-date {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
  font-family: 'Inter', system-ui, sans-serif;
}

@media (min-width: 640px) {
  .hero-secondary-date {
    font-size: 0.88rem;
  }
}

/* ==========================================================================
   Calendar Main Section
   ========================================================================== */

.calendar-card {
  padding: 12px;
}

@media (min-width: 640px) {
  .calendar-card {
    padding: 20px;
  }
}

/* Mode Switcher Segmented Control */
.view-mode-bar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

@media (min-width: 600px) {
  .view-mode-bar {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

.neu-segmented {
  display: flex;
  background: var(--surface);
  padding: 4px;
  border-radius: var(--radius-pill);
  box-shadow: inset 3px 3px 6px var(--shadow-dark), inset -3px -3px 6px var(--shadow-light);
  width: 100%;
}

@media (min-width: 600px) {
  .neu-segmented {
    width: auto;
  }
}

.neu-segmented-btn {
  flex: 1;
  padding: 7px 12px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  border: none;
  outline: none;
  background: transparent;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-apple);
  text-align: center;
  white-space: nowrap;
}

@media (min-width: 640px) {
  .neu-segmented-btn {
    padding: 8px 18px;
    font-size: 0.88rem;
  }
}

.neu-segmented-btn.active {
  color: var(--accent);
  background: var(--surface);
  box-shadow: 3px 3px 7px var(--shadow-dark), -3px -3px 7px var(--shadow-light);
}

/* Month Navigation Controls */
.month-nav-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  width: 100%;
}

@media (min-width: 600px) {
  .month-nav-controls {
    width: auto;
    justify-content: flex-end;
  }
}

.month-picker-btn {
  flex: 1;
  padding: 8px 12px;
  font-size: 1rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 0;
}

@media (min-width: 600px) {
  .month-picker-btn {
    flex: initial;
    min-width: 160px;
    font-size: 1.15rem;
    padding: 8px 18px;
  }
}

.leap-badge {
  font-size: 0.68rem;
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  background: rgba(245, 158, 11, 0.12);
  color: var(--gold);
  border: 1px solid rgba(245, 158, 11, 0.25);
  font-weight: 600;
}

/* ==========================================================================
   Weekdays Header Grid (Guaranteed 7 Columns)
   ========================================================================== */

.weekdays-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

html.dark .weekdays-grid {
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

@media (min-width: 640px) {
  .weekdays-grid {
    gap: 8px;
    margin-bottom: 12px;
    padding-bottom: 10px;
  }
}

.weekday-header {
  text-align: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
}

@media (min-width: 640px) {
  .weekday-header {
    font-size: 0.85rem;
  }
}

.weekday-header.is-weekend {
  color: var(--holiday);
}

/* ==========================================================================
   Calendar Grid & Day Cells (Rock-Solid Mobile Sizing)
   ========================================================================== */

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  width: 100%;
}

@media (min-width: 480px) {
  .calendar-grid {
    gap: 6px;
  }
}

@media (min-width: 640px) {
  .calendar-grid {
    gap: 10px;
  }
}

@media (min-width: 768px) {
  .calendar-grid {
    gap: 12px;
  }
}

.day-cell {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  min-height: 44px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: 3px 3px 7px var(--shadow-dark), -3px -3px 7px var(--shadow-light);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-apple);
  padding: 2px;
}

@media (min-width: 480px) {
  .day-cell {
    min-height: 52px;
    padding: 4px;
  }
}

@media (min-width: 640px) {
  .day-cell {
    min-height: 64px;
    border-radius: var(--radius-md);
    box-shadow: 4px 4px 10px var(--shadow-dark), -4px -4px 10px var(--shadow-light);
    padding: 6px;
  }
}

@media (min-width: 768px) {
  .day-cell {
    min-height: 72px;
  }
}

.day-cell:hover {
  transform: translateY(-2px);
  box-shadow: 5px 5px 12px var(--shadow-dark), -5px -5px 12px var(--shadow-light);
}

.day-cell:active {
  transform: scale(0.94);
  box-shadow: inset 3px 3px 6px var(--shadow-dark), inset -3px -3px 6px var(--shadow-light);
}

.day-cell.other-month {
  opacity: 0.35;
  box-shadow: 2px 2px 4px var(--shadow-dark), -2px -2px 4px var(--shadow-light);
}

.day-cell.is-weekend {
  color: var(--holiday);
}

.day-cell.is-holiday {
  color: var(--holiday);
}

.day-cell.is-today {
  border: 2px solid var(--today);
  box-shadow: 3px 3px 10px var(--shadow-dark), -3px -3px 10px var(--shadow-light), 0 0 10px var(--today-glow);
}

.day-cell.is-selected {
  background: linear-gradient(135deg, var(--accent), var(--accent-hover)) !important;
  color: var(--accent-text) !important;
  box-shadow: inset 2px 2px 5px rgba(0, 0, 0, 0.25), 0 4px 14px var(--accent-glow) !important;
  transform: scale(0.96);
}

.day-cell.is-selected .sub-date {
  color: rgba(255, 255, 255, 0.85) !important;
}

.day-cell.is-selected .event-dot {
  background: #ffffff !important;
}

/* Day Numbers */
.day-num {
  font-size: 0.95rem;
  font-weight: 800;
  line-height: 1;
}

@media (min-width: 480px) {
  .day-num {
    font-size: 1.12rem;
  }
}

@media (min-width: 640px) {
  .day-num {
    font-size: 1.35rem;
  }
}

.sub-date {
  font-size: 0.62rem;
  font-weight: 500;
  color: var(--text-muted);
  line-height: 1;
  margin-top: 1px;
  font-family: 'Inter', system-ui, sans-serif;
}

@media (min-width: 480px) {
  .sub-date {
    font-size: 0.72rem;
    margin-top: 2px;
  }
}

@media (min-width: 640px) {
  .sub-date {
    font-size: 0.8rem;
    margin-top: 3px;
  }
}

/* Event Dots */
.event-dots-container {
  display: flex;
  gap: 2px;
  position: absolute;
  bottom: 2px;
  align-items: center;
  justify-content: center;
}

@media (min-width: 640px) {
  .event-dots-container {
    bottom: 5px;
    gap: 3px;
  }
}

.event-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
}

@media (min-width: 640px) {
  .event-dot {
    width: 5px;
    height: 5px;
  }
}

.event-dot.holiday-dot {
  background: var(--holiday);
}

.event-dot.note-dot {
  background: var(--gold);
}

/* ==========================================================================
   Calendar Legend & Info
   ========================================================================== */

.calendar-legend-bar {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.72rem;
  color: var(--text-muted);
}

html.dark .calendar-legend-bar {
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

@media (min-width: 640px) {
  .calendar-legend-bar {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    font-size: 0.78rem;
  }
}

.legend-items {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.legend-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

/* ==========================================================================
   Smooth Slide & Modal Animations
   ========================================================================== */

.slide-next {
  animation: slideNext 0.24s var(--ease-apple) forwards;
}

.slide-prev {
  animation: slidePrev 0.24s var(--ease-apple) forwards;
}

@keyframes slideNext {
  from { opacity: 0; transform: translateX(-16px) scale(0.98); }
  to { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes slidePrev {
  from { opacity: 0; transform: translateX(16px) scale(0.98); }
  to { opacity: 1; transform: translateX(0) scale(1); }
}

/* ==========================================================================
   Modals (Mobile-first Sheet / Center Dialog)
   ========================================================================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 15, 25, 0.45);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 9999;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.24s var(--ease-apple);
}

@media (min-width: 640px) {
  .modal-backdrop {
    align-items: center;
    padding: 16px;
  }
}

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

.modal-card {
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  overflow-y: auto;
  background: var(--surface);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.15);
  padding: 18px 16px 28px 16px;
  transform: translateY(100%);
  transition: transform 0.28s var(--ease-apple);
}

@media (min-width: 640px) {
  .modal-card {
    border-radius: var(--radius-xl);
    box-shadow: 16px 16px 36px var(--shadow-dark), -16px -16px 36px var(--shadow-light);
    padding: 24px;
    transform: scale(0.92) translateY(12px);
  }
}

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

@media (min-width: 640px) {
  .modal-backdrop.open .modal-card {
    transform: scale(1) translateY(0);
  }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  margin-bottom: 14px;
}

html.dark .modal-header {
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

/* Form Controls */
.neu-input {
  width: 100%;
  padding: 10px 14px;
  background: var(--surface);
  border: none;
  outline: none;
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
  box-shadow: inset 3px 3px 6px var(--shadow-dark), inset -3px -3px 6px var(--shadow-light);
  transition: box-shadow var(--duration-fast) var(--ease-apple);
}

.neu-input:focus {
  box-shadow: inset 3px 3px 6px var(--shadow-dark), inset -3px -3px 6px var(--shadow-light), 0 0 0 2px var(--accent-glow);
}

/* Event & Note Badges */
.event-card-holiday {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--holiday-bg);
  border: 1px solid var(--holiday-border);
  color: var(--holiday);
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin-bottom: 8px;
}

.event-card-world {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(0, 113, 227, 0.1);
  border: 1px solid rgba(0, 113, 227, 0.25);
  color: var(--accent);
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.note-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
}

.badge-tag {
  font-size: 0.68rem;
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  font-weight: 600;
  border: 1px solid currentColor;
}

.badge-work { color: var(--accent); background: rgba(0, 113, 227, 0.12); }
.badge-personal { color: var(--today); background: rgba(16, 185, 129, 0.12); }
.badge-important { color: var(--gold); background: rgba(245, 158, 11, 0.12); }
.badge-birthday { color: var(--purple); background: rgba(139, 92, 246, 0.12); }

/* Age Stats Grid */
.age-stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  text-align: center;
  margin-top: 10px;
  margin-bottom: 12px;
}

.age-stat-card {
  padding: 10px;
  border-radius: var(--radius-sm);
}

.age-stat-value {
  font-size: 1.4rem;
  font-weight: 800;
  line-height: 1.1;
}

.age-stat-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Utility Helpers */
.flex-row-gap-2 {
  display: flex;
  gap: 8px;
}

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