/* ================================================================
   AGE CALCULATOR - ENHANCED DATE INPUT DESIGN
   Beautiful calendar picker with custom styling
   ================================================================ */

/* Container for date input */
.agec-date-input-wrapper {
  position: relative;
  width: 100%;
}

/* Enhanced date input styling */
.agec-input[type="date"] {
  width: 100%;
  min-height: 52px;
  padding: 0.75rem 3.5rem 0.75rem 1rem;
  font-size: 1.05rem;
  font-weight: 600;
  color: #1e293b;
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  border: 2px solid #e0e7ff;
  border-radius: 14px;
  box-shadow:
    0 2px 8px rgba(99, 102, 241, 0.06),
    inset 0 1px 2px rgba(255, 255, 255, 0.8);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  position: relative;
}

/* Focus state */
.agec-input[type="date"]:focus {
  outline: none;
  border-color: #6366f1;
  box-shadow:
    0 0 0 4px rgba(99, 102, 241, 0.12),
    0 4px 16px rgba(99, 102, 241, 0.15),
    inset 0 1px 2px rgba(255, 255, 255, 0.9);
  transform: translateY(-1px);
}

/* Hover state */
.agec-input[type="date"]:hover:not(:focus) {
  border-color: #c7d2fe;
  box-shadow:
    0 4px 12px rgba(99, 102, 241, 0.1),
    inset 0 1px 2px rgba(255, 255, 255, 0.8);
}

/* Invalid state */
.agec-input[type="date"]:invalid {
  border-color: #fca5a5;
  background: linear-gradient(135deg, #fef2f2 0%, #ffffff 100%);
}

/* Custom calendar icon */
.agec-input[type="date"]::after {
  content: '📅';
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.5rem;
  pointer-events: none;
  filter: drop-shadow(0 2px 4px rgba(99, 102, 241, 0.2));
  transition: transform 0.3s ease;
}

.agec-input[type="date"]:focus::after {
  transform: translateY(-50%) scale(1.1);
}

/* Hide default calendar icon in webkit browsers */
.agec-input[type="date"]::-webkit-calendar-picker-indicator {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  width: 2.5rem;
  height: 2.5rem;
  cursor: pointer;
  opacity: 0;
  z-index: 2;
}

/* Custom calendar button overlay */
.agec-date-input-wrapper::after {
  content: '';
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  width: 2.5rem;
  height: 2.5rem;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  border-radius: 10px;
  display: grid;
  place-items: center;
  pointer-events: none;
  box-shadow:
    0 4px 12px rgba(99, 102, 241, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  transition: all 0.3s ease;
  z-index: 1;
}

/* Calendar icon inside button */
.agec-date-input-wrapper::before {
  content: '📅';
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  width: 2.5rem;
  height: 2.5rem;
  display: grid;
  place-items: center;
  font-size: 1.35rem;
  filter: brightness(0) invert(1) drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
  pointer-events: none;
  z-index: 2;
  transition: transform 0.3s ease;
}

/* Hover effect on calendar button */
.agec-input[type="date"]:hover + .agec-date-input-wrapper::after,
.agec-date-input-wrapper:has(.agec-input[type="date"]:hover)::after {
  transform: translateY(-50%) scale(1.05);
  box-shadow:
    0 6px 16px rgba(99, 102, 241, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.agec-input[type="date"]:hover + .agec-date-input-wrapper::before,
.agec-date-input-wrapper:has(.agec-input[type="date"]:hover)::before {
  transform: translateY(-50%) scale(1.1);
}

/* Focus effect on calendar button */
.agec-input[type="date"]:focus + .agec-date-input-wrapper::after,
.agec-date-input-wrapper:has(.agec-input[type="date"]:focus)::after {
  transform: translateY(-50%) scale(1.1) rotate(-5deg);
  box-shadow:
    0 8px 20px rgba(99, 102, 241, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.agec-input[type="date"]:focus + .agec-date-input-wrapper::before,
.agec-date-input-wrapper:has(.agec-input[type="date"]:focus)::before {
  transform: translateY(-50%) scale(1.15);
  animation: iconPulse 0.6s ease;
}

@keyframes iconPulse {
  0%, 100% { transform: translateY(-50%) scale(1.15); }
  50% { transform: translateY(-50%) scale(1.25); }
}

/* Placeholder text styling */
.agec-input[type="date"]:not(:focus):invalid {
  color: #94a3b8;
}

/* Label enhancement */
.agec-date-input-wrapper .agec-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
  font-weight: 700;
  color: #1e293b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.agec-date-input-wrapper .agec-label::before {
  content: '📆';
  font-size: 1.1rem;
  filter: drop-shadow(0 2px 4px rgba(99, 102, 241, 0.15));
  flex-shrink: 0;
}

/* Optional date field */
.agec-date-optional .agec-label::after {
  content: 'Optional';
  font-size: 0.7rem;
  font-weight: 600;
  color: #6366f1;
  background: #ede9fe;
  padding: 0.15rem 0.4rem;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-left: auto;
  flex-shrink: 0;
  white-space: nowrap;
}

/* Filled state indicator */
.agec-input[type="date"]:valid:not(:placeholder-shown) {
  border-color: #10b981;
  background: linear-gradient(135deg, #f0fdf4 0%, #ffffff 100%);
}

.agec-input[type="date"]:valid:not(:placeholder-shown) + .agec-date-input-wrapper::after {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

/* Success checkmark for filled inputs */
.agec-date-input-wrapper:has(.agec-input[type="date"]:valid:not(:placeholder-shown))::after {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.agec-date-input-wrapper:has(.agec-input[type="date"]:valid:not(:placeholder-shown))::before {
  content: '✓';
  font-size: 1.5rem;
  font-weight: 900;
}

/* Date input format hint */
.agec-date-format-hint {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: #6b7280;
  font-weight: 500;
}

.agec-date-format-hint::before {
  content: 'ℹ️';
  font-size: 0.95rem;
}

/* Responsive adjustments */
@media (max-width: 479px) {
  .agec-input[type="date"] {
    min-height: 50px;
    padding: 0.7rem 3.25rem 0.7rem 0.9rem;
    font-size: 1rem;
  }

  .agec-date-input-wrapper::after,
  .agec-date-input-wrapper::before {
    right: 0.65rem;
    width: 2.25rem;
    height: 2.25rem;
  }

  .agec-date-input-wrapper::before {
    font-size: 1.2rem;
  }

  .agec-input[type="date"]::-webkit-calendar-picker-indicator {
    right: 0.65rem;
    width: 2.25rem;
    height: 2.25rem;
  }

  .agec-date-format-hint {
    font-size: 0.8rem;
  }
}

/* Tablet and desktop - compact side-by-side layout */
@media (min-width: 480px) and (max-width: 1023px) {
  .agec-input[type="date"] {
    min-height: 50px;
    padding: 0.7rem 3rem 0.7rem 0.85rem;
    font-size: 0.95rem;
  }

  .agec-date-input-wrapper .agec-label {
    font-size: 0.85rem;
  }

  .agec-date-format-hint {
    font-size: 0.78rem;
    margin-top: 0.4rem;
  }

  .agec-date-optional .agec-label::after {
    font-size: 0.65rem;
    padding: 0.12rem 0.35rem;
  }
}

/* Medium screens - slightly larger */
@media (min-width: 768px) and (max-width: 1023px) {
  .agec-date-input-wrapper .agec-label {
    font-size: 0.88rem;
  }
}

/* Large desktop - full size */
@media (min-width: 1024px) {
  .agec-input[type="date"] {
    font-size: 1rem;
  }

  .agec-date-input-wrapper .agec-label {
    font-size: 0.95rem;
  }
}

/* Firefox specific fixes */
@-moz-document url-prefix() {
  .agec-input[type="date"] {
    padding-right: 1rem;
  }
}

/* Animation for calendar opening */
@keyframes calendarOpen {
  from {
    opacity: 0;
    transform: translateY(-10px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Enhanced webkit calendar picker dropdown */
.agec-input[type="date"]::-webkit-calendar-picker-indicator:hover {
  cursor: pointer;
}

/* Loading state (optional) */
.agec-date-input-wrapper.loading .agec-input[type="date"] {
  pointer-events: none;
  opacity: 0.7;
}

.agec-date-input-wrapper.loading::before {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from { transform: translateY(-50%) rotate(0deg); }
  to { transform: translateY(-50%) rotate(360deg); }
}

/* Disabled state */
.agec-input[type="date"]:disabled {
  background: #f1f5f9;
  border-color: #e2e8f0;
  color: #94a3b8;
  cursor: not-allowed;
  opacity: 0.6;
}

.agec-date-input-wrapper:has(.agec-input[type="date"]:disabled)::after {
  opacity: 0.5;
  background: #94a3b8;
}

/* Required field indicator */
.agec-date-input-wrapper.required .agec-label::after {
  content: '*';
  color: #ef4444;
  font-weight: 900;
  margin-left: 0.25rem;
  font-size: 1.1rem;
}

/* Tooltip for calendar icon */
.agec-date-input-wrapper[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  right: 0;
  top: -2.5rem;
  background: #1f2937;
  color: #ffffff;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  font-size: 0.85rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  z-index: 100;
}

.agec-date-input-wrapper[data-tooltip]::before {
  content: '';
  position: absolute;
  right: 1.5rem;
  top: -0.5rem;
  border: 6px solid transparent;
  border-top-color: #1f2937;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 100;
}

.agec-date-input-wrapper:hover[data-tooltip]::after,
.agec-date-input-wrapper:hover[data-tooltip]::before {
  opacity: 1;
}

/* Clear button for date inputs (if value exists) */
.agec-input[type="date"]::-webkit-clear-button {
  display: none;
}

.agec-input[type="date"]::-webkit-inner-spin-button {
  display: none;
}
