/**
 * SidebarCalendar v1.0.0
 * Styles for the sidebar calendar component
 */

// Variables
$calendar-width: 320px !default;
$calendar-bg: #ffffff !default;
$calendar-border-radius: 12px !default;
$calendar-shadow: 0 4px 20px rgba(0, 0, 0, 0.1) !default;

// Colors
$color-white: #ffffff !default;
$color-gray-50: #f9fafb !default;
$color-gray-100: #f3f4f6 !default;
$color-gray-200: #e5e7eb !default;
$color-gray-300: #d1d5db !default;
$color-gray-400: #9ca3af !default;
$color-gray-500: #6b7280 !default;
$color-gray-700: #374151 !default;
$color-gray-800: #1f2937 !default;
$color-gray-900: #111827 !default;

// Theme colors
$color-primary: #667eea !default;
$color-primary-dark: #764ba2 !default;

$color-day: #4ade80 !default;
$color-day-dark: #22c55e !default;
$color-day-bg: #f0fdf4 !default;
$color-day-text: #14532d !default;
$color-day-text-light: #166534 !default;

$color-week: #f59e0b !default;
$color-week-dark: #d97706 !default;
$color-week-bg: #fffbeb !default;
$color-week-text: #92400e !default;
$color-week-text-light: #a16207 !default;
$color-week-hover-bg: #fef3c7 !default;

$color-range: #8b5cf6 !default;
$color-range-dark: #7c3aed !default;
$color-range-bg: #faf5ff !default;
$color-range-text: #581c87 !default;
$color-range-text-light: #6b21a8 !default;
$color-range-in-bg: #ede9fe !default;

$color-today-bg: #fef3c7 !default;
$color-today-text: #d97706 !default;

$color-info-bg: #f0f9ff !default;
$color-info-border: #0ea5e9 !default;
$color-info-text: #0c4a6e !default;
$color-info-text-light: #075985 !default;

// Typography
$font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !default;
$font-size-sm: 12px !default;
$font-size-base: 14px !default;
$font-size-lg: 16px !default;
$font-size-xl: 18px !default;

// Spacing
$spacing-xs: 4px !default;
$spacing-sm: 8px !default;
$spacing-md: 12px !default;
$spacing-lg: 16px !default;
$spacing-xl: 20px !default;

// Transitions
$transition-base: all 0.2s ease !default;

// Mixins
@mixin gradient($color1, $color2) {
  background: linear-gradient(135deg, $color1 0%, $color2 100%);
}

@mixin button-reset {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
  font-family: inherit;
}

@mixin focus-outline {
  &:focus-visible {
    outline: 2px solid $color-primary;
    outline-offset: 2px;
  }
}

// Calendar wrapper
.calendar-wrapper {
  width: $calendar-width;
  background: $calendar-bg;
  border-radius: $calendar-border-radius;
  box-shadow: $calendar-shadow;
  overflow: hidden;
  font-family: $font-family;
  
  // Ensure the calendar fits in smaller containers
  max-width: 100%;
  box-sizing: border-box;
}

// Calendar container
.sidebar-calendar {
  width: 100%;
  background: $calendar-bg;
  
  // Calendar header
  .calendar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: $spacing-xl;
    @include gradient($color-primary, $color-primary-dark);
    color: $color-white;
    
    &.day-mode {
      @include gradient($color-day, $color-day-dark);
    }
    
    &.week-mode {
      @include gradient($color-week, $color-week-dark);
    }
    
    &.range-mode {
      @include gradient($color-range, $color-range-dark);
    }
  }
  
  // Navigation buttons
  .nav-button {
    @include button-reset;
    @include focus-outline;
    background: rgba($color-white, 0.2);
    color: $color-white;
    width: 36px;
    height: 36px;
    border-radius: $spacing-sm;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: $transition-base;
    font-size: $font-size-lg;
    
    &:hover {
      background: rgba($color-white, 0.3);
      transform: scale(1.05);
    }
    
    &:active {
      transform: scale(0.95);
    }
  }
  
  // Month/year display
  .month-year {
    font-size: $font-size-xl;
    font-weight: 600;
    text-align: center;
    flex: 1;
    cursor: pointer;
    padding: $spacing-sm;
    border-radius: 6px;
    transition: $transition-base;
    
    &:hover {
      background: rgba($color-white, 0.1);
    }
    
    @include focus-outline;
  }
  
  // Calendar body
  .calendar-body {
    padding: $spacing-xl;
  }
  
  // Weekdays header
  .weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: $spacing-xs;
    margin-bottom: $spacing-md;
  }
  
  .weekday {
    text-align: center;
    font-size: $font-size-sm;
    font-weight: 600;
    color: $color-gray-500;
    padding: $spacing-sm $spacing-xs;
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }
  
  // Days grid
  .days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: $spacing-xs;
  }
  
  // Individual day
  .day {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: $spacing-sm;
    font-size: $font-size-base;
    font-weight: 500;
    transition: $transition-base;
    position: relative;
    border: 2px solid transparent;
    
    @include focus-outline;
    
    &:hover {
      background: $color-gray-100;
      transform: scale(1.05);
    }
    
    &:active {
      transform: scale(0.95);
    }
    
    // Other month days
    &.other-month {
      color: $color-gray-300;
    }
    
    // Today
    &.today {
      background: $color-today-bg;
      color: $color-today-text;
      font-weight: 700;
    }
    
    // Day mode selection
    &.selected-day {
      @include gradient($color-day, $color-day-dark);
      color: $color-white;
      font-weight: 700;
      
      &:hover {
        transform: scale(1.05);
      }
    }
    
    // Week mode selection
    &.selected-week {
      @include gradient($color-week, $color-week-dark);
      color: $color-white;
      font-weight: 700;
      
      &:hover {
        transform: scale(1.05);
      }
    }
    
    &.week-hover {
      background: $color-week-hover-bg;
      color: $color-week-dark;
    }
    
    // Range mode selection
    &.in-range {
      background: $color-range-in-bg;
      color: $color-range-dark;
    }
    
    &.range-start,
    &.range-end {
      @include gradient($color-range, $color-range-dark);
      color: $color-white;
      font-weight: 700;
      
      &:hover {
        transform: scale(1.05);
      }
    }
    
    // Disabled state
    &.disabled {
      color: $color-gray-300;
      cursor: not-allowed;
      opacity: 0.5;
      
      &:hover {
        background: transparent;
        transform: none;
      }
    }
  }
  
  // Selected info display
  .selected-info {
    margin-top: $spacing-md;
    padding: $spacing-md;
    background: $color-info-bg;
    border-radius: $spacing-sm;
    border-left: 4px solid $color-info-border;
    
    &.day-mode {
      background: $color-day-bg;
      border-left-color: $color-day-dark;
      
      .selected-title {
        color: $color-day-text;
      }
      
      .selected-text {
        color: $color-day-text-light;
      }
    }
    
    &.week-mode {
      background: $color-week-bg;
      border-left-color: $color-week-dark;
      
      .selected-title {
        color: $color-week-text;
      }
      
      .selected-text {
        color: $color-week-text-light;
      }
    }
    
    &.range-mode {
      background: $color-range-bg;
      border-left-color: $color-range-dark;
      
      .selected-title {
        color: $color-range-text;
      }
      
      .selected-text {
        color: $color-range-text-light;
      }
    }
    
    .selected-title {
      font-size: 13px;
      color: $color-info-text;
      margin-bottom: $spacing-xs;
      font-weight: 600;
    }
    
    .selected-text {
      font-size: $font-size-sm;
      color: $color-info-text-light;
      margin: 0;
    }
  }
  
  // Quick actions
  .quick-actions {
    padding: $spacing-lg $spacing-xl;
    border-top: 1px solid $color-gray-200;
    background: $color-gray-50;
  }
  
  .quick-buttons {
    display: flex;
    gap: $spacing-sm;
    flex-wrap: wrap;
  }
  
  .quick-btn {
    @include button-reset;
    @include focus-outline;
    padding: 6px $spacing-md;
    background: $color-white;
    border: 1px solid $color-gray-300;
    border-radius: 6px;
    font-size: $font-size-sm;
    color: $color-gray-700;
    transition: $transition-base;
    
    &:hover {
      background: $color-gray-100;
      border-color: $color-gray-400;
    }
    
    &:active {
      transform: scale(0.95);
    }
  }
}

// Responsive design
@media (max-width: 768px) {
  .calendar-wrapper {
    width: 100%;
    max-width: 100%;
  }
  
  .sidebar-calendar {
    .calendar-header {
      padding: $spacing-lg;
    }
    
    .calendar-body {
      padding: $spacing-lg;
    }
    
    .quick-actions {
      padding: $spacing-md $spacing-lg;
    }
    
    .nav-button {
      width: 32px;
      height: 32px;
      font-size: $font-size-base;
    }
    
    .month-year {
      font-size: $font-size-lg;
    }
  }
}

// Dark theme support
@media (prefers-color-scheme: dark) {
  .sidebar-calendar {
    --calendar-bg: #{$color-gray-800};
    --text-color: #{$color-white};
    --text-muted: #{$color-gray-300};
    --border-color: #{$color-gray-700};
    --hover-bg: #{$color-gray-700};
    
    background: var(--calendar-bg);
    color: var(--text-color);
    
    .weekday {
      color: var(--text-muted);
    }
    
    .day {
      &:hover {
        background: var(--hover-bg);
      }
      
      &.other-month {
        color: var(--text-muted);
      }
    }
    
    .quick-actions {
      background: var(--hover-bg);
      border-color: var(--border-color);
    }
    
    .quick-btn {
      background: var(--calendar-bg);
      border-color: var(--border-color);
      color: var(--text-color);
      
      &:hover {
        background: var(--hover-bg);
      }
    }
  }
  
  .calendar-wrapper {
    background: var(--calendar-bg, #{$color-gray-800});
  }
}

// Accessibility improvements
@media (prefers-reduced-motion: reduce) {
  .sidebar-calendar {
    .day,
    .nav-button,
    .quick-btn,
    .month-year {
      transition: none;
      
      &:hover {
        transform: none;
      }
    }
  }
}

// High contrast mode
@media (prefers-contrast: high) {
  .sidebar-calendar {
    .day {
      border: 1px solid currentColor;
      
      &.selected-day,
      &.selected-week,
      &.range-start,
      &.range-end {
        background: $color-gray-900;
        color: $color-white;
        border-color: $color-white;
      }
      
      &.in-range {
        background: $color-gray-100;
        border-color: $color-gray-900;
      }
    }
  }
}

// Print styles
@media print {
  .sidebar-calendar {
    .calendar-header {
      background: $color-white !important;
      color: $color-gray-900 !important;
    }
    
    .nav-button,
    .quick-actions {
      display: none;
    }
    
    .day {
      &.selected-day,
      &.selected-week,
      &.range-start,
      &.range-end {
        background: $color-gray-900 !important;
        color: $color-white !important;
      }
      
      &.in-range {
        background: $color-gray-200 !important;
        color: $color-gray-900 !important;
      }
    }
  }
}