@font-face {
  font-family: "Sakkal Majalla";
  src: local("Sakkal Majalla");
}

/* Existing Styles from original file - ensure these are present */
.gauge-arc-background {
  fill: none;
  stroke: #e9ecef;
  stroke-linecap: round;
}
.gauge-arc-value {
  fill: none;
  stroke-linecap: round;
  /* transition: stroke-dasharray 0.5s ease-out; /* Consider removing for rapid updates if causing issues */
}
.gauge-value-text {
  font-weight: bold;
  text-anchor: middle;
  dominant-baseline: central;
}
.gauge-title-text {
  font-weight: bold;
  text-anchor: middle;
  dominant-baseline: hanging;
}
.gauge-description-text {
  text-anchor: middle;
  dominant-baseline: hanging;
}
.gauge-description-text tspan {
  text-anchor: middle;
  dominant-baseline: hanging;
}
.gauge-circle-label {
  text-anchor: middle;
  dominant-baseline: central;
  font-weight: bold;
  pointer-events: none;
}
.gauge-circle-label.fa-icon {
  font-family: "Font Awesome 6 Free", sans-serif; /* Ensure sans-serif fallback */
  font-weight: 900;
}
#chartTitleSVG {
  font-weight: 600;
  text-anchor: middle;
  dominant-baseline: hanging;
}
.color-preview {
  display: inline-block;
  width: 18px;
  height: 18px;
  margin-right: 5px;
  border: 1px solid #ccc;
  vertical-align: middle;
  border-radius: 3px;
}
.total-percentage-display {
  font-size: 0.85em;
  margin-top: 8px;
  text-align: center;
  font-weight: 600;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  background: #3b82f6;
  border-radius: 50%;
  cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  background: #3b82f6;
  border-radius: 50%;
  cursor: pointer;
}

/* Drag and Drop / Reordering Styles */
.gauge-container {
  cursor: grab;
  transition: transform 0.2s ease-out;
  pointer-events: all;
}
.gauge-container.dragging {
  cursor: grabbing;
  opacity: 0.7;
  z-index: 10;
  transition: none;
}
.drop-zone {
  border: 2px dashed #cccccc;
  background-color: rgba(204, 204, 204, 0.1);
  border-radius: 8px;
  box-sizing: border-box;
  transition: background-color 0.2s ease, border-color 0.2s ease;
  pointer-events: none;
}
.drop-zone.drop-active {
  border-color: #3b82f6;
  background-color: rgba(59, 130, 246, 0.15);
}

/* Multi-segment Label Styles */
.segment-label-group {
  pointer-events: none;
}
.segment-label-text {
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
}
.segment-label-shape {
  stroke: #cccccc;
  stroke-width: 1;
  pointer-events: none;
}

#mainChartSVG {
  display: block;
  overflow: visible;
}
.custom-segment-offset-controls.hidden {
  display: none !important; /* Ensure !important if Tailwind tries to override */
}
.custom-segment-offset-controls {
  display: flex;
}

/* === Styles Moved from index.php <style> block & Refinements === */

/* Full Height Layout */
html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
}
body {
  display: flex;
  flex-direction: column;
  /* font-family: "Cairo", sans-serif; Default font for the body */
  background-color: #f3f4f6; /* Tailwind gray-100 for overall page background */
}
.navbar {
  flex-shrink: 0;
  height: 60px;
  background-color: white; /* Consistent with current design */
  box-shadow: 0 2px 4px -1px rgba(0, 0, 0, 0.06),
    0 4px 5px 0 rgba(0, 0, 0, 0.06); /* Tailwind shadow-md like */
}
.content-body-wrapper {
  flex-grow: 1;
  display: flex;
  overflow: hidden;
}

/* Mini Sidebar (Now mostly Tailwind classes in HTML) */
/* .mini-sidebar, .mini-sidebar-item, .sidebar-icon-trigger, .mini-sidebar-dropdown */
/* will have their core styles applied via Tailwind in the HTML. */
/* This CSS block is for any overrides or minor adjustments if Tailwind can't do it easily. */

/* Example of a very specific override if needed: */
/* .mini-sidebar-dropdown { */
/* For instance, if Tailwind's origin-top-right isn't perfect for RTL due to complex transforms: */
/* transform-origin: 100% 0;  /* Explicitly top-right for RTL dropdowns */
/* } */
/* Problem 1: Mini-Sidebar Dropdown Disappears Too Quickly & Styling Improvements */

/* Base Mini Sidebar Item Styles (Problem 1 & Enhancements) */
.mini-sidebar-item {
  position: relative;
  width: 100%;
  display: flex;
  justify-content: center;
}

.mini-sidebar-item::after {
  content: "";
  position: absolute;
  top: 0;
  right: 100%; /* Extends to the left of the icon (RTL) */
  width: 10px; /* Buffer zone width */
  height: 100%;
  z-index: 1;
  pointer-events: none; /* Ensure it doesn't block clicks */
}

/* Enhanced Mini Sidebar Dropdown Styles (Problem 1 & Enhancements) */
.mini-sidebar-dropdown {
  /* Visual enhancements */
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  padding: 1.5rem; /* Default padding, overridden for mobile */
  min-width: 280px;
  transform-origin: top right;

  /* Behavior from Problem 1 */
  transition: opacity 0.2s ease-out, transform 0.2s ease-out,
    visibility 0s linear 0.1s !important;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  margin-right: 8px; /* Buffer from icon */
}

/* Dropdown visibility logic (Problem 1) */
.mini-sidebar-item:hover > .mini-sidebar-dropdown,
.mini-sidebar-item.js-dropdown-active > .mini-sidebar-dropdown {
  opacity: 1 !important;
  visibility: visible !important;
  transform: scale(1) translateX(0) !important;
  transition-delay: 0s, 0s, 0s !important; /* Ensure immediate show */
  pointer-events: auto !important;
}

/* Modernized Mini Sidebar Container (Enhancements) */
.mini-sidebar {
  width: 72px; /* Slightly wider for better touch targets */
  background: linear-gradient(
    180deg,
    #1f2937,
    #111827
  ); /* Gradient for depth */
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  padding-top: 1rem;
  padding-bottom: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  z-index: 100; /* Ensure it's above other content if fixed/absolute */
  transition: background 0.3s ease;
}

/* Sidebar Icon Trigger Styling (Enhancements) */
.sidebar-icon-trigger {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.1);
  color: #d1d5db; /* gray-300 */
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  position: relative; /* For z-index stacking if needed */
  z-index: 2; /* Above pseudo-element if any overlap issues */
}

.sidebar-icon-trigger:hover,
.sidebar-icon-trigger:focus {
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
  transform: scale(1.05);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Dropdown Item Styling (Enhancements) */
.dropdown-item {
  /* General class for items inside .mini-sidebar-dropdown */
  border-radius: 8px;
  padding: 1rem; /* Default padding for items */
  transition: background-color 0.2s ease, transform 0.2s ease;
}

.dropdown-item:hover {
  background-color: #f3f4f6; /* gray-100 */
  transform: translateX(
    -4px
  ); /* Subtle slide effect for LTR, adjust for RTL if needed */
}

/* Responsive Adjustments for Mini-Sidebar */
@media (max-width: 640px) {
  .mini-sidebar {
    width: 60px;
    /* position: fixed; /* HTML structure should handle this based on sm:relative */
    /* top: 60px; */
    /* right: 0; */
    /* z-index: 1000; /* Ensure high z-index if it becomes fixed on mobile */
  }

  .sidebar-icon-trigger {
    width: 40px;
    height: 40px;
  }

  .mini-sidebar-dropdown {
    width: 240px; /* Narrower dropdown for mobile */
    padding: 1rem; /* Reduced padding for mobile */
  }
}

/* Custom scrollbar for dropdowns and side panel */
.custom-scrollbar::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
.custom-scrollbar::-webkit-scrollbar-track {
  background: #f3f4f6; /* gray-100 */
  border-radius: 12px;
}
.custom-scrollbar::-webkit-scrollbar-thumb {
  background: #9ca3af; /* gray-400 */
  border-radius: 12px;
}
.custom-scrollbar::-webkit-scrollbar-thumb:hover {
  background: #6b7280; /* gray-500 */
}

/* Side Panel (Settings) Styles */
.side-panel {
  width: 380px;
  height: 100%;
  background-color: white;
  border-left: 1px solid #e5e7eb; /* Tailwind gray-200 */
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.side-panel .tabs-nav-container {
  flex-shrink: 0;
  display: flex;
  border-bottom: 1px solid #e5e7eb; /* Tailwind gray-200 */
}
.side-panel .tab-content {
  flex-grow: 1;
  position: relative;
  overflow: hidden; /* This element itself does not scroll */
}
.settings-tab {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  overflow-y: auto; /* THIS is where the scrollbar will be */
  padding: 1rem; /* Tailwind p-4 */
  display: none;
}
.settings-tab.active {
  display: block;
}
.tab-btn {
  padding: 0.75rem 1rem; /* Tailwind px-4 py-3 */
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem; /* Tailwind gap-2 */
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease,
    border-color 0.2s ease;
  border: none;
  border-bottom: 2px solid transparent; /* For active state */
  background-color: transparent;
  font-weight: 500; /* Medium weight */
  color: #4b5563; /* Tailwind gray-600 */
}
.tab-btn:hover {
  background-color: #f3f4f6; /* Tailwind gray-100 */
  color: #1f2937; /* Tailwind gray-800 */
}
.tab-btn.active {
  background-color: white; /* Or a very light blue: #eff6ff (blue-50) */
  color: #3b82f6; /* Tailwind blue-500 */
  border-bottom-color: #3b82f6; /* Tailwind blue-500 */
}
.tab-btn i {
  margin-right: 0.5rem; /* For LTR */
}
[dir="rtl"] .tab-btn i {
  margin-right: 0;
  margin-left: 0.5rem;
}

/* Main Content Area (Canvas) Styles */
.main-content.canvas-area {
  flex-grow: 1;
  height: 100%;
  background-color: #e5e7eb; /* Tailwind gray-200 for slight contrast */
  background-image: linear-gradient(rgba(0, 0, 0, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 0, 0, 0.02) 1px, transparent 1px);
  background-size: 20px 20px;
  padding: 1.25rem; /* Tailwind p-5 */
  box-sizing: border-box;
  overflow: auto;
  display: flex;
  justify-content: center;
  align-items: center;
}

.canvas-content {
  background: white;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1),
    0 4px 6px -4px rgba(0, 0, 0, 0.1); /* Tailwind shadow-lg */
  width: 100%;
  height: 100%;
  max-width: 95vw;
  max-height: calc(
    100% - 0px
  ); /* Remove the 30px to allow full use of padding from parent */
  display: flex;
  flex-direction: column;
  border-radius: 0.5rem; /* Tailwind rounded-lg */
  overflow: hidden; /* Clip chart-container if it tries to overflow */
}

.chart-container {
  flex-grow: 1;
  position: relative;
  overflow: hidden; /* Content inside should not make this scroll */
  padding: 1.5rem; /* Tailwind p-6 */
}

#mainChartSVG {
  width: 100%;
  height: 100%;
  display: block;
}

/* Project Name Input in Navbar */
#projectName {
  border: 1px solid #d1d5db; /* gray-300 */
  padding: 0.5rem; /* p-2 */
  border-radius: 0.375rem; /* rounded-md */
  width: 100%;
  text-align: center;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
#projectName:focus {
  outline: 2px solid transparent;
  outline-offset: 2px;
  border-color: #2563eb; /* blue-600 */
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.3); /* Tailwind-like ring */
}

/* Animation for Chart Update Highlight on .canvas-content */
.highlight-change {
  animation: highlight-pulse 0.7s ease-out;
}
@keyframes highlight-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.3),
      0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
  }
  50% {
    box-shadow: 0 0 0 10px rgba(59, 130, 246, 0),
      0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
  }
  100% {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1),
      0 4px 6px -4px rgba(0, 0, 0, 0.1);
  }
}

/* Utility: Hidden class (if not using Tailwind's default) */
.hidden {
  display: none !important;
}

/* Styles for input fields within data tab for consistency */
#dataTab .gauge-input label,
#displayTab .text-style-group label, /* Apply to labels in display tab fieldsets too */
#generalTab .mb-3 label {
  /* Apply to labels in general tab */
  display: block;
  font-size: 0.875rem; /* text-sm */
  color: #4b5563; /* gray-600 */
  margin-bottom: 0.25rem; /* mb-1 */
  font-weight: 500; /* medium */
}

#dataTab .gauge-group input[type="text"],
#dataTab .gauge-group input[type="number"],
#dataTab .gauge-group select,
.settings-tab input[type="text"], /* Generalize for all tabs */
.settings-tab input[type="number"],
.settings-tab select {
  width: 100%;
  padding: 0.5rem 0.75rem; /* p-2 px-3 */
  border: 1px solid #d1d5db; /* gray-300 */
  border-radius: 0.375rem; /* rounded-md */
  font-size: 0.875rem; /* text-sm */
  box-shadow: inset 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
#dataTab .gauge-group input[type="text"]:focus,
#dataTab .gauge-group input[type="number"]:focus,
#dataTab .gauge-group select:focus,
.settings-tab input[type="text"]:focus,
.settings-tab input[type="number"]:focus,
.settings-tab select:focus {
  border-color: #2563eb; /* blue-600 */
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.3); /* Tailwind-like ring */
  outline: none;
}
#dataTab .gauge-group input[type="color"],
.settings-tab input[type="color"] {
  /* Generalize for all tabs */
  width: 100%;
  height: 2.5rem; /* h-10 */
  padding: 0.25rem; /* p-1 */
  border: 1px solid #d1d5db;
  border-radius: 0.375rem;
  cursor: pointer;
}
#dataTab .segment-inputs {
  border: 1px solid #e5e7eb; /* gray-200 */
  padding: 0.75rem; /* p-3 */
  border-radius: 0.375rem; /* rounded-md */
  background-color: #f9fafb; /* gray-50, slight contrast */
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05); /* shadow-sm */
}
#dataTab .segment-inputs .text-blue-700 {
  color: #1d4ed8; /* Tailwind blue-700 */
}

/* My Charts List styling in sidebar dropdown */
#myChartsListSidebar .dropdown-item:hover {
  /* For items within myChartsListSidebar */
  background-color: #f3f4f6; /* gray-100 */
}

/* Print hidden utility */
@media print {
  .print\:hidden {
    display: none !important;
  }
}
