/* ========================================
   Renewal Cycle Dashboard - Main Styles (English)
   ======================================== */

/* ========================================
   Welcome Notification Animations
   ======================================== */
@keyframes slide-in-right {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slide-out-right {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(100%);
    opacity: 0;
  }
}

.animate-slide-in-right {
  animation: slide-in-right 0.3s ease-out forwards;
}

.animate-slide-out-right {
  animation: slide-out-right 0.3s ease-in forwards;
}

/* Logo color filter for light mode - converts white to #0160A9 */
.logo-light-filter {
  filter: brightness(0) saturate(100%) invert(24%) sepia(89%) saturate(1636%) hue-rotate(193deg) brightness(93%) contrast(101%);
}

/* Scrollbar Styling */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

.dark ::-webkit-scrollbar-thumb {
  background: #475569;
  border-radius: 3px;
}

/* ========================================
   Loading States & Skeletons
   ======================================== */
.skeleton {
  background: linear-gradient(90deg, #1e293b 25%, #334155 50%, #1e293b 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s ease-in-out infinite;
}

.light .skeleton {
  background: linear-gradient(90deg, #e2e8f0 25%, #cbd5e1 50%, #e2e8f0 75%);
  background-size: 200% 100%;
}

@keyframes skeleton-loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.chart-loading::before {
  content: '';
  position: absolute;
  inset: 0;
  background: inherit;
  border-radius: inherit;
  z-index: 10;
}

.chart-loading::after {
  content: 'Loading chart...';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #94a3b8;
  font-size: 0.875rem;
  z-index: 11;
}

/* Loading spinner */
.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid #475569;
  border-top-color: #f59e0b;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ========================================
   Accessibility
   ======================================== */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* Focus indicators */
.stage-seg:focus-visible,
.milestone-dot:focus-visible,
button:focus-visible,
a:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid #f59e0b;
  outline-offset: 2px;
  z-index: 100;
}

/* Skip link */
.skip-link {
  position: absolute;
  top: -100%;
  left: 0;
  padding: 0.5rem 1rem;
  background: #3b82f6;
  color: white;
  text-decoration: none;
  z-index: 9999;
  transition: top 0.2s;
}

.skip-link:focus {
  top: 0;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ========================================
   Animations
   ======================================== */
@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.animate-pulse-dot {
  animation: pulse-dot 2s ease-in-out infinite;
}

/* Timeline Bar Animations */
@keyframes timeline-grow {
  from {
    transform: scaleX(0);
    opacity: 0;
  }
  to {
    transform: scaleX(1);
    opacity: 1;
  }
}

@keyframes timeline-fade-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Timeline row container animation */
.timeline-row-wrapper {
  animation: timeline-fade-in 0.6s ease-out forwards;
  opacity: 0;
}

.timeline-row-wrapper:nth-child(1) { animation-delay: 0.1s; }
.timeline-row-wrapper:nth-child(2) { animation-delay: 0.3s; }
.timeline-row-wrapper:nth-child(3) { animation-delay: 0.5s; }

/* Stage segment animations */
.stage-seg {
  transform-origin: left center;
  animation: timeline-grow 0.5s ease-out forwards;
  opacity: 0;
}

/* Staggered delays for segments based on row */
.timeline-row-wrapper:nth-child(1) .stage-seg:nth-child(1) { animation-delay: 0.2s; }
.timeline-row-wrapper:nth-child(1) .stage-seg:nth-child(2) { animation-delay: 0.26s; }
.timeline-row-wrapper:nth-child(1) .stage-seg:nth-child(3) { animation-delay: 0.32s; }
.timeline-row-wrapper:nth-child(1) .stage-seg:nth-child(4) { animation-delay: 0.38s; }
.timeline-row-wrapper:nth-child(1) .stage-seg:nth-child(5) { animation-delay: 0.44s; }
.timeline-row-wrapper:nth-child(1) .stage-seg:nth-child(6) { animation-delay: 0.5s; }
.timeline-row-wrapper:nth-child(1) .stage-seg:nth-child(7) { animation-delay: 0.56s; }
.timeline-row-wrapper:nth-child(1) .stage-seg:nth-child(8) { animation-delay: 0.62s; }
.timeline-row-wrapper:nth-child(1) .stage-seg:nth-child(9) { animation-delay: 0.68s; }

.timeline-row-wrapper:nth-child(2) .stage-seg:nth-child(1) { animation-delay: 0.4s; }
.timeline-row-wrapper:nth-child(2) .stage-seg:nth-child(2) { animation-delay: 0.46s; }
.timeline-row-wrapper:nth-child(2) .stage-seg:nth-child(3) { animation-delay: 0.52s; }
.timeline-row-wrapper:nth-child(2) .stage-seg:nth-child(4) { animation-delay: 0.58s; }
.timeline-row-wrapper:nth-child(2) .stage-seg:nth-child(5) { animation-delay: 0.64s; }

.timeline-row-wrapper:nth-child(3) .stage-seg:nth-child(1) { animation-delay: 0.6s; }
.timeline-row-wrapper:nth-child(3) .stage-seg:nth-child(2) { animation-delay: 0.66s; }
.timeline-row-wrapper:nth-child(3) .stage-seg:nth-child(3) { animation-delay: 0.72s; }
.timeline-row-wrapper:nth-child(3) .stage-seg:nth-child(4) { animation-delay: 0.78s; }
.timeline-row-wrapper:nth-child(3) .stage-seg:nth-child(5) { animation-delay: 0.84s; }
.timeline-row-wrapper:nth-child(3) .stage-seg:nth-child(6) { animation-delay: 0.9s; }
.timeline-row-wrapper:nth-child(3) .stage-seg:nth-child(7) { animation-delay: 0.96s; }
.timeline-row-wrapper:nth-child(3) .stage-seg:nth-child(8) { animation-delay: 1.02s; }
.timeline-row-wrapper:nth-child(3) .stage-seg:nth-child(9) { animation-delay: 1.08s; }
.timeline-row-wrapper:nth-child(3) .stage-seg:nth-child(10) { animation-delay: 1.14s; }

/* Subtle hover effect on segments */
.stage-seg {
  transition: filter 0.2s ease, transform 0.2s ease;
}

.stage-seg:hover {
  filter: brightness(1.1);
  transform: scaleY(1.08);
}

/* ========================================
   Timeline Stage Patterns
   ======================================== */
.in-progress-stripes {
  background: repeating-linear-gradient(
    45deg,
    #f9f187,
    #f9f187 4px,
    #e9e070 4px,
    #e9e070 8px
  ) !important;
}

.forecasted-stripes-amber {
  background: repeating-linear-gradient(
    45deg,
    #f9f187,
    #f9f187 4px,
    #e9e070 4px,
    #e9e070 8px
  ) !important;
}

.inactivity-stripes {
  background: repeating-linear-gradient(
    -45deg,
    rgba(249, 241, 135, 0.6),
    rgba(249, 241, 135, 0.6) 3px,
    rgba(212, 200, 74, 0.6) 3px,
    rgba(212, 200, 74, 0.6) 6px
  ) !important;
}

.inactivity-stripes-grey {
  background: repeating-linear-gradient(
    -45deg,
    rgba(100, 116, 139, 0.4),
    rgba(100, 116, 139, 0.4) 3px,
    rgba(71, 85, 105, 0.4) 3px,
    rgba(71, 85, 105, 0.4) 6px
  ) !important;
}

/* ========================================
   Tender Preparation Stage Color (Light Yellow)
   ======================================== */
.bg-tender-prep {
  background-color: #f9f187 !important;
}

.text-tender-prep {
  color: #d4c84a !important;
}

/* ========================================
   Milestone Dots
   ======================================== */
.milestone-dot {
  position: absolute;
  width: 12px;
  height: 12px;
  background: #f97316;
  border-radius: 50%;
  top: 50%;
  transform: translateY(-50%);
  cursor: pointer;
  z-index: 25;
}

.milestone-dot:hover {
  transform: translateY(-50%) scale(1.4);
  z-index: 26;
}

/* ========================================
   Tooltips
   ======================================== */
.has-tip {
  position: relative;
}

.tip {
  position: absolute;
  top: -60px;
  left: 50%;
  transform: translateX(-50%);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s, visibility 0.15s;
  pointer-events: none;
  white-space: nowrap;
  z-index: 999999 !important;
}

.has-tip:hover > .tip {
  opacity: 1;
  visibility: visible;
}

/* ========================================
   Timeline Stage Segments
   ======================================== */
.stage-seg {
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.15s ease, z-index 0s;
  position: relative;
  overflow: visible !important;
  z-index: 1;
}

.stage-seg:hover {
  transform: scaleY(1.15);
  filter: brightness(1.1);
  z-index: 100;
  isolation: isolate;
}

.stage-seg:hover > .tip {
  z-index: 999999 !important;
}

.stage-seg.active {
  transform: scaleY(1.3);
  filter: brightness(1.2);
  z-index: 25;
  box-shadow: 0 0 0 2px #f59e0b;
}

/* ========================================
   Panel Expandable (Stage Details)
   ======================================== */
.panel-expandable {
  transition: all 0.3s ease;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
}

.panel-expandable.open {
  max-height: 2000px;
  opacity: 1;
}

/* ========================================
   Inactivity Zone
   ======================================== */
.inactivity-zone {
  cursor: pointer;
  position: relative;
  overflow: visible !important;
}

/* ========================================
   Timeline Row Wrapper
   ======================================== */
.timeline-row-wrapper {
  position: relative;
  overflow: visible !important;
  z-index: 1;
}

.timeline-row-wrapper:hover {
  z-index: 100;
}

/* ========================================
   Delay Justification Components
   ======================================== */

/* Collapsible/Accordion */
.accordion-header {
  cursor: pointer;
  user-select: none;
  transition: background-color 0.15s ease;
}

.accordion-header:hover {
  background-color: rgba(148, 163, 184, 0.1);
}

.accordion-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease-out;
}

.accordion-content.open {
  max-height: 2000px;
  transition: max-height 0.5s ease-in;
}

.accordion-icon {
  transition: transform 0.3s ease;
}

.accordion-header.open .accordion-icon {
  transform: rotate(180deg);
}

/* Sub-stage Progress Bar */
.substage-bar {
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

.substage-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s ease;
}

.substage-bar-delay {
  position: absolute;
  right: 0;
  top: 0;
  height: 100%;
  background: repeating-linear-gradient(
    45deg,
    #ef4444,
    #ef4444 2px,
    #dc2626 2px,
    #dc2626 4px
  );
  border-radius: 0 4px 4px 0;
}

/* Sequence of Events Timeline */
.events-timeline {
  position: relative;
  padding-left: 24px;
}

.events-timeline::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: linear-gradient(to bottom, #64748b, #94a3b8);
}

.event-item {
  position: relative;
  padding-bottom: 16px;
}

.event-item:last-child {
  padding-bottom: 0;
}

.event-dot {
  position: absolute;
  left: -20px;
  top: 4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #64748b;
  border: 2px solid #1e293b;
}

.event-item.delay .event-dot {
  background: #ef4444;
}

.event-item.milestone .event-dot {
  background: #f97316;
  width: 12px;
  height: 12px;
  left: -21px;
  top: 3px;
}

/* Delay Badge */
.delay-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 10px;
  font-weight: 600;
}

.delay-badge.critical {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
}

.delay-badge.warning {
  background: rgba(245, 158, 11, 0.2);
  color: #f59e0b;
}

.delay-badge.on-track {
  background: rgba(59, 130, 246, 0.2);
  color: #3b82f6;
}

/* Stage Card Hover Effects */
.stage-card {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stage-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
}

/* Drill-down Modal/Panel */
.drill-down-panel {
  position: fixed;
  top: 0;
  right: -500px;
  width: 500px;
  height: 100vh;
  background: #1e293b;
  box-shadow: -10px 0 30px rgba(0, 0, 0, 0.5);
  transition: right 0.3s ease;
  z-index: 9999;
  overflow-y: auto;
}

.drill-down-panel.open {
  right: 0;
}

.drill-down-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  z-index: 9998;
}

.drill-down-overlay.open {
  opacity: 1;
  visibility: visible;
}

/* Light mode adjustments */
.light .drill-down-panel {
  background: #f1f5f9;
}

.light .events-timeline::before {
  background: linear-gradient(to bottom, #94a3b8, #cbd5e1);
}

.light .event-dot {
  border-color: #f1f5f9;
}

/* ========================================
   Events Log Table Styles
   ======================================== */

/* Table container */
.events-log-table {
  width: 100%;
  border-collapse: collapse;
}

.events-log-table th,
.events-log-table td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
}

.events-log-table th {
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

.events-log-table tr:hover {
  background-color: rgba(148, 163, 184, 0.05);
}

/* Delay row highlighting */
.events-log-table tr.delay-row {
  background-color: rgba(245, 158, 11, 0.1);
}

.events-log-table tr.critical-row {
  background-color: rgba(239, 68, 68, 0.15);
}

/* Mobile responsive table */
@media (max-width: 768px) {
  .events-log-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .events-log-table {
    min-width: 800px;
  }
}

/* ========================================
   Notification Toast
   ======================================== */
.notification-toast {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  padding: 0.75rem 1.5rem;
  border-radius: 0.5rem;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
  transform: translateY(100%);
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 9999;
}

.notification-toast.show {
  transform: translateY(0);
  opacity: 1;
}

.notification-toast.success {
  background: #10b981;
  color: white;
}

.notification-toast.error {
  background: #ef4444;
  color: white;
}

/* ========================================
   Export Button Styles
   ======================================== */
.export-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: 9999px;
  transition: all 0.2s;
}

.export-btn:hover {
  transform: scale(1.05);
}

.export-btn svg {
  width: 1rem;
  height: 1rem;
}