/**
 * DatePicker CSS Styles
 * Modern, responsive design with theme support and CSS custom properties
 */

/* CSS Custom Properties (Variables) */
:root {
  /* Colors */
  --dp-primary-color: #007bff;
  --dp-primary-hover: #0056b3;
  --dp-primary-light: #e3f2fd;
  --dp-secondary-color: #6c757d;
  --dp-secondary-hover: #545b62;
  --dp-success-color: #28a745;
  --dp-danger-color: #dc3545;
  --dp-warning-color: #ffc107;
  --dp-info-color: #17a2b8;

  /* Background Colors */
  --dp-bg-primary: #ffffff;
  --dp-bg-secondary: #f8f9fa;
  --dp-bg-muted: #e9ecef;
  --dp-bg-dark: #2d3748;
  --dp-bg-hover: #e9ecef;

  /* Text Colors */
  --dp-text-primary: #333333;
  --dp-text-secondary: #666666;
  --dp-text-muted: #999999;
  --dp-text-light: #cccccc;
  --dp-text-white: #ffffff;
  --dp-text-dark: #e2e8f0;

  /* Border Colors */
  --dp-border-color: #dddddd;
  --dp-border-light: #e9ecef;
  --dp-border-dark: #4a5568;
  --dp-border-focus: #007bff;

  /* Spacing */
  --dp-spacing-xs: 4px;
  --dp-spacing-sm: 8px;
  --dp-spacing-md: 12px;
  --dp-spacing-lg: 16px;
  --dp-spacing-xl: 20px;
  --dp-spacing-xxl: 24px;

  /* Sizes */
  --dp-font-size-xs: 12px;
  --dp-font-size-sm: 13px;
  --dp-font-size-base: 14px;
  --dp-font-size-lg: 16px;
  --dp-font-size-xl: 18px;

  /* Component Sizes */
  --dp-day-size: 36px;
  --dp-button-height: 32px;
  --dp-input-height: 40px;
  --dp-container-min-width: 280px;

  /* Border Radius */
  --dp-border-radius-sm: 4px;
  --dp-border-radius-md: 6px;
  --dp-border-radius-lg: 8px;
  --dp-border-radius-round: 50%;

  /* Shadows */
  --dp-shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
  --dp-shadow-md: 0 4px 12px rgba(0, 0, 0, 0.15);
  --dp-shadow-lg: 0 8px 25px rgba(0, 0, 0, 0.15);
  --dp-shadow-focus: 0 0 0 2px rgba(0, 123, 255, 0.25);

  /* Transitions */
  --dp-transition-fast: 0.15s ease;
  --dp-transition-base: 0.2s ease;
  --dp-transition-slow: 0.3s ease;

  /* Z-Index */
  --dp-z-index-dropdown: 1000;
  --dp-z-index-popup: 9999;

  /* Font Family */
  --dp-font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    sans-serif;
  --dp-font-family-mono: "Monaco", "Menlo", "Ubuntu Mono", monospace;
}

/* Theme Customization Examples */
/* 
  Override these variables to customize the DatePicker:
  
  .my-custom-datepicker {
    --dp-primary-color: #ff6b6b;
    --dp-primary-hover: #ff5252;
    --dp-primary-light: #ffebee;
    --dp-day-size: 40px;
    --dp-border-radius-md: 12px;
  }
*/

/* Green Theme Example */
.datepicker-container.green-theme {
  --dp-primary-color: #28a745;
  --dp-primary-hover: #218838;
  --dp-primary-light: #d4edda;
  --dp-border-focus: #28a745;
  --dp-shadow-focus: 0 0 0 2px rgba(40, 167, 69, 0.25);
}

/* Purple Theme Example */
.datepicker-container.purple-theme {
  --dp-primary-color: #6f42c1;
  --dp-primary-hover: #5a32a3;
  --dp-primary-light: #e2d9f3;
  --dp-border-focus: #6f42c1;
  --dp-shadow-focus: 0 0 0 2px rgba(111, 66, 193, 0.25);
}

/* Large Size Theme Example */
.datepicker-container.large-theme {
  --dp-day-size: 48px;
  --dp-button-height: 40px;
  --dp-font-size-base: 16px;
  --dp-font-size-lg: 18px;
  --dp-spacing-lg: 20px;
  --dp-container-min-width: 320px;
}

/* Base Container Styles */
.datepicker-container {
  font-family: var(--dp-font-family);
  font-size: var(--dp-font-size-base);
  line-height: 1.4;
  color: var(--dp-text-primary);
  background: var(--dp-bg-primary);
  border: 1px solid var(--dp-border-color);
  border-radius: var(--dp-border-radius-lg);
  box-shadow: var(--dp-shadow-md);
  z-index: var(--dp-z-index-dropdown);
  user-select: none;
  min-width: var(--dp-container-min-width);
}

/* Popup specific styles */
.datepicker-popup {
  position: absolute;
  display: none;
  z-index: var(--dp-z-index-popup);
}

.datepicker-popup.datepicker-open {
  display: block;
}

/* Fixed positioning support */
.datepicker-popup.fixed-position {
  position: fixed;
}

/* Custom positioning support */
.datepicker-popup.custom-position {
  position: absolute;
}

/* Inline specific styles */
.datepicker-inline {
  position: relative;
  display: block;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Input Wrapper Styles */
.datepicker-input-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: 100%;
}

.datepicker-input-wrapper.icon-right {
  flex-direction: row;
}

.datepicker-input-wrapper.icon-left {
  flex-direction: row-reverse;
}

/* Input Styles */
.datepicker-input {
  width: 100%;
  padding: var(--dp-spacing-sm) var(--dp-spacing-md);
  border: 1px solid var(--dp-border-color);
  border-radius: var(--dp-border-radius-sm);
  font-size: var(--dp-font-size-base);
  outline: none;
  transition: border-color var(--dp-transition-base);
  flex: 1;
}

.datepicker-input-wrapper.icon-right .datepicker-input {
  padding-right: var(--dp-input-height);
}

.datepicker-input-wrapper.icon-left .datepicker-input {
  padding-left: var(--dp-input-height);
}

.datepicker-input:focus {
  border-color: var(--dp-border-focus);
  box-shadow: var(--dp-shadow-focus);
}

/* Icon Styles */
.datepicker-icon {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: var(--dp-spacing-lg);
  height: var(--dp-spacing-lg);
  color: var(--dp-text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--dp-transition-base);
  z-index: 1;
}

.datepicker-input-wrapper.icon-right .datepicker-icon {
  right: var(--dp-spacing-md);
}

.datepicker-input-wrapper.icon-left .datepicker-icon {
  left: var(--dp-spacing-md);
}

.datepicker-icon:hover {
  color: var(--dp-primary-color);
}

.datepicker-icon svg {
  width: 100%;
  height: 100%;
}

/* Icon variations */
.datepicker-icon.icon-calendar {
  /* Default calendar icon styles */
}

.datepicker-icon.icon-custom {
  /* Custom icon styles */
}

/* Disabled state */
.datepicker-input:disabled + .datepicker-icon,
.datepicker-input-wrapper.disabled .datepicker-icon {
  color: #ccc;
  cursor: not-allowed;
}

.datepicker-input:disabled + .datepicker-icon:hover,
.datepicker-input-wrapper.disabled .datepicker-icon:hover {
  color: #ccc;
}

/* Calendar Styles */
.datepicker-calendar {
  padding: 16px;
}

/* Header Styles */
.datepicker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--dp-spacing-lg);
  padding: 0 var(--dp-spacing-xs);
}

.datepicker-month-year {
  display: flex;
  align-items: center;
  gap: var(--dp-spacing-sm);
}

.datepicker-month-btn,
.datepicker-year-btn {
  background: none;
  border: none;
  font-size: var(--dp-font-size-lg);
  font-weight: 600;
  color: var(--dp-text-primary);
  cursor: pointer;
  padding: var(--dp-spacing-xs) var(--dp-spacing-sm);
  border-radius: var(--dp-border-radius-sm);
  transition: background-color var(--dp-transition-base);
}

.datepicker-month-btn:hover,
.datepicker-year-btn:hover {
  background-color: var(--dp-bg-secondary);
}

/* Dropdown Styles */
.datepicker-month-dropdown,
.datepicker-year-dropdown {
  background: var(--dp-bg-primary);
  border: 1px solid var(--dp-border-color);
  border-radius: var(--dp-border-radius-sm);
  padding: var(--dp-spacing-xs) var(--dp-spacing-sm);
  font-size: var(--dp-font-size-base);
  font-weight: 600;
  color: var(--dp-text-primary);
  cursor: pointer;
  outline: none;
  transition: border-color var(--dp-transition-base);
  margin: 0 2px;
}

.datepicker-month-dropdown:focus,
.datepicker-year-dropdown:focus {
  border-color: #007bff;
  box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

.datepicker-month-dropdown:hover,
.datepicker-year-dropdown:hover {
  border-color: #adb5bd;
}

.datepicker-month-dropdown {
  min-width: 120px;
}

.datepicker-year-dropdown {
  min-width: 80px;
}

.datepicker-prev-btn,
.datepicker-next-btn {
  background: none;
  border: none;
  width: var(--dp-button-height);
  height: var(--dp-button-height);
  border-radius: var(--dp-border-radius-round);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--dp-font-size-xl);
  color: var(--dp-text-secondary);
  transition: all var(--dp-transition-base);
}

.datepicker-prev-btn:hover,
.datepicker-next-btn:hover {
  background-color: var(--dp-bg-secondary);
  color: var(--dp-text-primary);
}

/* Weekdays Header */
.datepicker-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  margin-bottom: 8px;
}

.weekday {
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: #666;
  padding: 8px 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Days Grid */
.datepicker-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.datepicker-week {
  display: contents;
}

.datepicker-day {
  background: none;
  border: none;
  width: var(--dp-day-size);
  height: var(--dp-day-size);
  border-radius: var(--dp-border-radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--dp-font-size-base);
  color: var(--dp-text-primary);
  transition: all var(--dp-transition-base);
  position: relative;
}

.datepicker-day:hover:not(:disabled) {
  background-color: var(--dp-bg-hover);
}

.datepicker-day:disabled {
  color: var(--dp-text-light);
  cursor: not-allowed;
  background-color: var(--dp-bg-secondary);
  position: relative;
}

.datepicker-day:disabled:hover {
  background-color: var(--dp-bg-secondary);
  color: var(--dp-text-light);
}

/* Strikethrough effect for disabled dates */
.datepicker-day:disabled::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 10%;
  right: 10%;
  height: 1px;
  background-color: #dc3545;
  transform: translateY(-50%);
}

/* Different styling for different types of disabled dates */
.datepicker-day.disabled-weekend {
  background-color: #fff3cd;
  color: #856404;
}

.datepicker-day.disabled-past {
  background-color: #f8d7da;
  color: #721c24;
}

.datepicker-day.disabled-future {
  background-color: #d1ecf1;
  color: #0c5460;
}

.datepicker-day.disabled-custom {
  background-color: #e2e3e5;
  color: #383d41;
}

.datepicker-day.other-month {
  color: var(--dp-text-muted);
}

.datepicker-day.today {
  background-color: var(--dp-primary-light);
  color: var(--dp-primary-color);
  font-weight: 600;
}

.datepicker-day.selected {
  background-color: var(--dp-primary-color);
  color: var(--dp-text-white);
  font-weight: 600;
}

.datepicker-day.selected:hover {
  background-color: var(--dp-primary-hover);
}

/* Range Mode Styles */
.datepicker-day.in-range {
  background-color: var(--dp-primary-light);
  color: var(--dp-primary-color);
}

.datepicker-day.range-start {
  background-color: var(--dp-primary-color);
  color: var(--dp-text-white);
  border-radius: var(--dp-border-radius-md) 0 0 var(--dp-border-radius-md);
}

.datepicker-day.range-end {
  background-color: var(--dp-primary-color);
  color: var(--dp-text-white);
  border-radius: 0 var(--dp-border-radius-md) var(--dp-border-radius-md) 0;
}

.datepicker-day.range-start.range-end {
  border-radius: var(--dp-border-radius-md);
}

/* Time Picker Styles */
.datepicker-time {
  border-top: 1px solid #eee;
  padding-top: 16px;
  margin-top: 16px;
}

.time-input-group {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.time-hours,
.time-minutes,
.time-seconds {
  width: 50px;
  padding: 6px 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
  text-align: center;
  font-size: 14px;
  outline: none;
}

.time-hours:focus,
.time-minutes:focus,
.time-seconds:focus {
  border-color: #007bff;
  box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

.time-ampm {
  padding: 6px 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
  outline: none;
  background: white;
}

.time-ampm:focus {
  border-color: #007bff;
  box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

/* Footer Styles */
.datepicker-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #eee;
  gap: 8px;
  flex-wrap: wrap;
}

/* Range Confirmation Buttons */
.datepicker-range-buttons {
  display: flex;
  gap: 8px;
  margin-right: auto;
}

.datepicker-apply-btn,
.datepicker-cancel-btn {
  padding: 6px 16px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
  outline: none;
}

.datepicker-apply-btn {
  background-color: #007bff;
  color: white;
}

.datepicker-apply-btn:hover {
  background-color: #0056b3;
}

.datepicker-apply-btn:focus {
  box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

.datepicker-cancel-btn {
  background-color: #6c757d;
  color: white;
}

.datepicker-cancel-btn:hover {
  background-color: #545b62;
}

.datepicker-cancel-btn:focus {
  box-shadow: 0 0 0 2px rgba(108, 117, 125, 0.25);
}

.datepicker-clear-btn,
.datepicker-today-btn {
  background: none;
  border: 1px solid #ddd;
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  color: #666;
  transition: all 0.2s ease;
}

.datepicker-clear-btn:hover,
.datepicker-today-btn:hover {
  background-color: #f8f9fa;
  border-color: #adb5bd;
  color: #333;
}

/* Theme Variations */

/* Dark Theme */
.datepicker-container.dark {
  background: #2d3748;
  border-color: #4a5568;
  color: #e2e8f0;
}

.datepicker-container.dark .datepicker-input {
  background: #2d3748;
  border-color: #4a5568;
  color: #e2e8f0;
}

.datepicker-container.dark .datepicker-icon {
  color: #a0aec0;
}

.datepicker-container.dark .datepicker-icon:hover {
  color: #e2e8f0;
}

.datepicker-container.dark .datepicker-month-btn,
.datepicker-container.dark .datepicker-year-btn {
  color: #e2e8f0;
}

.datepicker-container.dark .datepicker-month-btn:hover,
.datepicker-container.dark .datepicker-year-btn:hover {
  background-color: #4a5568;
}

.datepicker-container.dark .datepicker-prev-btn,
.datepicker-container.dark .datepicker-next-btn {
  color: #a0aec0;
}

.datepicker-container.dark .datepicker-prev-btn:hover,
.datepicker-container.dark .datepicker-next-btn:hover {
  background-color: #4a5568;
  color: #e2e8f0;
}

.datepicker-container.dark .weekday {
  color: #a0aec0;
}

.datepicker-container.dark .datepicker-day {
  color: #e2e8f0;
}

.datepicker-container.dark .datepicker-day:hover:not(:disabled) {
  background-color: #4a5568;
}

.datepicker-container.dark .datepicker-day.other-month {
  color: #718096;
}

.datepicker-container.dark .datepicker-day.today {
  background-color: #2b6cb0;
  color: white;
}

.datepicker-container.dark .datepicker-day.selected {
  background-color: #3182ce;
  color: white;
}

.datepicker-container.dark .datepicker-day.in-range {
  background-color: #2c5282;
  color: #bee3f8;
}

.datepicker-container.dark .datepicker-clear-btn,
.datepicker-container.dark .datepicker-today-btn {
  border-color: #4a5568;
  color: #a0aec0;
}

.datepicker-container.dark .datepicker-clear-btn:hover,
.datepicker-container.dark .datepicker-today-btn:hover {
  background-color: #4a5568;
  color: #e2e8f0;
}

.datepicker-container.dark .datepicker-month-dropdown,
.datepicker-container.dark .datepicker-year-dropdown {
  background: #2d3748;
  border-color: #4a5568;
  color: #e2e8f0;
}

.datepicker-container.dark .datepicker-month-dropdown:focus,
.datepicker-container.dark .datepicker-year-dropdown:focus {
  border-color: #3182ce;
  box-shadow: 0 0 0 2px rgba(49, 130, 206, 0.25);
}

.datepicker-container.dark .datepicker-month-dropdown:hover,
.datepicker-container.dark .datepicker-year-dropdown:hover {
  border-color: #718096;
}

.datepicker-container.dark .datepicker-apply-btn {
  background-color: #3182ce;
}

.datepicker-container.dark .datepicker-apply-btn:hover {
  background-color: #2c5282;
}

.datepicker-container.dark .datepicker-cancel-btn {
  background-color: #718096;
}

.datepicker-container.dark .datepicker-cancel-btn:hover {
  background-color: #4a5568;
}

.datepicker-container.dark .datepicker-day:disabled {
  background-color: #2d3748;
  color: #718096;
}

.datepicker-container.dark .datepicker-day:disabled:hover {
  background-color: #2d3748;
  color: #718096;
}

.datepicker-container.dark .datepicker-day.disabled-weekend {
  background-color: #744210;
  color: #fef3c7;
}

.datepicker-container.dark .datepicker-day.disabled-past {
  background-color: #7f1d1d;
  color: #fecaca;
}

.datepicker-container.dark .datepicker-day.disabled-future {
  background-color: #164e63;
  color: #a7f3d0;
}

.datepicker-container.dark .datepicker-day.disabled-custom {
  background-color: #374151;
  color: #d1d5db;
}

/* Minimal Theme */
.datepicker-container.minimal {
  border: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  border-radius: 0;
}

.datepicker-container.minimal .datepicker-day {
  border-radius: 0;
}

.datepicker-container.minimal .datepicker-day.selected {
  background-color: #000;
}

/* Responsive Design */
@media (max-width: 480px) {
  .datepicker-container {
    min-width: 100%;
    max-width: 100vw;
    border-radius: 0;
    border-left: none;
    border-right: none;
  }

  .datepicker-popup {
    position: fixed;
    top: auto !important;
    left: 0 !important;
    bottom: 0;
    width: 100%;
  }

  .datepicker-calendar {
    padding: 20px;
  }

  .datepicker-day {
    width: 40px;
    height: 40px;
    font-size: 16px;
  }

  .datepicker-header {
    margin-bottom: 20px;
  }

  .datepicker-prev-btn,
  .datepicker-next-btn {
    width: 40px;
    height: 40px;
    font-size: 20px;
  }
}

/* Accessibility Improvements */
.datepicker-day:focus {
  outline: 2px solid #007bff;
  outline-offset: 2px;
}

.datepicker-prev-btn:focus,
.datepicker-next-btn:focus,
.datepicker-month-btn:focus,
.datepicker-year-btn:focus {
  outline: 2px solid #007bff;
  outline-offset: 2px;
}

/* Animation for smooth transitions */
.datepicker-container {
  animation: fadeIn 0.2s ease-out;
}

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

/* Print styles */
@media print {
  .datepicker-popup {
    display: none !important;
  }
}
