/* Page Transition Styles */
.page-transitioning {
  overflow: hidden;
}

.page-transition-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(5px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.page-transition-overlay.active {
  opacity: 1;
  visibility: visible;
}

.loading-spinner {
  text-align: center;
  color: white;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(255, 255, 255, 0.3);
  border-top: 4px solid #ff9800;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 20px;
}

.loading-text {
  font-size: 16px;
  font-weight: 500;
  color: #fff;
  opacity: 0.9;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Smooth transitions for main content */
.main-content {
  transition: opacity 0.3s ease-out;
}

/* Optimize sidebar transitions */
.sidebar-item {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.sidebar-item::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
  transition: left 0.5s ease;
}

.sidebar-item:hover::before {
  left: 100%;
}

.sidebar-item.active {
  background: linear-gradient(135deg, #ff9800, #ff5722);
  box-shadow: 0 4px 15px rgba(255, 152, 0, 0.3);
}

/* Smooth header transitions */
.header {
  transition: all 0.3s ease;
}

.header-btn {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.header-btn::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: width 0.3s ease, height 0.3s ease;
}

.header-btn:hover::after {
  width: 100px;
  height: 100px;
}

/* Optimize clock display transitions */
.clock {
  transition: all 0.3s ease;
  will-change: transform, opacity;
}

.clock-container {
  transition: all 0.3s ease;
}

/* Smooth modal transitions */
.modal {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-content {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform, opacity;
}

/* Optimize background video transitions */
.background-container {
  transition: opacity 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  will-change: opacity;
}

.background-container video {
  transition: opacity 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  will-change: opacity;
}

/* Crossfade effect for background videos */
.background-container .video-fade-in {
  opacity: 1;
  transition: opacity 1s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.background-container .video-fade-out {
  opacity: 0;
  transition: opacity 1s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* Smooth background layer transitions */
.background-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  transition: opacity 1.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  will-change: opacity;
}

.background-layer.active {
  opacity: 1;
}

/* Hardware acceleration for smooth transitions */
.background-container,
.background-container video,
.background-layer {
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

/* Performance optimizations */
* {
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
  .page-transition-overlay,
  .main-content,
  .sidebar-item,
  .header-btn,
  .clock,
  .modal,
  .background-container video {
    transition: none;
  }
  
  .spinner {
    animation: none;
  }
}

/* Loading states */
.loading {
  opacity: 0.6;
  pointer-events: none;
}

.loading * {
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

/* Smooth scroll behavior */
html {
  scroll-behavior: smooth;
}

/* Optimize for mobile */
@media (max-width: 768px) {
  .page-transition-overlay {
    background: rgba(0, 0, 0, 0.9);
  }
  
  .loading-text {
    font-size: 14px;
  }
  
  .spinner {
    width: 30px;
    height: 30px;
    border-width: 3px;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .page-transition-overlay {
    background: rgba(0, 0, 0, 0.95);
  }
  
  .spinner {
    border-color: #fff;
    border-top-color: #000;
  }
}

/* Dark mode optimizations */
@media (prefers-color-scheme: dark) {
  .page-transition-overlay {
    background: rgba(0, 0, 0, 0.9);
  }
}

/* GPU acceleration for smooth animations */
.sidebar-item,
.header-btn,
.clock,
.modal-content {
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
}

/* Optimize transitions for better performance */
.sidebar-item,
.header-btn {
  contain: layout style paint;
}

/* Smooth focus transitions */
.sidebar-item:focus,
.header-btn:focus {
  outline: 2px solid #ff9800;
  outline-offset: 2px;
  transition: outline 0.2s ease;
}

/* Loading skeleton for better perceived performance */
.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
}

@keyframes loading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* Error state styling */
.navigation-error {
  animation: shake 0.5s ease-in-out;
}

@keyframes shake {
  0%, 100% {
    transform: translate(-50%, -50%) translateX(0);
  }
  25% {
    transform: translate(-50%, -50%) translateX(-5px);
  }
  75% {
    transform: translate(-50%, -50%) translateX(5px);
  }
}

/* Loading Indicator Styles */
.loading-indicator {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(5px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.loading-indicator.active {
  opacity: 1;
  visibility: visible;
}

.loading-progress {
  text-align: center;
  color: white;
  max-width: 300px;
  width: 100%;
  padding: 20px;
}

.progress-bar {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 15px;
  position: relative;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #ff9800, #ff5722);
  border-radius: 2px;
  width: 0%;
  transition: width 0.3s ease;
  position: relative;
}

.progress-fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

.loading-text {
  font-size: 16px;
  font-weight: 500;
  color: #fff;
  opacity: 0.9;
  margin: 0;
}

/* Spinner animation */
.spinner {
  width: 30px;
  height: 30px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top: 3px solid #ff9800;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto;
}

/* Loading dots animation */
.loading-dots {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 4px;
}

.loading-dots span {
  width: 8px;
  height: 8px;
  background: #ff9800;
  border-radius: 50%;
  animation: loadingDots 1.4s infinite ease-in-out both;
}

.loading-dots span:nth-child(1) {
  animation-delay: -0.32s;
}

.loading-dots span:nth-child(2) {
  animation-delay: -0.16s;
}

@keyframes loadingDots {
  0%, 80%, 100% {
    transform: scale(0);
    opacity: 0.5;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Multiple loading indicators */
.loading-indicator:nth-of-type(2) {
  z-index: 1001;
}

.loading-indicator:nth-of-type(3) {
  z-index: 1002;
}

/* Responsive design */
@media (max-width: 768px) {
  .loading-progress {
    max-width: 250px;
    padding: 15px;
  }
  
  .loading-text {
    font-size: 14px;
  }
  
  .spinner {
    width: 25px;
    height: 25px;
    border-width: 2px;
  }
}

/* High contrast mode */
@media (prefers-contrast: high) {
  .loading-indicator {
    background: rgba(0, 0, 0, 0.95);
  }
  
  .progress-bar {
    background: rgba(255, 255, 255, 0.3);
    border: 1px solid #fff;
  }
  
  .progress-fill {
    background: #fff;
  }
  
  .spinner {
    border-color: #fff;
    border-top-color: #000;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .loading-indicator,
  .progress-fill,
  .spinner,
  .loading-dots span {
    transition: none;
    animation: none;
  }
  
  .progress-fill::after {
    animation: none;
  }
}

/* Timer Alert Styles */
.timer-alert {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(5px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
}

.timer-alert.active {
  display: flex;
}

.alert-content {
  background: #2a2a2a;
  padding: 30px;
  border-radius: 12px;
  text-align: center;
  color: white;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  animation: alertPopIn 0.3s ease-out;
}

.alert-icon {
  font-size: 48px;
  margin-bottom: 20px;
}

.alert-message {
  font-size: 18px;
  margin-bottom: 25px;
  line-height: 1.4;
}

.alert-button {
  background: #ff9800;
  color: #000;
  border: none;
  padding: 12px 30px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
}

.alert-button:hover {
  background: #ffa726;
  transform: scale(1.05);
}

@keyframes alertPopIn {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Notification buttons */
.notification-buttons {
  display: flex;
  gap: 15px;
  justify-content: center;
  margin-top: 20px;
}

.restart-btn {
  background: #4caf50;
  color: white;
}

.restart-btn:hover {
  background: #45a049;
}

/* Stopwatch and Timer Styles */
.stopwatch-display {
  font-family: 'Digital-7', monospace;
  font-size: 4rem;
  text-align: center;
  color: #ff9800;
  margin: 2rem 0;
  text-shadow: 0 0 20px rgba(255, 152, 0, 0.5);
  background: rgba(0, 0, 0, 0.3);
  padding: 1.5rem;
  border-radius: 15px;
  border: 2px solid #ff9800;
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
}

/* Di chuyển đồng hồ lên khi có LAP */
.stopwatch-mode.has-laps .stopwatch-display {
  margin: 1rem 0;
  font-size: 3.5rem;
}

.stopwatch-mode.has-laps .stopwatch-controls {
  margin: 1rem 0;
}

.stopwatch-display::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 152, 0, 0.2), transparent);
  animation: shimmer 3s infinite;
}

@keyframes shimmer {
  0% { left: -100%; }
  100% { left: 100%; }
}

.stopwatch-display .separator {
  color: #ffa726;
  animation: blink 1s infinite;
}

@keyframes blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0.3; }
}

.stopwatch-controls {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin: 2rem 0;
}

.stopwatch-controls .btn {
  padding: 15px 30px;
  font-size: 1.3rem;
  font-weight: bold;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  min-width: 140px;
  text-transform: uppercase;
  letter-spacing: 1px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.stopwatch-controls .start-btn {
  background: #4caf50;
  color: white;
}

.stopwatch-controls .start-btn:hover {
  background: #45a049;
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(76, 175, 80, 0.4);
}

.stopwatch-controls .start-btn:active {
  transform: scale(0.95);
}

.stopwatch-controls .stop-btn {
  background: #f44336;
  color: white;
}

.stopwatch-controls .stop-btn:hover {
  background: #da190b;
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(244, 67, 54, 0.4);
}

.stopwatch-controls .stop-btn:active {
  transform: scale(0.95);
}

.stopwatch-controls .reset-btn {
  background: #ff9800;
  color: white;
}

.stopwatch-controls .reset-btn:hover {
  background: #f57c00;
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(255, 152, 0, 0.4);
}

.stopwatch-controls .reset-btn:active {
  transform: scale(0.95);
}

.lap-times {
  margin-top: 2rem;
  max-height: 250px;
  overflow-y: auto;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 15px;
  padding: 1rem;
  border: 2px solid rgba(255, 152, 0, 0.3);
  transition: all 0.3s ease;
}

/* Animation khi có LAP mới */
.lap-times.has-laps {
  animation: slideUp 0.5s ease;
}

@keyframes slideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.lap-times table {
  width: 100%;
  border-collapse: collapse;
  background: transparent;
}

.lap-times th,
.lap-times td {
  padding: 12px 15px;
  text-align: center;
  border-bottom: 1px solid rgba(255, 152, 0, 0.2);
  font-size: 1rem;
}

.lap-times th {
  background: rgba(255, 152, 0, 0.3);
  color: #ff9800;
  font-weight: bold;
  font-size: 1.1rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.lap-times td {
  color: white;
  font-family: 'Digital-7', monospace;
  font-size: 1.2rem;
}

.lap-times td:first-child {
  color: #ffa726;
  font-weight: bold;
  font-size: 1.1rem;
}

.lap-times tr:hover {
  background: rgba(255, 152, 0, 0.1);
}

.lap-times tr:last-child td {
  border-bottom: none;
}

.lap-times .fastest-lap {
  background: rgba(76, 175, 80, 0.2) !important;
  color: #4caf50 !important;
}

.lap-times .fastest-lap td {
  color: #4caf50 !important;
  font-weight: bold;
}

.lap-times .slowest-lap {
  background: rgba(244, 67, 54, 0.2) !important;
  color: #f44336 !important;
}

.lap-times .slowest-lap td {
  color: #f44336 !important;
  font-weight: bold;
}

/* Cải tiến hiển thị LAP */
.lap-times .lap-time {
  color: #ff9800 !important;
  font-size: 1.3rem;
  font-weight: bold;
}

/* Animation cho LAP mới */
.lap-times tr:first-child {
  animation: newLap 0.5s ease;
}

@keyframes newLap {
  0% {
    background: rgba(255, 152, 0, 0.3);
    transform: scale(1.05);
  }
  100% {
    background: transparent;
    transform: scale(1);
  }
}

/* Timer Styles */
.timer-display {
  font-family: 'Digital-7', monospace;
  font-size: 4rem;
  text-align: center;
  color: #ff9800;
  margin: 2rem 0;
  text-shadow: 0 0 20px rgba(255, 152, 0, 0.5);
}

.timer-inputs {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin: 2rem 0;
}

.timer-input-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.timer-input-group label {
  font-size: 1.2rem;
  font-weight: bold;
  color: #ff9800;
}

.timer-input-group input {
  width: 80px;
  height: 50px;
  font-size: 2rem;
  text-align: center;
  border: 2px solid #ff9800;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.5);
  color: white;
  font-family: 'Digital-7', monospace;
}

.timer-input-group input:focus {
  outline: none;
  border-color: #ffa726;
  box-shadow: 0 0 10px rgba(255, 152, 0, 0.5);
}

.sound-selector {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  margin: 2rem 0;
}

.sound-selector select {
  padding: 8px 12px;
  border: 1px solid #ff9800;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.5);
  color: white;
  font-size: 1rem;
}

.test-sound {
  padding: 8px 16px;
  background: #ff9800;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1rem;
}

.test-sound:hover {
  background: #ffa726;
}

.timer-controls {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin: 2rem 0;
}

.control-btn {
  width: 60px;
  height: 60px;
  border: none;
  border-radius: 50%;
  font-size: 1.5rem;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.control-btn#start-timer {
  background: #4caf50;
  color: white;
}

.control-btn#start-timer:hover {
  background: #45a049;
  transform: scale(1.1);
}

.control-btn#reset-timer {
  background: #ff9800;
  color: white;
}

.control-btn#reset-timer:hover {
  background: #f57c00;
  transform: scale(1.1);
}

.pause-btn {
  background: #f44336 !important;
}

.pause-btn:hover {
  background: #da190b !important;
}
