/* Main Stylesheet - Mobile First */

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'IBM Plex Sans Arabic', sans-serif;
  background-color: var(--bg);
  color: var(--fg);
  line-height: 1.5;
  min-height: 100vh;
  transition: background-color 0.2s, color 0.2s;
}

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

/* View Management */
.view {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.view.hidden {
  display: none;
}

/* Container */
.container {
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  padding: 1rem;
}

/* Header */
.header {
  border-bottom: 1px solid var(--border-color);
  background-color: var(--card-bg);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(8px);
  background-color: rgba(var(--card-bg), 0.8);
}

.header-content {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 1rem;
  max-width: 100%;
  direction: ltr;
}

.header-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0;
  color: var(--fg);
  grid-column: 2;
  text-align: center;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  grid-column: 3;
  justify-self: end;
  direction: ltr;
}

/* Main Content */
.main {
  flex: 1;
  padding-bottom: calc(2rem + 64px + env(safe-area-inset-bottom));
}

/* Today View */
.today-stats {
  margin-bottom: 1.5rem;
}

.today-tasks {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* Progress View */
.progress-timeline {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Calendar View */
#calendar-view .calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  padding: 0 0.5rem;
}

#calendar-view .calendar-grid {
  margin-bottom: 0;
}

/* Daily Schedule */
.daily-schedule {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.schedule-section {
  background-color: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.section-title {
  font-size: 1.125rem;
  font-weight: 600;
  margin: 0 0 1rem 0;
  color: var(--fg);
}

/* Arabic font is applied via [lang="ar"] selector above */

.schedule-items {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* Setup View */
#setup-view {
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

#setup-view .container {
  max-width: 28rem;
  width: 100%;
}

#setup-view .card {
  padding: 2rem;
}

/* Settings View */
#settings-view .card {
  padding: 1.5rem;
  margin-bottom: 1rem;
}

/* RTL Support */
[dir="rtl"] {
  direction: rtl;
  text-align: right;
}

[dir="rtl"] .header-content {
  grid-template-columns: 1fr auto 1fr;
  direction: ltr;
}

[dir="rtl"] .header-actions {
  justify-self: end;
  direction: ltr;
}


[dir="rtl"] .schedule-item-content {
  flex-direction: row-reverse;
}

[dir="rtl"] .stats-grid {
  direction: rtl;
}

/* Responsive Design - Tablet and Up */
@media (min-width: 768px) {
  .container {
    max-width: 42rem;
    padding: 1.5rem;
  }

  .header-content {
    padding: 1.25rem 1.5rem;
  }


  .daily-schedule {
    max-width: 42rem;
    margin: 0 auto;
  }

  .section-title {
    flex-direction: row;
    align-items: baseline;
    gap: 0.5rem;
  }

  #setup-view .container {
    max-width: 32rem;
  }

  #setup-view .card {
    padding: 2.5rem;
  }
}

/* Responsive Design - Desktop */
@media (min-width: 1024px) {
  .container {
    max-width: 48rem;
  }

  .daily-schedule {
    max-width: 48rem;
  }

  .schedule-section {
    padding: 1.5rem;
  }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Focus visible for keyboard navigation */
*:focus-visible {
  outline: 2px solid var(--ring-color);
  outline-offset: 2px;
}

/* Calendar Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  overflow-y: auto;
}

.modal.hidden {
  display: none;
}

/* Calendar modal specific - no scroll on content */
#calendar-modal .modal-content {
  overflow: visible;
  max-height: none;
  height: auto;
}

.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  background-color: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  max-width: 100%;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  z-index: 1001;
}

.calendar-modal {
  padding: 1.5rem;
  max-width: 28rem;
  overflow: visible;
  max-height: none;
  height: auto;
}

.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.calendar-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0;
  color: var(--fg);
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  width: 100%;
  overflow: visible;
}

.calendar-day-header {
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted-fg);
  padding: 0.5rem 0;
  text-transform: uppercase;
}

.calendar-day {
  aspect-ratio: 1;
  min-height: 3rem;
  border: 1px solid var(--border-color);
  border-radius: calc(var(--radius) - 2px);
  padding: 0.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: all 0.15s;
  background-color: var(--bg);
  position: relative;
}

.calendar-day:hover {
  background-color: var(--accent-bg);
  border-color: var(--ring-color);
}

.calendar-day.today {
  border-color: var(--primary-bg);
  border-width: 2px;
}

.calendar-day.selected {
  background-color: var(--primary-bg);
  color: var(--primary-fg);
  border-color: var(--primary-bg);
}

.calendar-day.empty {
  border: none;
  cursor: default;
  background-color: transparent;
}

.calendar-day.empty:hover {
  background-color: transparent;
}

.calendar-day-number {
  font-size: 0.875rem;
  font-weight: 500;
}

/* Task indicators container at bottom of calendar day */
.calendar-task-indicators {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.25rem;
  width: 100%;
  margin-top: auto;
  padding-top: 0.25rem;
  max-width: 100%;
}

/* Individual task indicator circle */
.calendar-task-indicator {
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.625rem;
  font-weight: 600;
  color: white;
  line-height: 1;
}

/* New memorization - Priority 1 (Blue) */
.calendar-task-indicator-new {
  background-color: hsl(217, 91%, 60%);
}

/* Yesterday review - Priority 2 (Orange) */
.calendar-task-indicator-yesterday {
  background-color: hsl(25, 95%, 53%);
}

/* Spaced review - Priority 3 (Green) */
.calendar-task-indicator-spaced {
  background-color: hsl(142, 71%, 45%);
}

.calendar-filters {
  display: flex;
  justify-content: center;
  margin-bottom: 1rem;
  gap: 1rem;
}

.calendar-filter-select {
  padding: 0.5rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  background-color: var(--card-bg);
  color: var(--text-primary);
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s;
}

.calendar-filter-select:hover {
  border-color: var(--primary-bg);
}

.calendar-filter-select:focus {
  outline: none;
  border-color: var(--primary-bg);
  box-shadow: 0 0 0 2px var(--primary-bg-alpha);
}

.calendar-day-items {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  justify-content: center;
  align-items: center;
  width: 100%;
  margin-top: auto;
}

.calendar-item-wrapper {
  position: relative;
  display: inline-block;
}

.calendar-item-circle {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  background-color: var(--primary-bg);
  color: var(--primary-fg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.625rem;
  font-weight: 600;
  flex-shrink: 0;
  transition: all 0.15s;
}

.calendar-item-circle.more {
  background-color: var(--secondary-bg);
  color: var(--secondary-fg);
  font-size: 0.5rem;
}

.calendar-item-circle.placeholder {
  background-color: var(--muted-bg);
  color: var(--muted-fg);
  border: 1px dashed var(--border-color);
  opacity: 0.7;
}

.calendar-day.selected .calendar-item-circle {
  background-color: var(--primary-fg);
  color: var(--primary-bg);
}

.calendar-item-delete {
  position: absolute;
  top: -0.25rem;
  right: -0.25rem;
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  background-color: var(--destructive-bg);
  color: var(--destructive-fg);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 10;
  padding: 0;
}

.calendar-item-wrapper:hover .calendar-item-delete {
  opacity: 1;
}

.calendar-item-delete:hover {
  background-color: var(--destructive-bg);
  opacity: 1;
  transform: scale(1.1);
}

.calendar-footer {
  display: flex;
  justify-content: flex-end;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
}

/* Responsive Calendar */
/* Mobile optimizations for calendar task indicators */
@media (max-width: 767px) {
  .calendar-day {
    aspect-ratio: auto;
    min-height: 4rem;
    height: auto;
  }
  
  .calendar-task-indicators {
    gap: 0.125rem;
    padding-top: 0.125rem;
  }
  
  .calendar-task-indicator {
    width: 1rem;
    height: 1rem;
    font-size: 0.5rem;
  }
}

@media (min-width: 768px) {
  .calendar-modal {
    max-width: 32rem;
    padding: 2rem;
    overflow: visible;
    max-height: none;
  }

  .calendar-day {
    min-height: 3.5rem;
    padding: 0.5rem;
  }

  .calendar-item-circle {
    width: 1.75rem;
    height: 1.75rem;
    font-size: 0.75rem;
  }
}

/* Ensure calendar modal doesn't scroll */
.modal-content.calendar-modal {
  overflow: visible;
  max-height: none;
  height: fit-content;
}

/* Print Styles */
@media print {
  .header-actions,
  .date-selector,
  .schedule-item-actions {
    display: none;
  }

  .view {
    display: block;
  }

  .view.hidden {
    display: none;
  }
}

