/* ========================================
   Renewal Cycle Dashboard - Main Styles (Arabic/RTL)
   ======================================== */

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

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

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

.animate-slide-out-left {
  animation: slide-out-left 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%);
}

/* Apply Zain font globally for Arabic */
* {
  font-family: 'Zain', sans-serif;
}

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

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

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

/* ========================================
   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 (RTL) */
@keyframes timeline-grow-rtl {
  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 (RTL - origin from right) */
.stage-seg {
  transform-origin: right center;
  animation: timeline-grow-rtl 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; }

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

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

.inactivity-stripes {
  background: repeating-linear-gradient(
    135deg,
    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(
    135deg,
    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 (RTL)
   ======================================== */
.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;
  direction: rtl;
}

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

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

.stage-seg:hover {
  filter: brightness(1.1);
  transform: scaleY(1.08);
  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 - RTL)
   ======================================== */
.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 RTL Container
   ======================================== */
.timeline-rtl {
  direction: rtl;
  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 (RTL)
   ======================================== */

/* 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 (RTL) */
.substage-bar {
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
  position: relative;
  direction: rtl;
}

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

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

/* Sequence of Events Timeline (RTL) */
.events-timeline {
  position: relative;
  padding-inline-start: 24px;
  padding-inline-end: 0;
}

.events-timeline::before {
  content: '';
  position: absolute;
  inset-inline-start: 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;
  inset-inline-start: -20px;
  top: 4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #f97316;
  border: 2px solid #1e293b;
}

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

.event-item.milestone .event-dot {
  background: #f97316;
  width: 12px;
  height: 12px;
  inset-inline-start: -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 (RTL) */
.drill-down-panel {
  position: fixed;
  top: 0;
  left: -500px;
  right: auto;
  width: 500px;
  height: 100vh;
  background: #1e293b;
  box-shadow: 10px 0 30px rgba(0, 0, 0, 0.5);
  transition: left 0.3s ease;
  z-index: 9999;
  overflow-y: auto;
}

.drill-down-panel.open {
  left: 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 (RTL)
   ======================================== */

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

.events-log-table th,
.events-log-table td {
  padding: 8px 12px;
  text-align: right;
  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;
  }
}
