:root {
  --primary-color: #4f46e5;
  --accent-color: #10b981;
  --danger-color: #ef4444;
  --friday-color: #fca5a5;
  --friday-bg-color: #fef2f2;
  --neutral-bg: #f9fafb;
  --dark-text: #111827;
  --light-text: #6b7280;
  --border-color: #e5e7eb;
}

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

.shamsi-calendar-container {
  font-family: "Vazir", "Tahoma", sans-serif;
  direction: rtl;
  text-align: center;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

.shamsi-calendar {
  max-width: 100%;
  width: 100%;
  background: white;
  border-radius: 24px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
  overflow: hidden;
  border: 1px solid var(--border-color);
  transition: all 0.3s ease-in-out;
  height: 100%;
  display: flex;
  flex-direction: column;
  margin: 0 auto;
}

.shamsi-header {
  background: var(--primary-color);
  color: white;
  padding: 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  direction: rtl;
  text-align: center;
}

.shamsi-nav-btn {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  font-size: 20px;
  cursor: pointer;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  flex-shrink: 0;
}

.shamsi-nav-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.1);
}

.shamsi-month-year {
  font-size: 18px;
  font-weight: 600;
  text-align: center;
  flex: 1;
  margin: 0 1rem;
}

.shamsi-goto-section {
  padding: 1.25rem;
  background: var(--neutral-bg);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  direction: rtl;
  align-items: center;
}

.shamsi-select-container {
  display: flex;
  gap: 1rem;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  width: 100%;
}

.shamsi-select-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  align-items: center;
  text-align: center;
}

.shamsi-select-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--light-text);
  text-align: center;
}

.shamsi-goto-select {
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: white;
  font-size: 14px;
  min-width: 110px;
  text-align: center;
  cursor: pointer;
  direction: rtl;
  transition: all 0.3s ease;
}

.shamsi-goto-select:hover {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.shamsi-year-navigation {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  direction: rtl;
}

.shamsi-year-nav-btn {
  background: var(--light-text);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 4px 10px;
  cursor: pointer;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.shamsi-year-nav-btn:hover {
  background: #4b5563;
  transform: scale(1.05);
}

.shamsi-action-buttons {
  display: flex;
  gap: 1rem;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  width: 100%;
}

.shamsi-goto-btn,
.shamsi-today-btn {
  padding: 8px 16px;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.3s ease;
  color: white;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
}

.shamsi-goto-btn {
  background: var(--primary-color);
}

.shamsi-today-btn {
  background: var(--danger-color);
}

.shamsi-goto-btn:hover {
  background: #4338ca;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.shamsi-today-btn:hover {
  background: #b91c1c;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.shamsi-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background: #e0e7ff;
  color: var(--dark-text);
  direction: rtl;
}

.shamsi-weekday {
  padding: 12px 0;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------- Style friday weekday header ---------- */
.shamsi-weekday:nth-child(7) {
  background: var(--friday-bg-color);
  color: var(--friday-color);
  font-weight: 700;
}

.shamsi-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  flex-grow: 1;
  padding: 1rem;
  gap: 6px;
  opacity: 0;
  animation: fadeInGrid 0.4s ease forwards;
  direction: rtl;
  justify-items: center;
  align-items: center;
}

@keyframes fadeInGrid {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.shamsi-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  color: var(--dark-text);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  border-radius: 50%;
  background-color: transparent;
  border: 2px solid transparent;
  width: 100%;
  height: 100%;
  text-align: center;
}

.shamsi-day:hover {
  background: var(--primary-color);
  color: white;
  font-weight: 600;
  transform: scale(1.15);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.shamsi-day.other-month {
  color: var(--light-text);
  background: #f3f4f6;
  transition: all 0.3s ease;
}

.shamsi-day.today {
  background: var(--danger-color);
  color: white;
  font-weight: bold;
  border: 2px solid var(--danger-color);
  animation: pulseToday 2s infinite;
}

@keyframes pulseToday {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(239, 68, 68, 0);
  }
}
.shamsi-day.selected {
  background: var(--accent-color);
  color: white;
  font-weight: bold;
  border: 2px solid var(--accent-color);
  animation: bounceIn 0.5s ease;
}

@keyframes bounceIn {
  0% {
    transform: scale(0.3);
    opacity: 0;
  }
  50% {
    transform: scale(1.2);
    opacity: 1;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}
/* Style Friday days (7th column) */
.shamsi-day:nth-child(7n) {
  color: var(--friday-color);
  background: var(--friday-bg-color);
  font-weight: 600;
}

/* ---------- Friday hover state ---------- */
.shamsi-day:nth-child(7n):hover {
  background: var(--friday-color);
  color: white;
  font-weight: 600;
  transform: scale(1.15);
  box-shadow: 0 4px 12px rgba(252, 165, 165, 0.3);
}

/* ---------- Ensure today and selected states override friday styling when needed ---------- */
.shamsi-day:nth-child(7n).today {
  background: var(--danger-color);
  color: white;
  font-weight: bold;
  border: 2px solid var(--danger-color);
}

.shamsi-day:nth-child(7n).selected {
  background: var(--accent-color);
  color: white;
  font-weight: bold;
  border: 2px solid var(--accent-color);
}

/* Friday other-month styling */
.shamsi-day:nth-child(7n).other-month {
  color: rgba(252, 165, 165, 0.5);
  background: rgba(254, 242, 242, 0.5);
}

.shamsi-day.has-events::after {
  content: "●";
  position: absolute;
  bottom: 2px;
  left: 50%;
  transform: translateX(-50%) scale(1);
  font-size: 8px;
  color: var(--primary-color);
  opacity: 1;
  transition: all 0.3s ease;
  animation: eventDot 2s infinite;
}

@keyframes eventDot {
  0%, 100% {
    opacity: 0.7;
    transform: translateX(-50%) scale(1);
  }
  50% {
    opacity: 1;
    transform: translateX(-50%) scale(1.2);
  }
}
.selected-date-info {
  background: #f1f5f9;
  padding: 0.75rem;
  text-align: center;
  font-size: 14px;
  color: var(--dark-text);
  border-top: 1px solid var(--border-color);
  direction: rtl;
  opacity: 0;
  transform: translateY(-10px);
  transition: all 0.4s ease;
}

.selected-date-info[style*=block] {
  opacity: 1;
  transform: translateY(0);
}

.status-message {
  margin-top: 8px;
  padding: 8px;
  font-size: 13px;
  border-radius: 6px;
  text-align: center;
  direction: rtl;
  transition: all 0.3s ease;
}

.status-success {
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #bbf7d0;
}

.status-error {
  background: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

.status-loading {
  background: #fef9c3;
  color: #92400e;
  border: 1px solid #fde68a;
}

.calendar-layout-container {
  display: flex;
  gap: 20px;
  max-width: 1200px;
  margin: 0 auto;
  direction: rtl;
  padding: 20px;
  justify-content: center;
  align-items: stretch;
}

.events-panel {
  flex: 1;
  min-width: 300px;
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: translateX(30px);
  animation: slideInRight 0.6s ease forwards;
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}
.calendar-panel {
  flex: 0 0 auto;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: translateX(-30px);
  animation: slideInLeft 0.6s ease forwards;
}

@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}
.events-header {
  background: var(--primary-color);
  color: white;
  padding: 1.7rem;
  border-radius: 16px 16px 0 0;
  text-align: center;
  font-weight: 600;
  font-size: 16px;
  position: relative;
  overflow: hidden;
}

.events-list {
  background: white;
  border-radius: 0 0 16px 16px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.05);
  border: 1px solid var(--border-color);
  border-top: none;
  flex-grow: 1;
  overflow-y: auto;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

/* ---------- Enhanced events list animation states ---------- */
.events-list.loading {
  opacity: 0.7;
  transform: scale(0.98);
}

.events-list.loaded {
  opacity: 1;
  transform: scale(1);
}

.event-item {
  border-bottom: 1px solid var(--border-color);
  padding: 1rem;
  cursor: pointer;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  animation: slideInEvent 0.4s ease forwards;
  direction: rtl;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

@keyframes slideInEvent {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
/* ---------- Stagger animation for multiple events ---------- */
.event-item:nth-child(1) {
  animation-delay: 0.1s;
}

.event-item:nth-child(2) {
  animation-delay: 0.2s;
}

.event-item:nth-child(3) {
  animation-delay: 0.3s;
}

.event-item:nth-child(4) {
  animation-delay: 0.4s;
}

.event-item:nth-child(5) {
  animation-delay: 0.5s;
}

.event-item:nth-child(n+6) {
  animation-delay: 0.6s;
}

.event-item::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(79, 70, 229, 0.1), transparent);
  transition: left 0.5s ease;
  z-index: 1;
}

.event-item:hover {
  background: var(--neutral-bg);
  transform: translateX(-8px) scale(1.02);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
  border-radius: 8px;
  border-color: var(--primary-color);
}

.event-item:hover::before {
  left: 100%;
}

.event-item:last-child {
  border-bottom: none;
}

.event-title {
  font-weight: 600;
  color: var(--dark-text);
  margin-bottom: 0.5rem;
  font-size: 14px;
  position: relative;
  z-index: 2;
  transition: color 0.3s ease;
}

.event-item:hover .event-title {
  color: var(--primary-color);
}

.event-meta {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 12px;
  color: var(--light-text);
  position: relative;
  z-index: 2;
}

.event-time,
.event-calendar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: transform 0.3s ease;
}

.event-item:hover .event-time,
.event-item:hover .event-calendar {
  transform: translateX(-4px);
}

.event-icon {
  width: 14px;
  height: 14px;
  opacity: 0.7;
  transition: all 0.3s ease;
}

.event-item:hover .event-icon {
  opacity: 1;
  transform: scale(1.2);
}

.no-events {
  padding: 2rem;
  text-align: center;
  color: var(--light-text);
  font-style: italic;
  opacity: 0;
  transform: translateY(20px);
  animation: fadeInUp 0.5s ease forwards;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
/* ---------- Enhanced event modal with advanced animations ---------- */
.event-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
  display: flex;
  justify-content: center;
  align-items: center;
  backdrop-filter: blur(0px);
  -webkit-backdrop-filter: blur(0px);
  background: rgba(0, 0, 0, 0);
  opacity: 0;
  visibility: hidden;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.event-modal.show {
  opacity: 1;
  visibility: visible;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  background: rgba(0, 0, 0, 0.3);
}

.event-modal-content {
  background: rgba(255, 255, 255, 0.95);
  border-radius: 20px;
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  direction: rtl;
  transform: scale(0.7) translateY(50px);
  opacity: 0;
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.event-modal.show .event-modal-content {
  transform: scale(1) translateY(0);
  opacity: 1;
}

.event-modal-header {
  background: var(--primary-color);
  color: white;
  padding: 1.5rem;
  border-radius: 20px 20px 0 0;
  position: relative;
  direction: rtl;
  text-align: center;
  overflow: hidden;
}

.event-modal-header::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.6s ease;
}

.event-modal-header:hover::before {
  left: 100%;
}

.event-modal-title {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
  padding-right: 2rem;
  text-align: center;
  direction: rtl;
  opacity: 0;
  transform: translateY(10px);
  animation: fadeInDown 0.5s ease 0.2s forwards;
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.event-modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.event-modal-close:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: rotate(90deg) scale(1.1);
}

.event-modal-body {
  padding: 1.5rem;
  direction: rtl;
  text-align: right;
}

.event-detail-group {
  margin-bottom: 1.5rem;
  direction: rtl;
  text-align: right;
  opacity: 0;
  transform: translateX(20px);
  animation: slideInDetail 0.4s ease forwards;
}

@keyframes slideInDetail {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}
/* ---------- Stagger detail animations ---------- */
.event-detail-group:nth-child(1) {
  animation-delay: 0.1s;
}

.event-detail-group:nth-child(2) {
  animation-delay: 0.2s;
}

.event-detail-group:nth-child(3) {
  animation-delay: 0.3s;
}

.event-detail-group:nth-child(4) {
  animation-delay: 0.4s;
}

.event-detail-group:nth-child(5) {
  animation-delay: 0.5s;
}

.event-detail-group:nth-child(6) {
  animation-delay: 0.6s;
}

.event-detail-label {
  font-weight: 600;
  color: var(--dark-text);
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  direction: rtl;
  justify-content: flex-start;
  transition: color 0.3s ease;
}

.event-detail-group:hover .event-detail-label {
  color: var(--primary-color);
}

.event-detail-value {
  color: var(--light-text);
  line-height: 1.5;
  text-align: right;
  direction: rtl;
  transition: all 0.3s ease;
}

.event-detail-group:hover .event-detail-value {
  color: var(--dark-text);
  transform: translateX(-4px);
}

.event-description {
  background: var(--neutral-bg);
  padding: 1rem;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  text-align: right;
  direction: rtl;
  transition: all 0.3s ease;
}

.event-description:hover {
  background: rgba(79, 70, 229, 0.05);
  border-color: var(--primary-color);
  transform: scale(1.02);
}

/* RTL-specific responsive adjustments */
@media (max-width: 768px) {
  .calendar-layout-container {
    flex-direction: column;
    padding: 0;
    align-items: center;
  }
  .shamsi-calendar-container {
    padding: 10px;
    width: 100%;
  }
  .shamsi-calendar {
    border-radius: 16px;
    max-width: none;
    width: 100%;
  }
  .events-panel,
  .calendar-panel {
    max-width: none;
    min-width: auto;
    height: auto;
    animation-delay: 0s;
  }
  .calendar-panel {
    max-width: none;
    animation: slideInUp 0.6s ease forwards;
  }
  .events-panel {
    animation: slideInUp 0.6s ease 0.3s forwards;
  }
  @keyframes slideInUp {
    from {
      opacity: 0;
      transform: translateY(30px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }
  .shamsi-select-container {
    flex-direction: column;
    gap: 0.5rem;
    align-items: center;
  }
  .shamsi-select-group {
    width: 100%;
    max-width: 200px;
  }
  .shamsi-goto-select {
    width: 100%;
  }
  .shamsi-action-buttons {
    flex-direction: column;
    gap: 0.5rem;
    align-items: center;
  }
  .shamsi-goto-btn,
  .shamsi-today-btn {
    width: 100%;
    max-width: 200px;
  }
  .shamsi-header {
    padding: 1rem;
  }
  .shamsi-month-year {
    font-size: 16px;
  }
  .shamsi-nav-btn {
    width: 32px;
    height: 32px;
    font-size: 18px;
  }
  .shamsi-days {
    padding: 0.5rem;
    gap: 4px;
  }
  .shamsi-day {
    font-size: 12px;
  }
  .event-modal-content {
    width: 95%;
    max-width: 400px;
    max-height: 90vh;
    border-radius: 16px;
  }
  .event-modal-header {
    border-radius: 16px 16px 0 0;
  }
  .event-modal-title {
    font-size: 16px;
    padding-right: 1.5rem;
  }
  .event-item:hover {
    transform: translateY(-2px) scale(1.02);
  }
}
/* ---------- Loading animation for events list ---------- */
@keyframes shimmer {
  0% {
    background-position: -200px 0;
  }
  100% {
    background-position: calc(200px + 100%) 0;
  }
}
.events-list.loading::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.6), transparent);
  animation: shimmer 1.5s infinite;
}