/* ============================================================================
   TASKEEN TABLES & LOADING INDICATORS DESIGN SYSTEM
   Version: 1.0
   Last Updated: 2024
   
   This file contains all table styling and loading indicators for the 
   Taskeen application based on the official design system specification.
============================================================================ */

/* ============================================================================
   TABLE BASE STRUCTURE
============================================================================ */

.main-table {
  /* Layout */
  margin-top: 1.5rem;
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;

  /* Border */
  border: 1px solid var(--Gray-Gray-Tint-20, #CDD6DB);
  border-radius: 1rem;

  /* Shadow */
  box-shadow: var(--shadow-card, 4px 16px 40px rgba(87, 67, 49, 0.04));
}

/* Alias for compatibility */
.table-taskeen {
  margin-top: 1.5rem;
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  border: 1px solid var(--Gray-Gray-Tint-20, #CDD6DB);
  border-radius: 1rem;
  box-shadow: var(--shadow-card);
}

/* ============================================================================
   TABLE HEADER
============================================================================ */

.main-table th,
.table-taskeen th {
  /* Dimensions */
  height: auto;
  padding: 1.25rem 1rem;
  gap: 0.75rem;
  flex: 1 0 0;

  /* Background - Dark Green */
  background: linear-gradient(135deg, var(--Main-Colors-Main) 0%, var(--primary-shade-60) 100%) !important;

  /* Typography */
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--Text-Colors-White) !important;
  font-family: var(--font-arabic, Cairo);
  font-size: 0.875rem;
  font-style: normal;
  font-weight: 700;
  line-height: 1.125rem;
  text-align: center;
  vertical-align: middle;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* Header Corner Radius (LTR - English) */
.main-table th:first-child:not(:lang(ar)),
.table-taskeen th:first-child:not(:lang(ar)) {
  border-radius: 0 0 0 0;
}

.main-table th:last-child:not(:lang(ar)),
.table-taskeen th:last-child:not(:lang(ar)) {
  border-radius: 0 0 0 0;
}

/* Header Corner Radius (RTL - Arabic) */
.main-table th:first-child:lang(ar),
.table-taskeen th:first-child:lang(ar) {
  border-radius: 0 0 0 0;
}

.main-table th:last-child:lang(ar),
.table-taskeen th:last-child:lang(ar) {
  border-radius: 0 0 0 0;
}

/* ============================================================================
   TABLE BODY CELLS
============================================================================ */

.main-table td,
.table-taskeen td {
  /* Dimensions */
  height: 4.5rem;
  padding: 1rem 0.5rem;
  gap: 0.75rem;
  flex: 1 0 0;

  /* Border */
  border-bottom: 1px solid var(--Gray-300, #EAECF0);

  /* Background */
  background-color: transparent !important;

  /* Typography */
  overflow: hidden;
  color: var(--Text-Colors-Dark-Gray, #3A403B);
  text-overflow: ellipsis;
  font-family: var(--font-default, Montserrat);
  font-size: 1.0625rem;
  font-style: normal;
  font-weight: 400;
  line-height: 1.25rem;
  text-align: center;
  vertical-align: middle;
}

/* Remove border from last row */
.main-table tbody tr:last-child td,
.table-taskeen tbody tr:last-child td {
  border-bottom: none;
}

/* ============================================================================
   ALTERNATING ROW COLORS (ZEBRA STRIPING)
============================================================================ */

.main-table tbody tr:nth-child(odd),
.table-taskeen tbody tr:nth-child(odd) {
  background: var(--Gray-50);
}

.main-table tbody tr:nth-child(even),
.table-taskeen tbody tr:nth-child(even) {
  background-color: var(--Main-Colors-White);
}

/* ============================================================================
   LAST ROW CORNER RADIUS (LTR - English)
============================================================================ */

.main-table tr:last-child td:last-child:not(:lang(ar)),
.table-taskeen tr:last-child td:last-child:not(:lang(ar)) {
  border-radius: 0rem 0rem 0.75rem 0rem;
}

.main-table tr:last-child td:first-child:not(:lang(ar)),
.table-taskeen tr:last-child td:first-child:not(:lang(ar)) {
  border-radius: 0rem 0rem 0rem 0.75rem;
}

/* ============================================================================
   LAST ROW CORNER RADIUS (RTL - Arabic)
============================================================================ */

.main-table tr:last-child td:last-child:lang(ar),
.table-taskeen tr:last-child td:last-child:lang(ar) {
  border-radius: 0rem 0rem 0rem 0.75rem;
}

.main-table tr:last-child td:first-child:lang(ar),
.table-taskeen tr:last-child td:first-child:lang(ar) {
  border-radius: 0rem 0rem 0.75rem 0rem;
}

/* ============================================================================
   INTERACTIVE STATES
============================================================================ */

/* Hover State */
.main-table tbody tr:hover,
.table-taskeen tbody tr:hover {
  background: var(--Other-Primary-Tint, rgba(43, 86, 49, 0.1)) !important;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.main-table tr:hover td:last-child,
.table-taskeen tr:hover td:last-child {
  background: var(--primary-tint-shades-primary-tint-5);
  box-shadow: -30px 0px 34px 0px rgba(43, 86, 49, 0.1);
}

/* Disable hover on last row (often totals) */
.main-table tr:last-child:hover,
.table-taskeen tr:last-child:hover {
  background: var(--Main-Colors-White, #F9FAFA) !important;
}

/* Active/Selected Row */
.main-table tbody tr.active,
.table-taskeen tbody tr.active {
  background: var(--Other-Primary-Tint, rgba(43, 86, 49, 0.1)) !important;
}

.main-table tr.active td:last-child,
.table-taskeen tr.active td:last-child {
  background: var(--primary-tint-shades-primary-tint-5);
  box-shadow: -30px 0px 34px 0px rgba(43, 86, 49, 0.1);
}

/* ============================================================================
   TABLE ACTIONS
============================================================================ */

.actions {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;

  /* Always visible - no hiding */
  transform: translateX(0);
  opacity: 1;
  height: auto;
  visibility: visible;
  transition: transform 300ms ease-out;
}

/* Show actions on row hover */
.main-table tr:hover .actions,
.table-taskeen tr:hover .actions {
  height: auto;
  transform: translateX(0);
  opacity: 1;
}

/* Show actions on active row */
.main-table tr.active .actions,
.table-taskeen tr.active .actions {
  display: flex;
}

.actions span img {
  width: 1.25rem;
  height: 1.25rem;
}

/* Hide status when row is active (show actions instead) */
.main-table tr:hover .status,
.main-table tr.active .status,
.table-taskeen tr:hover .status,
.table-taskeen tr.active .status {
  display: none;
}

/* ============================================================================
   STATUS BADGE IN TABLE CELL
============================================================================ */

.status {
  gap: 0.375rem;
  flex: 1 0 0;
  display: flex;
  height: 1.5rem;
  padding: 0.375rem 0.75rem 0.375rem 0.625rem;
  align-items: center;
  gap: 0.375rem;
  flex-shrink: 0;
  align-self: stretch;

  border-radius: 0.5rem;
  background: var(--Gray-Gray-Tint-5, #F2F3F3);

  overflow: hidden;
  color: var(--Text-Colors-md-Gray, #858E86);
  text-overflow: ellipsis;

  font-family: var(--font-default, Montserrat);
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.25rem;
}

/* ============================================================================
   CHECKBOX IN TABLE
============================================================================ */

.table-select {
  width: 1.25rem;
  height: 1.25rem;
  flex-shrink: 0;
  border-radius: 0.25rem;
  border: 2px solid var(--Text-Colors-Dark-Gray, #3A403B) !important;
  cursor: pointer;
}

.table-select:checked {
  background: var(--Main-Colors-Main, #2B5631);
  border-color: var(--Main-Colors-Main, #2B5631);
}

/* Spacing for checkbox (LTR) */
.table-select:not(:lang(ar)) {
  margin-right: 0.75rem;
}

/* Spacing for checkbox (RTL) */
.table-select:lang(ar) {
  margin-left: 0.75rem;
}

/* ============================================================================
   SORTABLE TABLE HEADERS
============================================================================ */

.sort-tble-hedr {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  cursor: pointer;
  transition: color var(--transition-fast);
}

.sort-tble-hedr .img {
  width: 1rem;
  height: 1rem;
}

.sort-tble-hedr:hover {
  color: var(--Main-Colors-Main, #2B5631);
}

/* ============================================================================
   TABLE PAGINATION
============================================================================ */

.table-pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  align-self: stretch;
  margin-top: 0.8rem;
}

.total-record-text {
  font-family: var(--font-arabic, Tajawal);
  font-size: 1rem;
  font-style: normal;
  font-weight: 700;
  line-height: normal;
  color: var(--Text-Colors-Black, #101911);
}

.total-record-number {
  font-family: var(--font-arabic, Tajawal);
  font-size: 1rem;
  font-style: normal;
  font-weight: 700;
  line-height: normal;
  color: var(--Text-Colors-Dark-Gray, #3A403B);
}

/* Page Numbers */
.page-numbers {
  display: flex;
  align-items: center;
  direction: ltr;
}

.page-numbers span {
  display: flex;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0.75rem 0.5625rem;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 0.625rem;

  border: 1px solid var(--light-gray, #EFEFEF);

  color: var(--Text-Colors-Dark-Gray, #3A403B);
  font-family: var(--font-arabic, Tajawal);
  font-size: 0.875rem;
  font-weight: 700;

  cursor: pointer;
  transition: background var(--transition-fast);
}

.page-numbers span:hover {
  background: var(--Other-Primary-Tint, rgba(43, 86, 49, 0.1));
}

.page-numbers span.selected {
  background: var(--Gray-50, #F9FAFB);
}

/* ============================================================================
   SPECIAL TABLE VARIANTS
============================================================================ */

/* Details Container Table */
.details-container .main-table th {
  background: var(--Gray-Gray-Tint-5) !important;
}

.details-container .main-table {
  border: 1px solid var(--Gray-Gray-Tint-20, #CDD6DB);
  border-radius: 1rem;
}

.details-container .main-table tbody tr:hover {
  background-color: var(--Gray-Gray-Tint-5) !important;
}

.details-container .main-table tr:hover td:last-child {
  box-shadow: none;
}

.details-container .main-table tbody tr:last-child:hover {
  background-color: transparent !important;
}

/* ============================================================================
   LOADING INDICATORS
============================================================================ */

/* Dual Rotating Squares Loader */
.loader {
  width: 64px;
  height: 64px;
  display: inline-block;
  position: relative;
}

.loader::after,
.loader::before {
  content: "";
  width: 64px;
  height: 64px;
  border: 5px solid var(--Main-Colors-Secondry, #B4975A);
  position: absolute;
  left: 0;
  top: 0;
  box-sizing: border-box;
  animation: rotation 2s ease-in-out infinite;
}

.loader::after {
  border-color: var(--Main-Colors-Main, #2B5631);
  animation-delay: 1s;
}

@keyframes rotation {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

/* Simple Spinner (Login) */
.spinner {
  width: 1rem;
  height: 1rem;
  border: 2px solid transparent;
  border-top: 2px solid currentColor;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

/* Processing Section */
.processing-section {
  min-height: 200px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.spinner-border {
  width: 3rem;
  height: 3rem;
  border: 0.25rem solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spinner-border 0.75s linear infinite;
}

@keyframes spinner-border {
  to {
    transform: rotate(360deg);
  }
}

/* ============================================================================
   PROGRESS BARS
============================================================================ */

/* Progress Bar */
.acco-progress {
  --bs-progress-bg: var(--color-button-light, #EAE6E2);
  --bs-progress-bar-color: var(--Text-Colors-White, #F9FAF9);
  width: 100%;
  --bs-progress-height: 0.5rem;
  --bs-progress-border-radius: 0.5rem;
}

/* Complete (100%) - Green */
.complete {
  --bs-progress-bar-bg: var(--success-green);
}

/* Semi-complete (50-99%) - Orange */
.semi-complete {
  --bs-progress-bar-bg: var(--warning-gold);
}

/* Incomplete (<50%) - Red */
.incomplete {
  --bs-progress-bar-bg: var(--Other-Red);
}

.progress-bar {
  color: var(--Text-Colors-White, #F9FAF9);
  font-family: var(--font-default, Montserrat);
  font-size: 0.875rem;
  font-weight: 700;
  line-height: 1.125rem;
}

/* Progress Container */
.progress-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  width: 100%;
}

.progress-value {
  color: var(--Text-Colors-Black);
  font-family: var(--font-arabic, Cairo);
  font-size: 1.125rem;
  font-weight: 700;
  line-height: 2.75rem;
  letter-spacing: -0.0225rem;
  min-width: 3.5rem;
}

/* ============================================================================
   SKELETON LOADERS
============================================================================ */

.placeholder-glow {
  animation: placeholder-glow 2s ease-in-out infinite;
}

@keyframes placeholder-glow {
  50% {
    opacity: 0.2;
  }
}

.placeholder {
  display: inline-block;
  min-height: 1em;
  vertical-align: middle;
  cursor: wait;
  background-color: currentColor;
  opacity: 0.5;
}

.placeholder.bg-secondary {
  background-color: var(--Gray-Gray-Tint-5, #F2F3F3) !important;
}

/* ============================================================================
   RESPONSIVE DESIGN
============================================================================ */

/* Mobile */
@media (max-width: 768px) {

  .main-table,
  .table-taskeen {
    font-size: 0.875rem;
  }

  .main-table th,
  .main-table td,
  .table-taskeen th,
  .table-taskeen td {
    padding: 0.5rem;
  }

  .loader {
    width: 48px;
    height: 48px;
  }

  .loader::after,
  .loader::before {
    width: 48px;
    height: 48px;
  }
}

/* Tablet */
@media (min-width: 769px) and (max-width: 1024px) {

  .main-table,
  .table-taskeen {
    font-size: 0.9375rem;
  }
}

/* ============================================================================
   END OF TASKEEN TABLES DESIGN SYSTEM
============================================================================ */