@tailwind base;
@tailwind components;
@tailwind utilities;
/* * {
  font-family: "almarai";
} */

:root {
  /* primary colors */
  --primary50: 247 245 230;
  --primary100: 231 223 176;
  --primary200: 219 207 138;
  --primary300: 202 185 84;
  --primary400: 192 172 51;
  --primary500: 176 151 0;
  --primary600: 160 137 0;
  --primary700: 125 107 0;
  --primary800: 97 83 0;
  --primary900: 74 63 0;

  /* secondary colors */
  --secondary50: 238 238 239;
  --secondary100: 202 203 204;
  --secondary200: 176 177 179;
  --secondary300: 140 142 144;
  --secondary400: 118 120 123;
  --secondary500: 84 86 90;
  --secondary600: 76 78 82;
  --secondary700: 60 61 64;
  --secondary800: 46 47 50;
  --secondary900: 35 36 38;

  /* font colors */
  --fontPrimary: #202020;
  --fontSecondary: #646464;
  --fontTertiary: #9a9a9a;

  /* background colors */
  --background: #ffffff;
  --backgroundGray: #f9f9f9;
}

/* @media (prefers-color-scheme: dark)  */
[data-theme="dark"] {
  /* font colors */
  --fontPrimary: #ffffff;
  --fontSecondary: #ffffffde;
  --fontTertiary: #ffffffde;

  /* background colors */
  --background: #121212;
  --backgroundGray: #2a2a2a;
}

@layer components {
  .main-title {
    @apply relative pb-4 text-base md:text-xl text-fontColorPrimary font-bold border-b mb-3 md:mb-4;
    @apply after:content-[''] after:absolute after:bottom-0 rtl:after:rounded-se-3xl after:rounded-se-3xl rtl:after:right-0 after:left-0 after:w-[60px] after:h-1 after:bg-yellow-500;
  }
  .dash-title {
    @apply relative pb-2 ps-4 text-xl text-fontColorPrimary font-bold border-b mb-4;
    @apply after:content-[''] after:absolute after:right-0 after:top-1/2 after:-translate-y-1/2 after:w-1.5 after:h-6 after:bg-yellow-500 after:rounded-md;
  }
  .main-container {
    @apply bg-background p-2 border border-[#E9E9E9] rounded-xl;
  }
  .pagination-btn {
    @apply flex items-center gap-2 px-4 border rounded-xl !text-fontColorSecondary hover:border-primary-500 hover:text-primary-500;
  }
}

/* .font-default {
  --font-default: var(--font-aljazeera); 
}
.font-heading {
  --font-heading: var(--font-saudi);
}
.font-content {
  --font-content: var(--font-droid);
} */

body {
  color: var(--fontPrimary);
  background: var(--background);
  font-family: var(--font-default);
  font-size: 16px;
  line-height: 1.6;
}

main,
header,
footer {
  font-family: var(--font-default);
}

h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--font-heading, var(--font-default));
}

::selection {
  color: white;
  background: rgb(var(--primary300));
}

*::-webkit-scrollbar {
  width: 8px;
  height: 6px;
}

*::-webkit-scrollbar-track {
  background: var(--background);
}

*::-webkit-scrollbar-thumb {
  background-color: rgb(var(--primary500));
  border: 3px solid rgb(var(--primary500));
}

.thin-scroll::-webkit-scrollbar {
  width: 2px;
  height: 2px;
  scroll-behavior: smooth;
  scrollbar-width: 2px;
}

.no-scroll {
  scrollbar-width: none;
}

a:hover {
  color: rgb(var(--primary500)) !important;
}

.headroom--pinned {
  z-index: 999 !important;
  background: var(--background);
  box-shadow: 0px 4px 4px 4px rgba(176, 151, 0, 0.1);
  border-bottom: 1px solid #e5e5e5;
}

.headroom--unpinned {
  transform: translateY(0%) !important;
  z-index: 999 !important;
  background: var(--background);
  box-shadow: 0px 4px 4px 4px rgba(176, 151, 0, 0.1);
  border-bottom: 1px solid #e5e5e5;
}

.table-wrapper {
  max-width: 100%;
}

.custome-table {
  width: 100%;
  max-width: 100%;
}

.custome-table table {
  border-collapse: collapse;
  text-align: center;
  border-radius: 16px;
  /* Fixed layout on desktop so tables always fit the article width: columns
     share the space (or honor editor resize widths) and cell text wraps,
     instead of expanding to content and overflowing. Mobile overrides this
     back to `auto` + horizontal scroll in the max-width:639px block below. */
  table-layout: fixed;
  width: 100%;
  max-width: 100%;
}

.custome-table th,
.custome-table td {
  border: 1px solid theme("colors.yellow.500");
  padding: 10px;
  word-break: normal;
  overflow-wrap: break-word;
  white-space: normal;
}

.custome-table th {
  background-color: theme("colors.yellow.500");
  font-weight: bold;
  padding: 16px;
}

.custome-table td {
  background-color: theme("colors.background");
  padding: 16px;
}

/* CMS table defaults (respects editor styles if present) */
.custome-table thead th,
.custome-table thead td {
  background-color: theme("colors.yellow.500");
  color: #202020;
  font-weight: 700;
  border-color: theme("colors.yellow.400");
  border-bottom-color: theme("colors.yellow.500");
}

.custome-table tbody tr:nth-child(odd) td {
  background-color: theme("colors.background");
  color: #202020;
}

.custome-table tbody tr:nth-child(even) td {
  background-color: theme("colors.yellow.50");
  color: #202020;
}

.custome-table tr.cms-table-header-row td,
.custome-table tr.cms-table-header-row th {
  background-color: theme("colors.yellow.500") !important;
  color: #202020 !important;
  font-weight: 700 !important;
  border-color: theme("colors.yellow.400") !important;
  border-bottom-color: theme("colors.yellow.500") !important;
}

@media (max-width: 639px) {
  /* Mobile keeps horizontal scroll for wide tables; desktop shrinks to fit. */
  .table-wrapper,
  .custome-table {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Default tables (<= 3 columns) */
  .custome-table table {
    width: 100%;
    max-width: 100%;
    table-layout: auto;
  }

  /* Scrollable tables (> 3 columns) */
  .scrollable-table-wrapper {
    overflow-x: auto !important;
    display: block;
    width: 100%;
  }

  .scrollable-table-wrapper table {
    /* Use auto to respect inline 'style="width: ..."' while ensuring expansion */
    width: auto; 
    min-width: 100% !important;
    max-width: none !important;
    display: table !important;
  }

  .scrollable-table-wrapper th {
    white-space: nowrap !important; /* Force width expansion for complex headers */
    padding: 12px 16px !important;
    min-width: 120px;
  }

  .scrollable-table-wrapper td {
    padding: 8px 10px;
    font-size: 14px;
    white-space: normal;
    min-width: 120px; /* Ensure minimum floor for legibility */
  }
}

.dynamic-text {
  line-height: 180%;
  font-family: var(--font-content, var(--font-default));
  font-size: 16px;
}
.dynamic-text {
  word-wrap: break-word;
  overflow-wrap: break-word;
  word-break: break-word;
  white-space: normal;
  max-width: 100%;
  overflow: visible;
}
.slider-text {
  font-family: var(--font-slider, var(--font-default));
  font-size: var(--font-slider-size, 16px);
}

.ant-table-thead th {
  font-size: 14px;
  color: #202020;
}
a.ant-btn-primary:hover {
  color: white !important;
}

.newsletter-table .selected-row > .ant-table-cell {
  background-color: #f7f5e6 !important;
}
.poll-modal .ant-modal-close {
  border: 1px solid #e9e9e9 !important;
  border-radius: 8px !important;
  margin-top: 3px;
}

.ant-pagination-item-active {
  background-color: #fcf7ea !important;
  border-color: theme("colors.primary.100") !important;
}

.not-checked {
  background-color: #ddd !important;
}

.checked {
  background-color: #e7dfb0 !important;
}

.not-checked .ant-switch-handle::before {
  background-color: white !important;
}

.checked .ant-switch-handle::before {
  background-color: #b09700 !important;
}

.user-upload .ant-upload.ant-upload-select {
  border: 1px #e9e9e9 solid !important;
}

.ant-upload-list-item-container {
  width: auto !important;
  height: auto !important;
}

.ant-modal-footer {
  display: flex;
  flex-direction: row-reverse;
  gap: 12px;
}

.ltr-dropdown .ant-select-item {
  direction: ltr;
  text-align: left;
}

.media-page-details .ant-tabs-content-holder {
  background: #fafafa;
}

.ant-col.ant-form-item-label {
  padding: 0px 0px 3px 0px !important;
}

.ant-picker-time-panel-cell-selected .ant-picker-time-panel-cell-inner {
  background-color: theme("colors.primary.500") !important;
  color: white !important;
}

/* iOS Safari viewport height fix */
@supports (-webkit-touch-callout: none) {
  /* For iOS Safari, ensure proper height handling */
  html {
    height: -webkit-fill-available;
  }

  body {
    min-height: 100vh;
    min-height: -webkit-fill-available;
  }
}

/* 
======================================================
  JODIT TEXT EDITOR TWEAKS (Dashboard)
======================================================
  Forces table layout to be "fixed" inside the editor. 
  This stops the browser's auto-calculation from fighting 
  with the editor's drag-and-drop resizing handles, 
  making cell adjustment much smoother.
*/
.jodit-wysiwyg table {
  table-layout: fixed !important; 
}

.jodit-wysiwyg table td,
.jodit-wysiwyg table th {
  word-wrap: break-word !important;
  overflow-wrap: break-word !important; 
  /* Allows text to break so you can drag columns smaller */
}

/* 
======================================================
  TABLE RESIZE - JODIT EDITOR (Dashboard)
======================================================
  Styles for Jodit's table resize functionality
  (column resize, whole table resize via edge)
*/

/* Jodit's table resizer handle styling */
.jodit-table-resizer {
  position: absolute !important;
  width: 5px !important;
  cursor: col-resize !important;
  z-index: 100 !important;
  background: transparent !important;
  transition: background 0.15s ease !important;
  pointer-events: auto !important;
}

.jodit-table-resizer:hover,
.jodit-table-resizer.jodit-table-resizer_moved {
  background: rgba(59, 130, 246, 0.8) !important;
  width: 4px !important;
}

/* Prevent text selection during resize */
.jodit-wysiwyg.jodit-table-resizing {
  user-select: none !important;
  cursor: col-resize !important;
}

/* Ensure inline styles on table elements can override global.css */
.jodit-wysiwyg table[style*="width"],
.jodit-wysiwyg table[style*="height"],
.jodit-wysiwyg table td[style*="width"],
.jodit-wysiwyg table th[style*="width"] {
  /* Allow inline styles to take precedence */
}
