* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  line-height: 1.6;
  background-color: #f5f7fa;
  color: #2d3748;
}

.site-header {
  text-align: center;
  padding: 2.5rem 0;
  background: linear-gradient(135deg, #1a365d, #2b6cb0);
  margin-bottom: 2rem;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  position: relative;
  overflow: hidden;
}

.site-header:before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0) 70%);
  animation: shimmer 10s linear infinite;
}

@keyframes shimmer {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.site-logo {
  font-size: 3.5rem;
  font-weight: 800;
  text-transform: none;
  letter-spacing: 1px;
  margin: 0;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
  font-family: 'Poppins', 'Montserrat', 'Segoe UI', Roboto, sans-serif;
  display: inline-block;
  color: #ffffff;
  background: none;
  -webkit-background-clip: unset;
  -webkit-text-fill-color: unset;
  position: relative;
}

.site-logo .highlight {
  color: #ffd700;
  -webkit-text-fill-color: #ffd700;
  font-weight: 700;
  position: relative;
  display: inline-block;
  transition: all 0.3s ease;
  background: linear-gradient(135deg, #ffd700 50%, #ffd700 100%);
  -webkit-background-clip: text;
}

.site-logo .highlight:after {
  content: '';
  position: absolute;
  bottom: 8px;
  left: 0;
  width: 100%;
  height: 4px;
  background: #ffd700;
  border-radius: 2px;
  transform: scaleX(0);
  transform-origin: right;
  transition: transform 0.3s ease;
}

.site-logo:hover .highlight:after {
  transform: scaleX(1);
  transform-origin: left;
}

.site-tagline {
  color: rgba(255,255,255,0.9);
  font-size: 1.2rem;
  margin: 1rem 0 0;
  font-weight: 300;
  letter-spacing: 0.5px;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.1);
}

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

h1 {
  text-align: center;
  margin-bottom: 2.5rem;
  color: #2b6cb0;
  font-size: 2.5rem;
  font-weight: 600;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.1);
}

.service-card {
  background: white;
  border-radius: 12px;
  padding: 2rem;
  margin-bottom: 2rem;
  box-shadow: 0 4px 6px rgba(0,0,0,0.05), 0 1px 3px rgba(0,0,0,0.1);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  content-visibility: auto;
  contain-intrinsic-size: 0 500px;
}

.service-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.12);
}

h2 {
  color: #2b6cb0;
  margin-bottom: 1.5rem;
  font-size: 1.5rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.input-group {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  align-items: center;
}

input, select {
  padding: 0.75rem 1rem;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  font-size: 1rem;
  transition: all 0.2s ease;
  background-color: #fff;
}

input:focus, select:focus {
  outline: 3px solid #4299e1;
  outline-offset: 2px;
  border-color: #4299e1;
  box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.15);
}

select {
  cursor: pointer;
  padding-right: 2.5rem;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%232b6cb0'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 1.25rem;
}

input[type="number"], input[type="date"] {
  width: 200px;
}

#dateType {
  width: 320px;
}

#unitCategory {
  min-width: 220px;
}

#fromUnit, #toUnit {
  min-width: 160px;
}

button {
  background-color: #2b6cb0;
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 500;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

button:focus {
  outline: 3px solid #4299e1;
  outline-offset: 2px;
}

button:hover {
  background-color: #2c5282;
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
}

a:focus {
  outline: 3px solid #4299e1;
  outline-offset: 2px;
}

.result-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 1rem 0;
  padding: 1rem;
  border-radius: 8px;
  background-color: #f8fafc;
  border: 1px solid #e2e8f0;
  animation: fadeIn 0.3s ease-out;
}

.copy-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  color: #2b6cb0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.copy-btn:hover {
  background-color: rgba(43, 108, 176, 0.1);
  color: #2c5282;
}

.copy-btn svg {
  width: 1.25rem;
  height: 1.25rem;
}

.result-text {
  flex-grow: 1;
  font-size: 1.1rem;
  line-height: 1.5;
}

.date-result-item {
  display: flex;
  align-items: center;
  margin: 1rem 0;
  padding: 1rem;
  background-color: #f8fafc;
  border-radius: 8px;
  gap: 1rem;
  border: 1px solid #e2e8f0;
  animation: fadeIn 0.3s ease-out;
}

.date-label {
  font-weight: 600;
  min-width: 90px;
  color: #2b6cb0;
}

.date-value {
  font-size: 1.1rem;
}

#dateResult, #unitResult, #ageResult, #numberResult {
  margin-top: 1.5rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

footer {
  background-color: #2b6cb0;
  color: white;
  padding: 1rem 0;
  margin-top: 2rem;
  text-align: center;
}

.calendar-container {
  position: fixed;
  left: 43px;
  top: 180px;
  width: 322px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
  padding: 1rem;
  z-index: 100;
  font-family: 'Segoe UI', Roboto, sans-serif;
  border: 1px solid rgba(43, 108, 176, 0.1);
  backdrop-filter: blur(8px);
  transition: all 0.3s ease;
  touch-action: pan-y pinch-zoom;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  cursor: grab;
}

.calendar-container:active {
  cursor: grabbing;
}

.calendar-container.swiping {
  transform: scale(0.98);
  opacity: 0.8;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.calendar-controls {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.5rem;
}

.today-btn {
  background: transparent;
  border: 2px solid #2b6cb0;
  color: #2b6cb0;
  font-size: 0.75rem;
  padding: 0.3rem 0.6rem;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.today-btn:hover {
  background: #2b6cb0;
  color: white;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(43, 108, 176, 0.2);
}

.today-btn:active {
  transform: translateY(0);
}

.calendar-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid rgba(43, 108, 176, 0.1);
}

.calendar-header h3 {
  margin: 0;
  font-weight: 600;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.calendar-header .gregorian-month {
  color: #2b6cb0;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.hijri-months {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: #ed8936;
}

.prev-hijri-month,
.next-hijri-month {
  opacity: 0.5;
  font-size: 0.7rem;
}

.current-hijri-month {
  font-weight: 600;
  color: #ed8936;
}

.gregorian-months {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  color: #2b6cb0;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.prev-gregorian-month,
.next-gregorian-month {
  opacity: 0.5;
  font-size: 0.7rem;
  color: #2b6cb0;
}

.current-gregorian-month {
  font-weight: 700;
  color: #2b6cb0;
}

.calendar-nav {
  display: flex;
  gap: 0.5rem;
}

.calendar-nav button {
  background: #f8fafc;
  border: 2px solid #2b6cb0;
  color: #2b6cb0;
  cursor: pointer;
  padding: 0.35rem;
  border-radius: 8px;
  font-size: 1rem;
  line-height: 1;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  font-weight: bold;
}

.calendar-nav button:hover {
  background: #2b6cb0;
  color: white;
}

.calendar-nav button:active {
  transform: translateY(0);
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  text-align: center;
  transition: opacity 0.2s ease;
}

.weekday-header {
  font-weight: 600;
  color: #2b6cb0;
  padding: 0.35rem;
  font-size: 0.7rem;
  opacity: 0.8;
}

.calendar-day {
  padding: 0.35rem 0.2rem;
  border-radius: 8px;
  cursor: pointer;
  position: relative;
  font-size: 0.7rem;
  border: 2px solid transparent;
  transition: all 0.2s ease;
  background: rgba(255, 255, 255, 0.8);
}

.calendar-day:hover {
  background: rgba(43, 108, 176, 0.1);
  border-color: #2b6cb0;
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 4px 12px rgba(43, 108, 176, 0.1);
  z-index: 1;
}

.calendar-day.today {
  background: #ebf8ff;
  border: 2px solid #2b6cb0;
  box-shadow: 0 4px 12px rgba(43, 108, 176, 0.15);
  transform: scale(1.05);
}

.calendar-day.holiday {
  background: #fffaf0;
  border: 2px solid #ed8936;
  box-shadow: 0 4px 12px rgba(237, 137, 54, 0.15);
}

.calendar-day .hijri-date {
  font-size: 0.6rem;
  color: #ed8936;
  margin-top: 3px;
  font-weight: 500;
}

.calendar-day .gregorian-date {
  color: #2b6cb0;
  font-weight: 600;
}

.calendar-day.today .gregorian-date {
  color: #2b6cb0;
}

.calendar-day.holiday {
  background: #fffaf0;
  border: 2px solid #ed8936;
  box-shadow: 0 4px 12px rgba(237, 137, 54, 0.15);
}

.calendar-day.other-month {
  opacity: 0.5;
  background: #f8fafc;
}

.holiday-tooltip {
  position: absolute;
  bottom: 120%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(45, 55, 72, 0.95);
  color: white;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  font-size: 0.8rem;
  white-space: nowrap;
  display: none;
  z-index: 1000;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
  backdrop-filter: blur(4px);
}

.holiday-tooltip:after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  margin-left: -6px;
  border-width: 6px;
  border-style: solid;
  border-color: #2d3748 transparent transparent transparent;
}

.calendar-day:hover .holiday-tooltip {
  display: block;
  animation: tooltipFadeIn 0.3s ease-out;
}

@keyframes tooltipFadeIn {
  from {
    opacity: 0;
    transform: translate(-50%, 10px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

.age-result-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  padding: 1rem;
  background: #f8fafc;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  margin-top: 1rem;
}

.age-numbers {
  color: #2b6cb0;
  font-weight: 500;
}

.motivational-phrase {
  font-family: 'Noto Kufi Arabic', 'Segoe UI', Tahoma, sans-serif;
  color: #ed8936;
  font-size: 1.1rem;
  text-align: right;
  flex-grow: 1;
  font-weight: 500;
  line-height: 1.5;
  animation: fadeIn 0.5s ease-out;
}

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

@media (max-width: 1500px) {
  .calendar-container {
    position: static;
    width: 322px;
    margin: 1.5rem auto;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  }
  
  .container {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 1.5rem;
  }
}

@media (max-width: 768px) {
  .calendar-container {
    margin: 0.75rem auto;
    padding: 0.75rem;
  }
  
  .calendar-grid {
    gap: 3px;
  }
  
  .calendar-day {
    padding: 0.3rem 0.15rem;
    font-size: 0.7rem;
  }
  
  .calendar-day .hijri-date {
    font-size: 0.55rem;
  }
  
  .calendar-nav button {
    width: 24px;
    height: 24px;
  }
}

@media (max-width: 480px) {
  .calendar-container {
    width: 95%;
    max-width: 322px;
  }
  
  .prev-gregorian-month,
  .next-gregorian-month,
  .prev-hijri-month,
  .next-hijri-month {
    font-size: 0.6rem;
  }
  
  .calendar-grid {
    gap: 2px;
  }
  
  .calendar-day {
    padding: 0.25rem 0.1rem;
    font-size: 0.65rem;
  }
  
  .weekday-header {
    font-size: 0.6rem;
    padding: 0.25rem;
  }
}

@media (max-width: 640px) {
  .container {
    margin: 1.5rem auto;
    padding: 0 1rem;
  }

  .service-card {
    padding: 1.5rem;
  }

  h1 {
    font-size: 2rem;
  }

  .site-logo {
    font-size: 2.8rem;
  }
  
  .site-tagline {
    font-size: 1rem;
  }

  .input-group {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  input[type="number"],
  input[type="date"],
  select {
    width: 100%;
  }

  button {
    width: 100%;
    justify-content: center;
  }
}

@media print {
  .site-header {
    background: none;
    color: #000;
    box-shadow: none;
  }
  
  .service-card {
    break-inside: avoid;
    box-shadow: none;
    border: 1px solid #000;
  }
  
  button {
    display: none;
  }
}

.calendar-day, .calendar-nav button, .today-btn {
  transition: all 0.2s ease-in-out;
}