/* ========================================
   TET CALENDAR - ULTRA MODERN STYLES
   Đồng bộ với design system & fix mobile overflow
   ======================================== */

/* ==================== CALENDAR CONTAINER ==================== */
.tet-calendar-container {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-2xl);
  padding: var(--space-8);
  box-shadow: var(--shadow-lg);
  margin: var(--space-8) 0;
  overflow: hidden; /* Prevent overflow */
}

/* ==================== CALENDAR HEADER ==================== */
.calendar-header {
  text-align: center;
  margin-bottom: var(--space-8);
}

.calendar-header h3 {
  font-size: clamp(var(--text-2xl), 4vw, var(--text-4xl));
  font-weight: 800;
  color: var(--color-text);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  margin: 0;
  letter-spacing: -0.02em;
}

.calendar-header h3 i {
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-size: clamp(var(--text-3xl), 5vw, var(--text-5xl));
}

/* ==================== INFO BOXES ==================== */
.calendar-info-box {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-5);
  margin-bottom: var(--space-8);
}

.info-item {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-5);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  transition: all var(--transition-base);
  position: relative;
  overflow: hidden;
}

.info-item::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 100px;
  height: 100px;
  background: var(--gradient-primary);
  opacity: 0.05;
  border-radius: 50%;
  transform: translate(30%, -30%);
  transition: all var(--transition-slow);
}

.info-item:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--color-primary);
}

.info-item:hover::before {
  transform: translate(20%, -20%) scale(1.2);
}

.info-item.highlight {
  background: var(--gradient-primary);
  border-color: transparent;
  color: white;
  box-shadow: var(--shadow-lg);
}

.info-item.highlight::before {
  background: white;
  opacity: 0.1;
}

.info-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-xl);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-2xl);
  color: white;
  flex-shrink: 0;
  box-shadow: var(--shadow-md);
}

.info-icon.red {
  background: var(--gradient-primary);
}

.info-icon.orange {
  background: var(--gradient-accent);
}

.info-icon.green {
  background: var(--gradient-success);
}

.info-icon.blue {
  background: var(--gradient-info);
}

.info-content {
  flex: 1;
  min-width: 0;
}

.info-label {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-text-secondary);
  margin-bottom: var(--space-1);
}

.info-item.highlight .info-label {
  color: rgba(255, 255, 255, 0.9);
}

.info-value {
  font-size: var(--text-lg);
  font-weight: 800;
  color: var(--color-text);
  line-height: 1.2;
}

.info-item.highlight .info-value {
  color: white;
}

.info-value.large {
  font-size: var(--text-2xl);
}

/* ==================== CALENDAR GRID ==================== */
.calendar-grid {
  margin-bottom: var(--space-6);
  width: 100%; /* Ensure full width */
  overflow-x: auto; /* Allow horizontal scroll if needed */
  -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
}

/* Hide scrollbar but keep functionality */
.calendar-grid::-webkit-scrollbar {
  height: 4px;
}

.calendar-grid::-webkit-scrollbar-track {
  background: var(--color-bg);
  border-radius: var(--radius-full);
}

.calendar-grid::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: var(--radius-full);
}

.calendar-grid::-webkit-scrollbar-thumb:hover {
  background: var(--color-text-muted);
}

.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: var(--space-1);
  margin-bottom: var(--space-2);
  min-width: 100%; /* Prevent shrinking */
}

.weekday {
  padding: var(--space-3);
  text-align: center;
  font-weight: 700;
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  background: var(--color-bg);
  border-radius: var(--radius-md);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.calendar-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: var(--space-1);
  min-width: 100%; /* Prevent shrinking */
}

.calendar-day {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-2);
  border-radius: var(--radius-lg);
  background: white;
  border: 2px solid var(--color-border);
  transition: all var(--transition-base);
  position: relative;
  cursor: default;
  min-width: 0; /* Allow shrinking */
}

.calendar-day:hover:not(.other-month) {
  transform: scale(1.05);
  box-shadow: var(--shadow-md);
  z-index: 1;
}

.calendar-day .day-number {
  font-size: clamp(var(--text-sm), 2vw, var(--text-base));
  font-weight: 700;
  color: var(--color-text);
  line-height: 1;
}

.calendar-day .day-label {
  font-size: clamp(0.5rem, 1.5vw, var(--text-xs));
  font-weight: 700;
  margin-top: var(--space-1);
  padding: var(--space-1) var(--space-2);
  background: var(--gradient-primary);
  color: white;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.calendar-day.other-month {
  opacity: 0.3;
  background: var(--color-bg);
}

.calendar-day.weekend {
  background: linear-gradient(135deg, #FFF3E0 0%, #FFE8CC 100%);
  border-color: var(--color-accent);
}

.calendar-day.holiday {
  background: linear-gradient(135deg, #FFEBEE 0%, #FFCDD2 100%);
  border-color: var(--color-primary);
}

.calendar-day.holiday .day-number {
  color: var(--color-primary);
  font-weight: 800;
}

.calendar-day.tet-day {
  background: var(--gradient-primary);
  border-color: transparent;
  box-shadow: var(--shadow-xl);
  animation: tetPulse 2s ease-in-out infinite;
}

@keyframes tetPulse {
  0%, 100% {
    box-shadow: 0 4px 20px rgba(230, 57, 70, 0.4);
  }
  50% {
    box-shadow: 0 8px 30px rgba(230, 57, 70, 0.6);
  }
}

.calendar-day.tet-day .day-number {
  color: white;
  font-size: clamp(var(--text-base), 2.5vw, var(--text-xl));
  font-weight: 900;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.calendar-day.tet-day .day-label {
  background: white;
  color: var(--color-primary);
}

.calendar-day.today {
  border: 3px solid var(--color-info);
  box-shadow: 0 0 0 3px rgba(17, 138, 178, 0.2);
}

/* ==================== CALENDAR NOTE ==================== */
.calendar-note {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4);
  background: linear-gradient(135deg, #FFF9C4 0%, #FFF59D 100%);
  border-left: 4px solid var(--color-accent);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-6);
  box-shadow: var(--shadow-sm);
}

.calendar-note i {
  color: var(--color-accent-dark);
  font-size: var(--text-xl);
  margin-top: var(--space-1);
  flex-shrink: 0;
}

.calendar-note p {
  font-size: var(--text-sm);
  line-height: 1.6;
  color: var(--color-text);
  margin: 0;
}

/* ==================== CALENDAR LEGEND ==================== */
.calendar-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  justify-content: center;
  padding-top: var(--space-6);
  border-top: 2px solid var(--color-divider);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-secondary);
}

.legend-color {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-md);
  border: 2px solid var(--color-border);
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

.legend-color.tet-day {
  background: var(--gradient-primary);
  border-color: transparent;
}

.legend-color.holiday {
  background: linear-gradient(135deg, #FFEBEE 0%, #FFCDD2 100%);
  border-color: var(--color-primary);
}

.legend-color.weekend {
  background: linear-gradient(135deg, #FFF3E0 0%, #FFE8CC 100%);
  border-color: var(--color-accent);
}

.legend-color.today {
  background: white;
  border: 3px solid var(--color-info);
}

/* ==================== EMPTY & ERROR STATES ==================== */
.empty-message,
.error-message {
  text-align: center;
  padding: var(--space-12) var(--space-6);
  background: var(--color-bg);
  border-radius: var(--radius-xl);
}

.empty-message i,
.error-message i {
  font-size: 4rem;
  color: var(--color-border);
  margin-bottom: var(--space-4);
  opacity: 0.5;
}

.empty-message p,
.error-message p {
  font-size: var(--text-base);
  color: var(--color-text-muted);
  margin: 0;
}

/* ==================== LOADING STATE ==================== */
.loading {
  text-align: center;
  padding: var(--space-12) var(--space-6);
}

.loading i {
  font-size: 3rem;
  color: var(--color-primary);
  margin-bottom: var(--space-4);
  animation: spin 1s linear infinite;
}

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

/* ==================== RESPONSIVE DESIGN ==================== */
@media (max-width: 1024px) {
  .calendar-info-box {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  }
}

@media (max-width: 768px) {
  .tet-calendar-container {
    padding: var(--space-6);
    margin: var(--space-6) 0;
  }
  
  .calendar-info-box {
    grid-template-columns: 1fr;
    gap: var(--space-4);
  }
  
  .info-item {
    padding: var(--space-4);
    gap: var(--space-3);
  }
  
  .info-icon {
    width: 48px;
    height: 48px;
    font-size: var(--text-xl);
  }
  
  .calendar-grid {
    /* Allow horizontal scroll on mobile if needed */
    overflow-x: auto;
  }
  
  .calendar-weekdays,
  .calendar-days {
    min-width: 320px; /* Minimum width to prevent too much shrinking */
  }
  
  .weekday {
    padding: var(--space-2);
    font-size: var(--text-xs);
  }
  
  .calendar-day {
    padding: var(--space-1);
  }
  
  .calendar-day .day-number {
    font-size: var(--text-sm);
  }
  
  .calendar-legend {
    gap: var(--space-3);
  }
  
  .legend-item {
    font-size: var(--text-xs);
  }
  
  .legend-color {
    width: 24px;
    height: 24px;
  }
}

@media (max-width: 480px) {
  .tet-calendar-container {
    padding: var(--space-4);
    margin: var(--space-4) 0;
    border-radius: var(--radius-xl);
  }
  
  .calendar-header {
    margin-bottom: var(--space-6);
  }
  
  .calendar-info-box {
    gap: var(--space-3);
  }
  
  .info-item {
    padding: var(--space-3);
  }
  
  .info-icon {
    width: 40px;
    height: 40px;
    font-size: var(--text-lg);
  }
  
  .info-value {
    font-size: var(--text-base);
  }
  
  .info-value.large {
    font-size: var(--text-xl);
  }
  
  /* Ensure calendar doesn't overflow on very small screens */
  .calendar-weekdays,
  .calendar-days {
    min-width: 280px;
    gap: 2px;
  }
  
  .weekday {
    padding: var(--space-1);
    font-size: 0.625rem; /* 10px */
  }
  
  .calendar-day {
    padding: var(--space-1);
    border-width: 1px;
  }
  
  .calendar-day .day-number {
    font-size: 0.75rem; /* 12px */
  }
  
  .calendar-day .day-label {
    font-size: 0.5rem; /* 8px */
    padding: 1px var(--space-1);
  }
  
  .calendar-note {
    flex-direction: column;
    padding: var(--space-3);
  }
  
  .calendar-note i {
    font-size: var(--text-lg);
    margin-top: 0;
  }
  
  .calendar-legend {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-2);
  }
  
  .legend-color {
    width: 20px;
    height: 20px;
  }
}

/* ==================== VERY SMALL SCREENS ==================== */
@media (max-width: 360px) {
  .calendar-weekdays,
  .calendar-days {
    min-width: 260px;
    gap: 1px;
  }
  
  .weekday {
    padding: 2px;
    font-size: 0.5rem; /* 8px */
  }
  
  .calendar-day {
    padding: 1px;
  }
  
  .calendar-day .day-number {
    font-size: 0.625rem; /* 10px */
  }
  
  .calendar-day .day-label {
    display: none; /* Hide labels on very small screens */
  }
}

/* ==================== ANIMATIONS ==================== */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.tet-calendar-container {
  animation: fadeInUp 0.6s ease-out;
}

.calendar-day {
  animation: fadeInUp 0.3s ease-out;
  animation-fill-mode: backwards;
}

/* Stagger animation for calendar days */
.calendar-day:nth-child(1) { animation-delay: 0.05s; }
.calendar-day:nth-child(2) { animation-delay: 0.1s; }
.calendar-day:nth-child(3) { animation-delay: 0.15s; }
.calendar-day:nth-child(4) { animation-delay: 0.2s; }
.calendar-day:nth-child(5) { animation-delay: 0.25s; }
.calendar-day:nth-child(6) { animation-delay: 0.3s; }
.calendar-day:nth-child(7) { animation-delay: 0.35s; }

/* ==================== ACCESSIBILITY ==================== */
.calendar-day:focus-visible {
  outline: 3px solid var(--color-info);
  outline-offset: 2px;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .tet-calendar-container,
  .calendar-day,
  .info-item,
  .calendar-day.tet-day {
    animation: none;
  }
  
  .calendar-day:hover {
    transform: none;
  }
}

/* ==================== PRINT STYLES ==================== */
@media print {
  .tet-calendar-container {
    box-shadow: none;
    border: 1px solid #ccc;
    page-break-inside: avoid;
  }
  
  .calendar-day:hover {
    transform: none;
  }
  
  .calendar-legend {
    page-break-before: avoid;
  }
}

/* ==================== HIGH CONTRAST MODE ==================== */
@media (prefers-contrast: high) {
  .calendar-day {
    border-width: 3px;
  }
  
  .info-item {
    border-width: 2px;
  }
}
