:root {
  /* Light Mode (Default) - Purple Accent Theme */
  --primary-main: #7F56D9; /* Path Wounded Purple */
  --primary-light: #9A7EE5; /* Lighter shade of PW Purple */
  --primary-dark: #6A40C1;  /* Darker shade of PW Purple */
  --primary-contrast: #FFFFFF;

  /* Secondary color can be kept or updated if a new accent is desired */
  --secondary-main: #10B981; /* Existing Green */
  --secondary-light: #34D399;
  --secondary-dark: #059669;
  --secondary-contrast: #FFFFFF;

  --neutral-main: #6B7280;
  --neutral-light: #E5E7EB;
  --neutral-medium: #9CA3AF;
  --neutral-dark: #4B5563;
  --neutral-contrast: #FFFFFF; /* Contrast for neutral-main buttons etc. */

  --background-default: #F9FAFB; /* Page background - Light */
  --background-paper: #FFFFFF;   /* Cards, sidebar, header in light mode - White */
  
  --text-primary: #111827;       /* Dark text for light backgrounds */
  --text-secondary: #6B7280;     /* Medium gray text */
  --text-disabled: #9CA3AF;
  --text-on-primary-bg: var(--primary-contrast);

  --error-main: #EF4444;
  --warning-main: #F59E0B;
  --info-main: #3B82F6;
  --success-main: #10B981; /* Kept green for success */

  --border-color: #E5E7EB;       /* Light gray borders */
  --border-color-light: #F3F4F6;

  --header-bg: var(--background-paper);
  --header-text: var(--text-primary);
  --header-border: var(--border-color);
  --header-height: 64px;

  --sidebar-bg: var(--background-paper);
  --sidebar-text: var(--text-primary);
  --sidebar-icon-color: var(--neutral-medium);
  --sidebar-border: var(--border-color);
  --sidebar-width: 260px;
  --sidebar-nav-link-hover-bg: var(--neutral-light);
  --sidebar-nav-link-active-bg: var(--primary-main);
  --sidebar-nav-link-active-text: var(--text-on-primary-bg);
  --sidebar-nav-link-active-icon: var(--text-on-primary-bg);

  --footer-bg: var(--background-default);
  --footer-text: var(--text-secondary);
  --footer-border: var(--border-color);
  --footer-height: 25px;

  --font-family-base: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
  --border-radius-small: 4px;
  --border-radius-medium: 8px;
  --border-radius-large: 12px;
  --box-shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --box-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --box-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --transition-speed: 0.2s;
  --transition-cubic: cubic-bezier(0.4, 0, 0.2, 1);
  --sidebar-collapsed-width: 80px; /* Width of the sidebar when collapsed */
  --background-header-table: var(--neutral-light);

  /* NEW or ALIASES for Help & Support Page */
  --background-color-secondary: var(--background-paper); /* Or a slightly different shade if desired, e.g., #FDFEFE for a subtle difference */
  --border-color-soft: var(--border-color-light); /* Using existing light border */
  --border-color-extralight: #F9FAFB; /* A very light border, almost matching default bg */
  --border-radius-pill: 20px; /* For pill-shaped badges */
  
  --text-color-primary-muted: var(--text-secondary); /* Can use text-secondary or a new, slightly darker gray than text-secondary but lighter than text-primary */

  /* Semantic color variants for statuses/alerts */
  --color-warning: var(--warning-main);
  --color-warning-soft: #FFFBEB; /* Light yellow background */
  --color-warning-dark: #B45309; /* Dark yellow/brown text */

  --color-info: var(--info-main);
  --color-info-soft: #EFF6FF;    /* Light blue background */
  --color-info-dark: #1E40AF;   /* Dark blue text */

  --color-success: var(--success-main);
  --color-success-soft: #F0FDF4;  /* Light green background */
  --color-success-dark: #15803D; /* Dark green text */
  
  /* For primary-based statuses (like 'in-progress') */
  --color-primary-soft: #F5F3FF; /* Light purple background (derived from --primary-main: #7F56D9) */
  --color-primary-dark: var(--primary-dark); /* Using existing --primary-dark for text */
}

[data-theme="dark"] {
  /* Dark Mode - Path Wounded Inspired */
  --primary-main: #7F56D9; /* Path Wounded Purple */
  --primary-light: #9A7EE5;
  --primary-dark: #6A40C1;
  --primary-contrast: #FFFFFF; /* White text on purple */

  /* Secondary color can be a dimmer purple or a contrasting accent if needed */
  --secondary-main: #5C3DAA; /* A slightly desaturated/darker purple for secondary elements */
  --secondary-light: #7F56D9;
  --secondary-dark: #4A2B8D;
  --secondary-contrast: #FFFFFF;

  --neutral-main: #A0ABC0; /* Lighter gray for text/elements in dark mode */
  --neutral-light: #4A5568; /* Hover for nav links, slightly lighter than paper */
  --neutral-medium: #718096; /* Icon color, secondary text */
  --neutral-dark: #2D3748;   /* Borders or subtle dividers */
  --neutral-contrast: #0B0C0F; /* Contrast for neutral-main buttons etc. */

  --background-default: #0B0C0F; /* Very dark, near-black page background */
  --background-paper: #14151A;   /* Dark gray for cards, sidebar, header */
  
  --text-primary: #E0E7FF;       /* Light, slightly bluish text for primary content */
  --text-secondary: #A0ABC0;     /* Dimmer light gray for secondary text */
  --text-disabled: #4A5568;
  --text-on-primary-bg: var(--primary-contrast);

  --error-main: #E53E3E; /* Brighter red for dark mode */
  --warning-main: #DD6B20; /* Brighter orange for dark mode */
  --info-main: #3182CE; /* Brighter blue for dark mode */
  --success-main: #38A169; /* Brighter green for dark mode */

  --border-color: #2A2B33;       /* Subtle dark border */
  --border-color-light: #374151; /* Lighter border for dark mode */

  /* NEW or ALIASES for Help & Support Page - DARK THEME */
  --background-color-secondary: var(--background-paper); /* Or a slightly different shade, e.g., #1A1C23 */
  --border-color-soft: var(--neutral-dark); 
  --border-color-extralight: #1E1F24; /* Very subtle border for dark theme */
  
  --text-color-primary-muted: var(--neutral-medium);

  /* Semantic color variants for statuses/alerts - DARK THEME */
  --color-warning-soft: #422006; /* Darker, muted yellow background */
  --color-warning-dark: #FDE68A; /* Lighter yellow text */

  --color-info-soft: #1E293B;    /* Darker, muted blue background */
  --color-info-dark: #93C5FD;   /* Lighter blue text */

  --color-success-soft: #062A16;  /* Darker, muted green background */
  --color-success-dark: #A7F3D0; /* Lighter green text */

  /* For primary-based statuses (like 'in-progress') - DARK THEME */
  --color-primary-soft: #2A2247; /* Darker, muted purple background */
  /* --color-primary-dark is already good for text (var(--primary-dark)) */

  --header-bg: var(--background-paper);
  --header-text: var(--text-primary);
  --header-border: var(--border-color);

  --sidebar-bg: var(--background-paper);
  --sidebar-text: var(--text-primary);
  --sidebar-icon-color: var(--neutral-medium);
  --sidebar-border: var(--border-color);
  --sidebar-nav-link-hover-bg: var(--neutral-light);
  --sidebar-nav-link-active-bg: var(--primary-main);
  --sidebar-nav-link-active-text: var(--text-on-primary-bg);
  --sidebar-nav-link-active-icon: var(--text-on-primary-bg);

  --footer-bg: var(--background-default);
  --footer-text: var(--text-secondary);
  --footer-border: var(--border-color);
  --sidebar-collapsed-width: 80px; /* Width of the sidebar when collapsed - ensure consistency */
  --background-header-table: var(--neutral-dark);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  height: 100%;
}

body {
  font-family: var(--font-family-base);
  background-color: var(--background-default);
  color: var(--text-primary);
  margin: 0;
  padding: 0;
  line-height: 1.6;
  font-size: 16px;
  transition: background-color var(--transition-speed) var(--transition-cubic), color var(--transition-speed) var(--transition-cubic);
  height: 100%;
  display: flex;
}

.app-layout {
  display: flex;
  width: 100%;
  height: 100%;
}

.sidebar {
  width: var(--sidebar-width);
  background-color: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  padding: 0; /* Remove top/bottom padding here, sidebar-header and nav-bottom will handle their padding */
  display: flex;
  flex-direction: column;
  flex-shrink: 0; /* Prevent sidebar from shrinking */
  transition: background-color var(--transition-speed) var(--transition-cubic), 
              border-color var(--transition-speed) var(--transition-cubic),
              width var(--transition-speed) var(--transition-cubic); /* Added width transition */
  position: fixed;
  top: 0;
  left: 0;
  height: 100%;
  z-index: 1001;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: flex-start; /* Logo to the left, button moved */
  padding: 0 10px 0 20px; /* Adjusted padding: top/bottom 0, right 10px for button, left 20px for logo */
  height: var(--header-height); /* Align with main header height */
  border-bottom: 1px solid var(--sidebar-border);
  /* margin-bottom: 20px; Removed as nav items have their own margin/padding now */
}

.sidebar-logo {
  display: none; /* Hide sidebar logo to avoid duplicate logo above menu */
  height: 200px;
  width: auto;
  /* Add filter for dark mode if SVG is not themeable */
}

.sidebar-nav {
  list-style: none;
  padding: 10px 0; /* Added top/bottom padding for main nav items */
  margin: 0;
}

.sidebar-nav-bottom {
  list-style: none;
  padding: 0; /* Base padding is 0 */
  margin: 0;
  margin-top: auto; /* Pushes bottom links down */
  padding-top: 20px; /* Specific top padding for spacing from border */
  border-top: 1px solid var(--sidebar-border);
}

.sidebar .nav-link {
  display: flex;
  align-items: center;
  padding: 12px 20px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95rem;
  border-radius: var(--border-radius-medium);
  margin: 4px 10px;
  transition: background-color var(--transition-speed) ease, color var(--transition-speed) ease;
}

.sidebar .nav-link .nav-icon {
  margin-right: 12px;
  width: 20px; /* For alignment */
  text-align: center;
  color: var(--sidebar-icon-color);
  transition: color var(--transition-speed) ease;
}

.sidebar .nav-link:hover {
  background-color: var(--sidebar-nav-link-hover-bg);
}

.sidebar .nav-link.active {
  background-color: var(--sidebar-nav-link-active-bg);
  color: var(--sidebar-nav-link-active-text);
}

.sidebar .nav-link.active .nav-icon {
  color: var(--sidebar-nav-link-active-icon);
}

.content-wrapper {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto; /* Allow content to scroll independently */
  min-width: 0; /* Fix for flexbox overflow issue */
  margin-left: var(--sidebar-width);
}

/* --- Tables --- */
.table-responsive {
    overflow-x: auto; /* Allows table to scroll horizontally on smaller screens */
    width: 100%;
    padding-bottom: 5px; /* Using padding instead of margin to ensure spacing */
}

header {
  position: sticky; /* Make header sticky */
  top: 0;
  z-index: 1000;
  background-color: var(--header-bg);
  color: var(--header-text);
  padding: 0 24px; /* Slimmer padding */
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between; /* To push title and button apart */
  border-bottom: 1px solid var(--header-border);
  transition: background-color var(--transition-speed) var(--transition-cubic), border-color var(--transition-speed) var(--transition-cubic);
}

header h1 {
  margin: 0;
  font-size: 1.5rem; /* Or as desired */
  font-weight: 600;
}

.topbar-logo {
  height: 28px;
  width: auto;
  margin-right: 12px;
}

.back-btn {
    background: var(--primary-main);
    color: var(--primary-contrast);
    border: none;
    padding: 8px 16px;
    border-radius: var(--border-radius-medium);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    transition: background-color var(--transition-speed) ease;
}

.back-btn:hover {
    background: var(--primary-dark);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 20px; /* Spacing between user controls group and theme toggle */
}

.user-controls {
  display: flex;
  align-items: center;
  gap: 15px; /* Spacing between notification, username, and auth link */
}

.notifications-btn {
  background: transparent;
  border: none;
  color: var(--header-text); /* Or a specific icon color */
  font-size: 1.2rem; /* Adjust as needed */
  padding: 5px;
  cursor: pointer;
  border-radius: var(--border-radius-small);
  transition: background-color var(--transition-speed) ease;
}

.notifications-btn:hover {
  background-color: var(--header-item-hover-bg); /* Ensure this variable exists or use a direct color */
}

.username {
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--header-text);
}

.auth-link {
  color: var(--header-text); /* Or accent color */
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 5px 8px;
  border-radius: var(--border-radius-small);
  transition: background-color var(--transition-speed) ease, color var(--transition-speed) ease;
}

.auth-link:hover {
  background-color: var(--header-item-hover-bg); /* Ensure this variable exists or use a direct color */
  /* color: var(--header-text-hover); */ /* Optional: if text color should change on hover */
}

#theme-toggle {
  /* position: absolute; top: 50%; transform: translateY(-50%); right: 20px; */ /* No longer needed with flex justify */
  padding: 6px 10px;
  background-color: var(--neutral-main);
  color: var(--neutral-contrast);
  border: 1px solid transparent; /* Cleaner look */
  border-radius: var(--border-radius-medium);
  cursor: pointer;
  font-family: var(--font-family-base);
  font-size: 0.8rem;
  font-weight: 500;
  transition: background-color var(--transition-speed) ease, border-color var(--transition-speed) ease, color var(--transition-speed) ease;
}

[data-theme="light"] #theme-toggle {
    background-color: var(--neutral-light);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

[data-theme="light"] #theme-toggle:hover {
    background-color: var(--border-color);
}

[data-theme="dark"] #theme-toggle {
    background-color: var(--neutral-dark);
    color: var(--neutral-contrast);
}

[data-theme="dark"] #theme-toggle:hover {
    background-color: var(--neutral-main);
}

main {
  padding: 24px; /* Consistent padding */
  flex-grow: 1; /* Allow main to fill available space */
}

footer {
  text-align: center;
  padding: 0 24px;
  height: var(--footer-height);
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--footer-bg);
  color: var(--footer-text);
  border-top: 1px solid var(--footer-border);
  font-size: 0.85rem;
  flex-shrink: 0; /* Prevent footer from shrinking */
  transition: background-color var(--transition-speed) var(--transition-cubic), border-color var(--transition-speed) var(--transition-cubic), color var(--transition-speed) var(--transition-cubic);
}

/* Sidebar Toggle Button & Collapsed Styles */

/* Styles for the new custom toggle button at the bottom */
.sidebar-toggle-btn-custom {
  background: transparent; /* Match nav-link */
  border: none; /* Match nav-link */
  color: var(--sidebar-text); /* Match nav-link */
  width: calc(100% - 20px); /* Full width like nav-links, considering margin */
  text-align: left; /* Align text/icon like nav-links */
  padding: 12px 20px; /* Match nav-link */
  font-weight: 500; /* Match nav-link */
  font-size: 0.95rem; /* Match nav-link */
  border-radius: var(--border-radius-medium); /* Match nav-link */
  margin: 4px 10px; /* Match nav-link */
  cursor: pointer;
  display: flex; /* To align icon and text */
  align-items: center;
  font-family: var(--font-family-base);
  line-height: 1.6; /* Match nav-link */
}

.sidebar-toggle-btn-custom:hover {
  background-color: var(--sidebar-nav-link-hover-bg);
}

/* Icon visibility for the new button */
.sidebar-toggle-btn-custom .nav-icon {
  margin-right: 12px;
  width: 20px;
  text-align: center;
  color: var(--sidebar-icon-color);
  transition: color var(--transition-speed) ease, margin-right var(--transition-speed) ease;
}

.sidebar-toggle-btn-custom .icon-expand {
  display: none; /* Hidden by default */
}

.sidebar-toggle-btn-custom .icon-collapse {
  display: inline-block; /* Visible by default */
}

/* Styles for the old .sidebar-toggle-btn (if any linger or were general) - can be removed if specific enough */
.sidebar-toggle-btn { /* This was the old one in the header, might not be needed now */
  background: transparent;
  border: none;
  color: var(--sidebar-icon-color);
  font-size: 1.5rem; /* Larger icon */
  padding: 5px; /* Small padding around icon */
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--border-radius-small);
  line-height: 1; /* Ensure icon is vertically centered */
}

.sidebar-toggle-btn:hover {
  background-color: var(--sidebar-nav-link-hover-bg);
  color: var(--sidebar-text);
}

.sidebar-toggle-btn .icon-expand {
  display: none; /* Hidden by default, shown when collapsed */
}

/* Collapsed Sidebar Styles */
.sidebar.collapsed {
  width: var(--sidebar-collapsed-width);
}

.sidebar.collapsed .sidebar-header {
  /* Button is no longer in header, so centering logic for it is removed */
  /* Padding might still be relevant for the logo if it were to be centered */
  padding: 0 10px 0 10px; /* Example: Minimal padding if logo were to be centered */
  justify-content: center; /* If logo should be centered when collapsed */
  height: var(--header-height); /* Maintain height */
}

.sidebar.collapsed .sidebar-logo {
  display: none;
}

/* Icon visibility for the NEW button when sidebar is collapsed */
.sidebar.collapsed .sidebar-toggle-btn-custom .icon-collapse {
  display: none;
}

.sidebar.collapsed .sidebar-toggle-btn-custom .icon-expand {
  display: inline-block; /* Show expand icon */
}

/* Hide text for the new button when collapsed */
.sidebar.collapsed .sidebar-toggle-btn-custom .nav-text {
  display: none;
}

/* Adjust new button's icon margin when collapsed */
.sidebar.collapsed .sidebar-toggle-btn-custom .nav-icon {
  margin-right: 0;
}

/* Ensure the button itself is centered or icons are centered within it */
.sidebar.collapsed .sidebar-toggle-btn-custom {
  justify-content: center; /* Center icon within the button */
}

.sidebar.collapsed .nav-link {
  justify-content: center; /* Center icon */
  padding-left: 10px;  /* Minimal padding for icon */
  padding-right: 10px; /* Minimal padding for icon */
  margin-left: 5px;
  margin-right: 5px;
}

.sidebar.collapsed .nav-link span:not(.nav-icon),
.sidebar.collapsed .nav-link .nav-text { /* Hide text, including specific .nav-text spans */
  display: none;
}

.sidebar.collapsed .nav-link .nav-icon {
  margin-right: 0; /* No margin when text is hidden */
}

/* Ensure bottom nav also behaves correctly when collapsed */
.sidebar.collapsed .sidebar-nav-bottom {
  padding-top: 10px; /* Adjust if needed */
}

.sidebar.collapsed .sidebar-nav-bottom .nav-link {
  justify-content: center; /* Center icons */
}
/* End of Sidebar Toggle Button & Collapsed Styles */

.page-title-actions {
    display: flex;
    align-items: center;
    gap: var(--space-lg);
}

/* Executive Dashboard Styles */
#executive-dashboard {
  padding: 0; /* Remove padding as main has it now */
}

/* Remove the separate h2 for executive dashboard as it's in the main header now */
/* #executive-dashboard > h2 { ... } */

.widget-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); /* Adjusted minmax */
  gap: 24px;
}

.metric-widget {
  background-color: var(--background-paper);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-large);
  padding: 20px;
  text-align: left;
  box-shadow: var(--box-shadow-sm);
  transition: transform var(--transition-speed) var(--transition-cubic), box-shadow var(--transition-speed) var(--transition-cubic);
}

.metric-widget:hover {
  transform: translateY(-3px);
  box-shadow: var(--box-shadow-md);
}

.metric-widget h3 {
  margin-top: 0;
  margin-bottom: 4px;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
}

.metric-widget .value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
  line-height: 1.2;
}

.metric-widget .change {
  font-size: 0.85rem;
  font-weight: 500;
}

.metric-widget .change.positive {
  color: var(--success-main);
}

.metric-widget .change.negative {
  color: var(--error-main);
}

/* Utility for visually hidden text */
.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;
}

/* Dashboard Specific Styles */
.dashboard-section {
  margin-bottom: 32px;
  padding: 24px;
  background-color: var(--background-paper);
  border-radius: var(--border-radius-large);
  box-shadow: var(--box-shadow-md);
}

.dashboard-section:last-child {
  margin-bottom: 0;
}

.dashboard-section h2 {
  font-size: 1.5rem; /* 24px */
  font-weight: 600;
  color: var(--text-primary);
  margin-top: 0;
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-color-light);
}

/* Specific Grid Layouts */
.kpi-overview-grid {
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); /* 5 columns on larger screens */
  gap: 20px;
}

.revenue-growth-grid {
  display: grid;
  grid-template-columns: 2fr 1fr; /* Chart takes 2/3, mini KPIs take 1/3 */
  gap: 24px;
}

.revenue-growth-grid .widget-grid {
    grid-template-columns: 1fr; /* Stack mini KPIs vertically */
}

.customer-lifecycle-grid,
.operational-health-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); /* 4 columns */
  gap: 20px;
}

.product-engagement-grid {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); /* 5 columns, slightly smaller widgets */
  gap: 16px;
}

.strategic-views-grid {
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); /* 2 columns */
  gap: 24px;
}

/* Chart Container Styles */
.chart-container {
  background-color: var(--background-default); /* Slightly different bg for contrast */
  padding: 20px;
  border-radius: var(--border-radius-medium);
  border: 1px solid var(--border-color-light);
  height: 350px; /* Default height, can be overridden */
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative; /* For placeholder text or actual chart */
}

.chart-container canvas {
  max-width: 100%;
  max-height: 100%;
}

.placeholder-text {
  color: var(--text-secondary);
  font-style: italic;
  text-align: center;
}

/* Full Width Section (for things like tables or large charts if needed) */
.full-width-section {
  grid-column: 1 / -1; /* Span all columns in its parent grid if applicable */
}

/* Adjustments for metric widgets in denser grids */
.product-engagement-grid .metric-widget .value {
  font-size: 1.75rem;
}

.product-engagement-grid .metric-widget h3 {
  font-size: 0.8rem;
}

/* Responsive adjustments */

/* Analytics Page Specific Styles */
.analytics-container {
  padding: 24px;
}

.analytics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 24px;
}

.analytics-card {
  background-color: var(--background-paper);
  border-radius: var(--border-radius-large);
  padding: 20px;
  box-shadow: var(--box-shadow-md);
  transition: all var(--transition-speed) var(--transition-cubic);
}

.analytics-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--box-shadow-lg);
}

.analytics-card h3 {
  font-size: 1.25rem; /* 20px */
  font-weight: 600;
  color: var(--text-primary);
  margin-top: 0;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color-light);
}

.analytics-card ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.analytics-card li {
  margin-bottom: 10px;
}

.analytics-card li:last-child {
  margin-bottom: 0;
}

.analytics-card a {
  color: var(--primary-main);
  text-decoration: none;
  font-weight: 500;
  transition: color var(--transition-speed) ease;
}

.analytics-card a:hover,
.analytics-card a:focus {
  color: var(--primary-dark);
  text-decoration: underline;
}

/* =================================== */
/* == Customer Page Specific Styles == */
/* =================================== */

.customer-page-container {
    display: flex;
    flex-direction: column;
    gap: 20px; /* Space between controls/table and modals */
}

.customer-controls .filters {
    display: flex;
    align-items: center; /* Vertically align items */
    gap: 10px; /* Space between filter elements */
    flex-wrap: wrap; /* Allow items to wrap on smaller screens if needed */
    width: 100%; /* Ensure it takes full available width */
}

#add-customer-btn.btn-add-customer-filter-bar {
    margin-left: auto; /* Push to the right */
    padding-top: 7px;    /* Adjust vertical padding to reduce height */
    padding-bottom: 7px; /* Adjust vertical padding to reduce height */
}

.customer-controls {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-medium); /* 16px */
    align-items: center;
    padding: var(--spacing-medium); /* Matches card padding */
    /* background-color: var(--background-card); Already a card */
    /* border-radius: var(--border-radius-lg); Already a card */
    /* box-shadow: var(--box-shadow-sm); Already a card */
}

.customer-controls input[type="search"] {
    flex-grow: 1;
    min-width: 230px; /* Increased minimum width by 50px */
    max-width: 350px; /* Increased maximum width by 50px */
    padding: var(--input-padding-y, 0.5rem) var(--input-padding-x, 0.75rem);
    border: 1px solid var(--primary-light); /* Purple border to match button */
    border-radius: var(--border-radius-sm); /* Match button border radius */
    font-size: var(--font-size-base);
    background-color: var(--background-input, var(--background-light)); /* Fallback if --background-input not defined */
    color: var(--text-primary);
    line-height: var(--line-height-base);
    height: 38px; /* Explicit height */
    box-sizing: border-box; /* Include padding and border in height */
}

.customer-controls .filters {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-small); /* 8px */
    align-items: center;
}

.customer-controls select {
    padding: var(--input-padding-y, 0.5rem) var(--input-padding-x, 0.75rem);
    border: 1px solid var(--primary-light); /* Purple border to match button */
    border-radius: var(--border-radius-sm); /* Match button border radius */
    background-color: transparent; /* Transparent background */
    color: var(--primary-main, #6200ea); /* Purple text */
    font-size: var(--font-size-base);
    min-width: 150px;
    line-height: var(--line-height-base);
    height: 38px; /* Match search input height */
    box-sizing: border-box; /* Include padding and border in height */
    appearance: none; /* Remove default styling */
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg fill='%236200ea' height='24' viewBox='0 0 24 24' width='24' xmlns='http://www.w3.org/2000/svg'><path d='M7 10l5 5 5-5z'/></svg>");
    background-repeat: no-repeat;
    background-position: right 8px center;
    padding-right: 30px; /* Space for the arrow */
}

/* Style for dropdown options */
.customer-controls select option {
    background-color: var(--background-dark, #1a1a1a) !important; /* Dark background */
    color: #ffffff !important; /* White text */
    padding: 8px 12px;
}

/* Transaction Page Filter Styles */
.filters-container .form-control { /* General for text inputs in transactions filters */
    padding: 0.65rem 0.85rem;
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--text-primary);
    background-color: var(--background-input, var(--background-default)); /* Using themed input background */
    border: 1px solid var(--primary-light);
    border-radius: var(--border-radius-sm);
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.filters-container .form-control:focus {
    border-color: var(--primary-main);
    outline: 0;
    box-shadow: 0 0 0 2px var(--primary-light); /* Consistent focus style */
}

.filters-container select.form-control {
    background-color: transparent; /* Key for themed select */
    color: var(--primary-main); /* Themed text color */
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e"); /* Custom arrow matching --primary-main */
    background-repeat: no-repeat;
    background-position: right var(--input-padding-x, 0.75rem) center;
    padding-right: calc(var(--input-padding-x, 0.75rem) + 20px + 5px); /* Adjusted padding for arrow */
}

/* Styling for the options within the select dropdown */
.filters-container select.form-control option {
    background-color: var(--background-paper, #2c2c2c); /* Themed background for options */
    color: var(--text-primary, #ffffff); /* Themed text for options */
}

/* Style for selected/highlighted option */
.customer-controls select option:checked,
.customer-controls select option:hover,
.customer-controls select option:focus,
.customer-controls select option:active,
.customer-controls select option[selected] {
    background-color: var(--primary-main, #6200ea) !important; /* Purple highlight */
    color: #ffffff !important;
    box-shadow: 0 0 10px 100px var(--primary-main, #6200ea) inset !important;
    -webkit-text-fill-color: #ffffff !important;
}

/* Style for the highlighted item in the dropdown */
.customer-controls select option::-moz-focus-inner {
    background-color: var(--primary-main, #6200ea) !important;
}

/* Add any additional global styles or utility classes here */

/* KB Article Modal Styles */
.modal {
    display: none; /* Hidden by default */
    position: fixed; /* Stay in place */
    z-index: 1050; /* Sit on top */
    left: 0;
    top: 0;
    width: 100%; /* Full width */
    height: 100%; /* Full height */
    overflow: auto; /* Enable scroll if needed */
    background-color: rgba(0,0,0,0.5); /* Black w/ opacity for overlay */
    padding-top: 60px; /* Location of the box */
}

.modal-content.card {
    background-color: var(--background-paper);
    margin: auto;
    padding: 0; /* Reset card padding, handle with modal-header/body/footer */
    border: 1px solid var(--border-color-soft);
    border-radius: var(--border-radius-medium);
    width: 80%;
    max-width: 700px; /* Max width */
    box-shadow: var(--box-shadow-lg);
    animation: fadeInModal 0.3s ease-out;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color-soft);
    background-color: var(--background-color-secondary); /* Subtle header background */
    border-top-left-radius: var(--border-radius-medium);
    border-top-right-radius: var(--border-radius-medium);
}

.modal-title {
    margin-bottom: 0;
    font-size: 1.25rem;
    color: var(--text-color-primary);
}

.modal-body {
    padding: 1.5rem;
    color: var(--text-color-primary-muted);
    line-height: 1.6;
}
.modal-body h6 { /* For subheadings within modal content */
    font-size: 1rem;
    color: var(--text-color-primary);
    margin-top: 1rem;
    margin-bottom: 0.5rem;
}
.modal-body p {
    margin-bottom: 1rem;
}
.modal-body ul, .modal-body ol {
    margin-bottom: 1rem;
    padding-left: 1.5rem;
}


.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color-soft);
    text-align: right;
    background-color: var(--background-color-secondary);
    border-bottom-left-radius: var(--border-radius-medium);
    border-bottom-right-radius: var(--border-radius-medium);
}

.btn-close { /* General close button style */
    background: transparent;
    border: 0;
    font-size: 1.5rem;
    font-weight: bold;
    line-height: 1;
    color: var(--text-color-secondary);
    text-shadow: 0 1px 0 var(--background-paper); /* Ensure visibility on varied backgrounds */
    opacity: 0.7;
    padding: 0.5rem; /* Easier to click */
    margin: -0.5rem; /* Offset padding */
}
.btn-close:hover {
    color: var(--text-color-primary);
    opacity: 1;
}

@keyframes fadeInModal {
    from {opacity: 0; transform: translateY(-20px);}
    to {opacity: 1; transform: translateY(0);}
}

/* --- Help & Support Page Styles --- */

/* General card style for help sections (if not already globally defined for .card) */
.help-section.card {
    margin-bottom: 25px; /* Increased spacing between KB and Tickets sections */
    /* Ensure your .card class has basic styling like background, border, radius, shadow */
}

/* Styling for individual ticket items */
.ticket-item.card {
    background-color: var(--background-color-secondary); /* Use secondary for cards within sections */
    border: 1px solid var(--border-color-soft);
    border-radius: var(--border-radius-md);
    padding: 15px 20px; /* More horizontal padding */
    margin-bottom: 15px; /* Spacing between ticket cards if in a single column */
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s ease-in-out, transform 0.2s ease-in-out;
}

.ticket-item.card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.ticket-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start; /* Align items to start for potentially multi-line titles */
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color-extralight);
}

.ticket-title {
    font-size: 1.15rem; /* Slightly larger title */
    font-weight: 600;
    color: var(--text-color-primary);
    margin: 0;
    margin-right: 10px; /* Space between title and status */
}

.ticket-status {
    padding: 5px 12px; /* More padding for a pill/badge look */
    border-radius: var(--border-radius-pill, 15px); /* Fallback if variable not set */
    font-size: 0.75rem; /* Smaller font for status badge */
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap; /* Prevent status from wrapping */
    line-height: 1.2;
}

/* Status-specific styles */
.ticket-status.status-open {
    background-color: var(--color-warning-soft, #fff3cd);
    color: var(--color-warning-dark, #665100);
    border: 1px solid var(--color-warning, #ffeeba);
}

.ticket-status.status-pending-review {
    background-color: var(--color-info-soft, #d1ecf1);
    color: var(--color-info-dark, #084298);
    border: 1px solid var(--color-info, #bee5eb);
}

.ticket-status.status-in-progress {
    background-color: var(--color-primary-soft, #cfe2ff);
    color: var(--color-primary-dark, #07408C);
    border: 1px solid var(--color-primary, #b6d4fe);
}

.ticket-status.status-resolved,
.ticket-status.status-closed {
    background-color: var(--color-success-soft, #d1e7dd);
    color: var(--color-success-dark, #0a3622);
    border: 1px solid var(--color-success, #badbcc);
}

.ticket-item-meta {
    font-size: 0.8rem;
    color: var(--text-color-secondary);
    margin-bottom: 10px;
    display: flex;
    flex-wrap: wrap; /* Allow meta items to wrap on small screens */
    gap: 5px 15px; /* Row and column gap */
}

.ticket-item-meta span .ticket-id,
.ticket-item-meta span .ticket-date {
    font-weight: 500;
    color: var(--text-color-primary-muted);
}

.ticket-item-body {
    font-size: 0.9rem;
    color: var(--text-color-primary-muted);
    line-height: 1.6;
    margin-bottom: 15px;
    padding-top: 5px; /* Small space above description */
}

.ticket-item-actions {
    text-align: right;
    margin-top: 10px; /* Space above action buttons */
}

/* Grid layout for tickets and KB articles */
/* This will make cards appear in columns if space allows */
.tickets-grid, .articles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); /* Responsive grid, min 320px or 100% */
    gap: 20px;
}

/* Ensure sections take full width if grid is not desired, or for single column fallback */
#knowledge-base .card-body > ul, /* If using UL for KB */
#knowledge-base .card-body > p, /* For initial messages in KB */
#support-tickets .card-body > p { /* For initial messages in Tickets */
    grid-column: 1 / -1; /* Make sure these span full width if inside a grid parent */
}

/* Styling for Knowledge Base Article Cards */
.kb-article-card.card {
    background-color: var(--background-color-secondary);
    border: 1px solid var(--border-color-soft);
    border-radius: var(--border-radius-md);
    padding: 0; /* Remove padding from card itself, apply to card-body */
    display: flex; /* Allow card-body to grow */
    flex-direction: column;
    transition: box-shadow 0.2s ease-in-out, transform 0.2s ease-in-out;
    box-shadow: var(--shadow-sm);
}

.kb-article-card.card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.kb-article-card .card-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    flex-grow: 1; /* Make card body take available space */
}

.kb-article-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-color-primary);
    margin-top: 0;
    margin-bottom: 10px;
}

.kb-article-title a {
    text-decoration: none;
    color: inherit;
}

.kb-article-title a:hover {
    color: var(--primary-main);
    text-decoration: underline;
}

.kb-article-summary {
    font-size: 0.875rem;
    color: var(--text-color-primary-muted);
    line-height: 1.5;
    margin-bottom: 15px;
    flex-grow: 1; /* Allow summary to take available space before button */
}

.kb-read-more.btn {
    margin-top: auto; /* Push button to the bottom of the card */
    align-self: flex-start; /* Align button to the left */
}

/* --- Global Form Styles --- */
.form-input,
.form-select {
    padding: 0.65rem 0.85rem;
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--text-primary);
    background-color: var(--background-paper);
    background-clip: padding-box;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-medium);
    transition: border-color var(--transition-speed) ease-in-out, box-shadow var(--transition-speed) ease-in-out;
    width: 100%; 
    box-sizing: border-box;
}

.form-input:focus,
.form-select:focus {
    color: var(--text-primary);
    background-color: var(--background-paper);
    border-color: var(--primary-main);
    outline: 0;
    box-shadow: 0 0 0 0.2rem rgba(127, 86, 217, 0.25);
}

.form-input::placeholder {
    color: var(--text-secondary);
    opacity: 1;
}

.form-select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.85rem center;
    background-size: 16px 12px;
    padding-right: 2.5rem;
}

[data-theme="dark"] .form-select {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23adb5bd' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
}

.form-select option {
    background-color: var(--background-paper);
    color: var(--text-primary);
}
/* End Global Form Styles */

/* --- Knowledge Upload Modal Tab Content --- */
.upload-content {
    display: none; /* Hide all content panes by default */
}

.upload-content.active {
    display: block; /* Show only the active content pane */
}

/* API Integration Section Styling */
.api-integration-section h3 {
    margin-bottom: 20px;
    color: var(--text-primary);
    font-size: 1.2rem;
}

.api-sources {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.api-source {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px;
    background-color: var(--background-paper);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-medium);
    transition: all var(--transition-speed) ease;
}

.api-source:hover {
    background-color: var(--neutral-dark);
    border-color: var(--primary-main);
}

.api-source i {
    font-size: 1.5rem;
    margin-right: 12px;
    color: var(--primary-main);
}

.api-source span {
    flex-grow: 1;
    font-weight: 500;
    color: var(--text-primary);
}

.api-source .btn-connect {
    padding: 6px 12px;
    font-size: 0.85rem;
    background-color: var(--primary-main);
    color: var(--primary-contrast);
    border: none;
    border-radius: var(--border-radius-small);
    cursor: pointer;
    transition: background-color var(--transition-speed) ease;
}

.api-source .btn-connect:hover {
    background-color: var(--primary-dark);
}

/* --- Settings Page Specific Styles --- */
.settings-section {
    margin-bottom: var(--space-lg);
}

.settings-section.card {
    background-color: var(--background-paper);
    border-radius: var(--border-radius-md);
    box-shadow: var(--shadow-dp2);
    overflow: hidden;
}

.settings-section .card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-md);
    border-bottom: 1px solid var(--neutral-medium-dark);
    background-color: var(--background-paper);
}

.settings-section .card-header h2 {
    margin: 0;
    font-size: var(--font-size-xl);
    color: var(--text-primary-high);
}

#add-employee-btn {
    margin-bottom: 5px;
}

.settings-section .card-body {
    padding: var(--space-md);
}

.table-responsive {
    overflow-x: auto;
}

#employees-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: var(--space-md);
}

/* #employees-table th,
#employees-table td {
    padding: var(--space-sm) var(--space-md);
    text-align: left;
    border-bottom: 1px solid var(--neutral-medium-dark);
    vertical-align: middle;
}

#employees-table th {
    background-color: var(--neutral-dark);
    color: var(--text-primary-medium);
    font-weight: var(--font-weight-semibold);
}

#employees-table tbody tr:hover {
    background-color: var(--neutral-medium-dark);
} */

#employees-table .btn-icon {
    background: transparent;
    border: none;
    color: var(--text-primary-medium);
    cursor: pointer;
    padding: var(--space-xs);
    margin-right: var(--space-xs);
}

#employees-table .btn-icon:hover {
    color: var(--primary-main);
}

#employees-table .btn-icon .icon {
    font-size: var(--font-size-lg);
}

.badge {
    display: inline-block;
    padding: 4px 8px; /* Match .btn-action in table */
    font-size: 0.85rem; /* Match .btn-action in table */
    font-weight: 500; /* Match .btn-action */
    line-height: 1.5; /* Match .btn-action */
    text-align: center;
    text-decoration: none;
    vertical-align: middle;
    cursor: default; /* Badges are not typically interactive like buttons */
    border: 1px solid var(--primary-light);
    border-radius: var(--border-radius-sm);
    text-transform: capitalize;
    background-color: transparent;
    color: var(--primary-main);
    transition: background-color var(--transition-speed) ease, color var(--transition-speed) ease;
}

/* Assuming .status-badge, .status-active, .status-inactive are globally styled or add them here if not */
.status-badge.status-inactive {
    background-color: var(--neutral-medium);
    color: var(--text-primary-high);
}


.modal {
    display: none;
    position: fixed;
    z-index: 1050;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.6);
}

.modal-dialog {
    position: relative;
    margin: 10% auto;
    max-width: 600px;
    pointer-events: none;
}

.modal-content {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    pointer-events: auto;
    background-color: var(--neutral-dark);
    background-clip: padding-box;
    border: 1px solid var(--neutral-medium-dark);
    border-radius: var(--border-radius-lg);
    outline: 0;
    box-shadow: var(--shadow-dp6);
}

.modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: var(--space-md);
    border-bottom: 1px solid var(--neutral-medium-dark);
    border-top-left-radius: var(--border-radius-lg);
    border-top-right-radius: var(--border-radius-lg);
    background-color: var(--neutral-darker);
}

.modal-header .modal-title {
    margin-bottom: 0;
    line-height: 1.5;
    font-size: var(--font-size-xl);
    color: var(--text-primary-high);
}

#permissions-fieldset {
    margin-top: var(--space-lg);
    padding: var(--space-md);
    border: 1px solid var(--neutral-medium-dark);
    border-radius: var(--border-radius-sm);
}

#permissions-fieldset legend {
    padding: 0 var(--space-sm);
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-medium);
    color: var(--text-primary-high);
    width: auto;
    margin-bottom: var(--space-sm);
}

#permissions-container .form-check {
    margin-bottom: var(--space-xs);
}
#permissions-container .form-check-input {
    margin-right: var(--space-sm);
    vertical-align: middle;
}
#permissions-container .form-check-label {
    vertical-align: middle;
}

/* Ensure buttons are styled (re-affirming from general button styles if needed) */
.btn.btn-primary {
    background-color: var(--primary-main);
    color: var(--text-on-primary);
    border-color: var(--primary-main);
}
.btn.btn-primary:hover {
    background-color: var(--primary-dark);
    border-color: var(--primary-dark);
}
.btn.btn-secondary {
    background-color: var(--neutral-medium);
    color: var(--text-primary-high);
    border-color: var(--neutral-medium);
}
.btn.btn-secondary:hover {
    background-color: var(--neutral-medium-dark);
    border-color: var(--neutral-medium-dark);
}

/* --- Knowledge Base Controls --- */
.knowledge-base-controls {
    display: flex;
    align-items: center;
    margin-bottom: 20px; /* Space between controls and article cards */
}

.knowledge-base-controls #kb-search {
    flex-grow: 1; /* Search input takes available space */
    padding: 0.5rem 0.75rem; /* Consistent padding */
    border-radius: var(--border-radius-medium, 8px); /* Consistent border radius */
    border: 1px solid var(--border-color); /* Default border for light mode */
    /* height: 38px; Explicit height - consider if button height is also explicit */
    box-sizing: border-box;
    font-size: 0.9rem; /* Match typical input font size */
}

.knowledge-base-controls #showCreateArticleModalBtn {
    margin-left: 15px; /* Spacing between search and button */
    white-space: nowrap; /* Prevent button text from wrapping */
}

[data-theme="dark"] .knowledge-base-controls #kb-search {
    background-color: var(--background-paper, #14151A); /* Darker background to match customer search */
    color: var(--text-primary, #E0E7FF);
    border: 1px solid var(--neutral-dark, #2D3748); /* Subtle border, lighter than background */
}

[data-theme="dark"] .knowledge-base-controls #kb-search::placeholder {
    color: var(--text-secondary, #A0ABC0);
}

/* Style for textareas in create article modal */
#createArticleModal textarea.form-control {
    min-height: 100px; /* Ensure a decent minimum height for summary */
}

#createArticleModal #newArticleContent {
    min-height: 200px; /* Larger area for full content editor */
}

/* --- Global Button Styles --- */
.btn {
    display: inline-block;
    font-weight: 500;
    line-height: 1.5;
    color: var(--text-primary);
    text-align: center;
    text-decoration: none;
    vertical-align: middle;
    cursor: pointer;
    user-select: none;
    background-color: var(--neutral-light);
    border: 1px solid var(--neutral-light);
    padding: 0.65rem 1.25rem;
    font-size: 0.95rem;
    border-radius: var(--border-radius-medium);
    transition: color var(--transition-speed) ease-in-out,
                background-color var(--transition-speed) ease-in-out,
                border-color var(--transition-speed) ease-in-out,
                box-shadow var(--transition-speed) ease-in-out;
}

.btn:hover {
    background-color: var(--neutral-medium);
    border-color: var(--neutral-medium);
    color: var(--text-primary);
}

.btn:focus, .btn.focus {
    outline: 0;
    box-shadow: 0 0 0 0.2rem rgba(107, 114, 128, 0.5);
}

.btn.disabled, .btn:disabled {
    opacity: 0.65;
    pointer-events: none;
}

/* Primary Button */
.btn-primary {
    color: var(--primary-contrast);
    background-color: var(--primary-main);
    border-color: var(--primary-main);
}

.btn-primary:hover {
    color: var(--primary-contrast);
    background-color: var(--primary-dark);
    border-color: var(--primary-dark);
}

.btn-primary:focus, .btn-primary.focus {
    color: var(--primary-contrast);
    background-color: var(--primary-dark);
    border-color: var(--primary-dark);
    box-shadow: 0 0 0 0.2rem rgba(127, 86, 217, 0.5);
}

/* Success Button */
.btn-success {
    color: var(--secondary-contrast);
    background-color: var(--success-main);
    border-color: var(--success-main);
}

.btn-success:hover {
    color: var(--secondary-contrast);
    background-color: var(--secondary-dark);
    border-color: var(--secondary-dark);
}

.btn-success:focus, .btn-success.focus {
    color: var(--secondary-contrast);
    background-color: var(--secondary-dark);
    border-color: var(--secondary-dark);
    box-shadow: 0 0 0 0.2rem rgba(16, 185, 129, 0.5);
}
/* End Global Button Styles */

/* --- Modal Styles --- */
.modal {
    display: none; /* Hidden by default */
    position: fixed; /* Stay in place */
    z-index: 1000; /* Sit on top */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto; /* Enable scroll if needed */
    background-color: rgba(0,0,0,0.6); /* Black w/ opacity for overlay */
    align-items: center; /* Vertical centering */
    justify-content: center;
}

/* Show the modal when it has the 'show' class */
.modal.show {
    display: flex !important; /* Use flex for centering content */
}

.modal-content {
    background-color: var(--background-paper);
    color: var(--text-primary);
    margin: auto; /* Handles centering for older browsers if flex not fully supported */
    padding: 25px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-large);
    width: 90%;
    max-width: 550px; /* Max width of modal */
    box-shadow: var(--box-shadow-lg);
    position: relative;
    animation: fadeInModal 0.3s var(--transition-cubic);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color-light);
    margin-bottom: 20px;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
    color: var(--text-primary);
}

.modal-close {
    color: var(--text-secondary);
    font-size: 28px;
    font-weight: bold;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.modal-close:hover,
.modal-close:focus {
    color: var(--text-primary);
    text-decoration: none;
}

.modal-body {
    padding-bottom: 20px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding-top: 20px;
    border-top: 1px solid #e5e7eb;
}

.modal-footer .btn {
    margin-left: 10px;
}

/* Form elements within modal */
.modal .form-group {
    margin-bottom: 15px;
}

/* Payment Method Styles */
.payment-method-container {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 10px;
    background: #f9fafb;
    border-radius: 6px;
}

.payment-method-container .text-muted {
    flex: 1;
    color: #6b7280;
}

.card-input-wrapper {
    position: relative;
}

.card-icons {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    gap: 5px;
}

.card-icons img {
    height: 20px;
    width: auto;
}

.form-row {
    display: flex;
    gap: 15px;
}

.form-row .form-group {
    flex: 1;
}

.col-6 {
    flex: 1;
}

.modal .form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-secondary);
}

.modal .form-control,
.modal .form-select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-medium);
    background-color: var(--background-default); /* Slightly different from paper for contrast */
    color: var(--text-primary);
    font-size: 1rem;
    transition: border-color var(--transition-speed) ease-in-out, box-shadow var(--transition-speed) ease-in-out;
}

.modal .form-control:focus,
.modal .form-select:focus {
    border-color: var(--primary-main);
    outline: 0;
    /* For the box-shadow to work with var(--primary-main) which is a hex, we'd need its RGB components. */
    /* Example: box-shadow: 0 0 0 0.2rem rgba(127, 86, 217, 0.25); if --primary-main is #7F56D9 */
    /* Or use a solid border: box-shadow: 0 0 0 3px var(--primary-light); */
    box-shadow: 0 0 0 2px var(--primary-light); /* Simpler focus shadow */
}

/* Keyframe animation for modal appearance */

/* --- Button action styles */
.btn-action {
    display: inline-block;
    padding: 5px 10px; /* Smaller padding for table buttons */
    margin-right: 5px; /* Space between buttons */
    font-size: 0.875em; /* Slightly smaller font */
    font-weight: 500;
    line-height: 1.5;
    text-align: center;
    text-decoration: none;
    vertical-align: middle;
    cursor: pointer;
    border: 1px solid transparent;
    border-radius: var(--border-radius-small);
    transition: all var(--transition-speed) var(--transition-cubic);
    background-color: transparent; /* Default transparent background */
    color: var(--primary-main); /* Use primary color for text by default */
}

.btn-action:last-child {
    margin-right: 0; /* No margin for the last button in a group */
}

.btn-action:hover {
    text-decoration: none;
    opacity: 0.8;
}

/* Specific styles for different action types */
.btn-action.btn-view-sub {
    color: var(--info-main);
    border-color: var(--info-main);
}
.btn-action.btn-view-sub:hover {
    background-color: var(--info-main);
    color: var(--primary-contrast);
}

.btn-action.btn-edit-sub {
    color: var(--primary-main); /* Or --warning-main if preferred for edit */
    border-color: var(--primary-main);
}
.btn-action.btn-edit-sub:hover {
    background-color: var(--primary-main);
    color: var(--primary-contrast);
}

.btn-action.btn-cancel-sub {
    color: var(--error-main);
    border-color: var(--error-main);
}
.btn-action.btn-cancel-sub:hover {
    background-color: var(--error-main);
    color: var(--primary-contrast);
}

/* --- Page Controls & Filters --- */
.page-title-actions {
    display: flex;
    /* justify-content: space-between; Removed as button is no longer here */
    align-items: center;
    margin-bottom: 20px; /* Space below the title/actions row */
}

.page-controls {
    display: flex;
    justify-content: space-between; /* Pushes filters to left, New Sub button to right */
    align-items: baseline; /* Changed from center to baseline for better button alignment */
    margin-bottom: 20px;
    flex-wrap: wrap; /* Allow wrapping on smaller screens */
    gap: 15px; /* Add spacing between filter group and New Plan button */
}

.filters-container {
    display: flex;
    align-items: center; /* Ensure all children are vertically centered */
    gap: 10px; /* Spacing between filter elements */
    flex-grow: 1; /* Allows filter container to take available space */
    flex-wrap: wrap; /* Allow filter elements to wrap */
}

.filters-container .form-input,
.filters-container .form-select {
    width: auto; /* Override global width: 100% */
    flex: 1 1 180px; /* Grow, Shrink, Basis. Adjusted basis for a slightly larger default. */
}

.filters-container #search-subscriptions { /* This is a .form-input */
    /* width: auto; is inherited */
    flex: 2 1 240px; /* Grow more, larger basis */
}

.filters-container .btn { /* For 'Apply Filters' button */
    flex: 0 0 auto; /* Don't grow, don't shrink, take content width */
    /* align-self: center; Removed as parent .filters-container now handles this */
}

/* Adjustments for specific filter elements if needed */
/* e.g., .filters-container .btn { margin-top: auto; } if they wrap and alignment is off */

/* Ensure buttons in page-controls have some breathing room if they wrap */
.page-controls > .btn {
    margin-top: 5px; /* Add some top margin if it wraps below filters */
}

/* --- Pagination Controls --- */
.pagination-controls {
    display: flex;
    justify-content: center; /* Center pagination by default */
    align-items: center;
    margin-top: 5px !important;
    padding: 10px 0;
}

/* Pagination buttons use the standard .btn styling */

.pagination-controls span { /* Targeting #page-info-subscriptions */
    font-size: 0.95em;
    color: var(--text-secondary);
    margin-left: 5px;
    margin-right: 5px;
}

/* If you want to align pagination to the right: */
/*
.pagination-controls {
    justify-content: flex-end;
}
*/

@keyframes fadeInModal {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.customer-controls select:focus option:checked {
    background: var(--primary-main, #6200ea) !important;
    background-color: var(--primary-main, #6200ea) !important;
    color: #ffffff !important;
}

/* Additional styling for webkit browsers */
.customer-controls select:focus option:checked {
    background: var(--primary-main, #6200ea) !important;
    background-color: var(--primary-main, #6200ea) !important;
    color: #ffffff !important;
}

/* Remove focus outline and add custom focus style */
.customer-controls select:focus {
    outline: none;
    box-shadow: 0 0 0 2px var(--primary-light);
}

/* Style for Apply Filters button to match action buttons */
#apply-filters-btn {
    height: 38px; /* Match search input and select height */
    box-sizing: border-box;
    padding: 0 20px; /* Fixed pixel value for more precise control */
    font-size: var(--font-size-base);
    text-decoration: none;
    color: var(--primary-main);
    border: 1px solid var(--primary-light);
    border-radius: var(--border-radius-sm);
    background-color: var(--background-light);
    transition: background-color var(--transition-speed) ease, color var(--transition-speed) ease;
    cursor: pointer;
}

#apply-filters-btn:hover {
    background-color: var(--primary-light);
    color: var(--text-on-primary);
}

/* General Data Table Styles (re-using .data-table from potential global styles) */
/* .customer-table-container is already a .card */

.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 0; /* Card provides padding */
    font-size: 0.9rem; /* 14.4px */
}

.data-table th,
.data-table td {
    padding: var(--spacing-s-medium, 12px); /* 12px */
    text-align: left;
    border-bottom: 1px solid var(--border-color-light);
    vertical-align: middle;
}

.data-table th {
    background-color: var(--background-header-table, var(--background-medium)); /* Fallback */
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.8rem; /* 12.8px */
    letter-spacing: 0.05em;
}


.data-table td.actions-cell {
    white-space: nowrap; /* Prevent buttons from wrapping */
}

.data-table tbody tr:hover {
    background-color: var(--background-row-hover, var(--background-hover)); /* Fallback */
}

/* Status Badges */
.data-table .status-active,
.data-table .status-trial,
.data-table .status-canceled,
.data-table .status-past-due,
.data-table .status-lead {
    padding: 5px 10px;
    border-radius: var(--border-radius-pill, 15px); /* Pill shape */
    font-size: 0.75rem; /* 12px */
    font-weight: 600;
    text-transform: capitalize; /* So "Active" not "ACTIVE" */
    letter-spacing: 0.5px;
    display: inline-block;
    text-align: center;
    min-width: 80px;
    line-height: 1.2;
}

.data-table .status-active {
    background-color: var(--success-bg, #d1e7dd); /* Bootstrap-like names */
    color: var(--success-text, #0a3622);
}

.data-table .status-trial {
    background-color: var(--info-bg, #cff4fc);
    color: var(--info-text, #055160);
}

.data-table .status-canceled {
    background-color: var(--danger-bg, #f8d7da);
    color: var(--danger-text, #58151c);
}

.data-table .status-past-due {
    background-color: var(--warning-bg, #fff3cd);
    color: var(--warning-text, #664d03);
}

.data-table .status-lead {
    background-color: var(--secondary-bg, #e2e3e5); /* Using secondary for lead */
    color: var(--secondary-text, #41464b);
}


/* Subscription Table Action Buttons - FORCE TRANSPARENT */
.subscriptions-table button.action-btn,
#subscriptions-table-body button.action-btn {
    display: inline-block !important;
    font-size: 0.85rem !important;
    padding: 4px 8px !important;
    margin-right: 4px !important;
    text-decoration: none !important;
    border-radius: 4px !important;
    transition: all 0.2s ease !important;
    background: transparent !important;
    background-color: transparent !important;
    background-image: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
    cursor: pointer !important;
    font-family: inherit !important;
    box-shadow: none !important;
}

.subscriptions-table button.action-btn.edit-btn,
#subscriptions-table-body button.action-btn.edit-btn {
    color: var(--primary-main) !important;
    border: 1px solid var(--primary-light) !important;
}

.subscriptions-table button.action-btn.sell-btn,
#subscriptions-table-body button.action-btn.sell-btn {
    color: var(--secondary-main) !important;
    border: 1px solid var(--secondary-main) !important;
}

.subscriptions-table button.action-btn.delete-btn,
#subscriptions-table-body button.action-btn.delete-btn {
    color: var(--error-main) !important;
    border: 1px solid var(--error-main) !important;
}

.subscriptions-table button.action-btn:hover,
#subscriptions-table-body button.action-btn:hover {
    color: white !important;
}

.subscriptions-table button.action-btn.edit-btn:hover,
#subscriptions-table-body button.action-btn.edit-btn:hover {
    background-color: var(--primary-main) !important;
    border-color: var(--primary-main) !important;
}

.subscriptions-table button.action-btn.sell-btn:hover,
#subscriptions-table-body button.action-btn.sell-btn:hover {
    background-color: var(--secondary-main) !important;
    border-color: var(--secondary-main) !important;
}

.subscriptions-table button.action-btn.delete-btn:hover,
#subscriptions-table-body button.action-btn.delete-btn:hover {
    background-color: var(--error-main) !important;
    border-color: var(--error-main) !important;
}

/* Pagination Controls */
.pagination-controls {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: var(--spacing-medium) var(--spacing-medium) 0; /* Padding inside card */
    gap: var(--spacing-large); /* Further increased gap for better spacing */
    margin-top: var(--spacing-medium); /* Space between table and pagination */
}

.pagination-controls span {
    font-size: 0.9rem; /* ~14.4px */
    color: var(--text-secondary);
    padding: 0 var(--spacing-medium); /* Add horizontal padding */
}

.pagination-controls .btn { /* Assuming .btn is already styled */
    padding: 0.375rem 0.75rem; /* Standard button padding */
}

.pagination-controls .btn-action {
    font-size: 0.85rem;
    padding: 4px 8px;
    margin: 5px;
    text-decoration: none;
    color: var(--primary-main);
    border: 1px solid var(--primary-light);
    border-radius: var(--border-radius-sm);
    background-color: var(--background-light);
    transition: background-color var(--transition-speed) ease, color var(--transition-speed) ease;
}

.pagination-controls .btn-action:hover {
    background-color: var(--primary-light);
    color: var(--text-on-primary);
}

/* Styling for disabled pagination buttons */
.pagination-controls .btn-disabled,
.pagination-controls .btn-disabled:hover {
    opacity: 0.5;
    cursor: not-allowed;
    background-color: var(--background-light);
    color: var(--text-secondary);
    border-color: var(--border-color-light);
}

@media (max-width: 1200px) {
  .kpi-overview-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); /* More flexible on medium screens */
  }
  .revenue-growth-grid {
    grid-template-columns: 1fr; /* Stack chart and mini KPIs */
  }
  .revenue-growth-grid .widget-grid {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); /* Mini KPIs side-by-side if space */
  }
}

@media (max-width: 992px) {
  .customer-lifecycle-grid,
  .operational-health-grid {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); /* 2 columns */
  }
  .product-engagement-grid {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  }
}

@media (max-width: 768px) {
  .dashboard-section {
    padding: 16px;
  }
  .dashboard-section h2 {
    font-size: 1.25rem;
  }
  .widget-grid,
  .kpi-overview-grid,
  .customer-lifecycle-grid,
  .operational-health-grid,
  .product-engagement-grid,
  .strategic-views-grid {
    grid-template-columns: 1fr; /* Single column for widgets on small screens */
    gap: 16px;
  }
  .metric-widget {
    padding: 16px;
  }
  .metric-widget .value {
    font-size: 1.8rem;
  }
  .chart-container {
    height: 300px;
  }
}

@media (max-width: 576px) {
  .metric-widget .value {
    font-size: 1.6rem;
  }
  .metric-widget h3 {
    font-size: 0.75rem;
  }
  .chart-container {
    height: 250px;
  }
}

/* Responsive adjustments for agent grid */
@media (max-width: 1400px) {
    .agent-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 1024px) {
    .agent-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 640px) {
    .agent-grid {
        grid-template-columns: 1fr;
    }
}

/* ==========================================================================
   Billing Page Specific Styles
   ========================================================================== */

/* Customer Payment Methods Section */
.theme-card .card-header {
    background-color: var(--background-paper); /* Ensure the header matches the dark theme */
    border-color: var(--border-color);
    color: var(--text-primary);
}

/* Customer Payment Methods Search Input */
.search-container {
    position: relative; /* Ensure this is the positioning context */
    padding: 0;
    margin: 0;
}

.customer-search-input {
    width: 100%;
    padding: 15px 20px;
    background-color: #14151A; /* Dark background matching the customers page */
    color: var(--text-primary);
    border: none;
    border-radius: 0;
    font-size: 1rem;
    margin: 0;
    display: block;
}

.customer-search-input::placeholder {
    color: #6c757d;
    font-style: normal;
}

.customer-search-input:focus {
    background-color: #14151A;
    color: var(--text-primary);
    outline: none;
    border: none;
    box-shadow: none;
}

.clear-search-icon {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 1.2rem;
    font-weight: bold;
    line-height: 1;
}

.clear-search-icon:hover {
    color: var(--text-primary);
}

/* Customer Payment Methods Table */
#customer-payment-methods-table {
    margin-top: 1rem; /* Space between description and table */
}

/* Styling for Stripe Card Element Placeholder in Modal */
.stripe-card-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 40px; /* Match typical input height */
    color: var(--text-secondary);
    font-style: italic;
    font-size: 0.9rem;
    text-align: center;
    border: 1px dashed var(--border-color); /* Dashed border to indicate placeholder */
    background-color: rgba(var(--background-paper-rgb), 0.5); /* Slightly different background */
}

/* Hide empty table when no customer is selected */
#customer-payment-methods-tbody:empty {
    display: none;
}

/* Hide table header when tbody is empty */
#customer-payment-methods-tbody:empty ~ thead,
thead:has(+ #customer-payment-methods-tbody:empty) {
    display: none;
}

.theme-table th.col-type,
.theme-table td.col-type {
    width: 15%;
}
.theme-table th.col-details,
.theme-table td.col-details {
    width: 40%;
}
.theme-table th.col-status,
.theme-table td.col-status {
    width: 20%;
}
.theme-table th.col-actions,
.theme-table td.col-actions {
    width: 25%;
    text-align: right;
}
/* Ensure buttons in action cells are spaced if multiple, and align right */
.theme-table td.col-actions .btn + .btn { /* Space between adjacent buttons */
    margin-left: 0.5rem;
}


/* Payment Method Status Badges */
.status-badge { /* Common style for all status badges in the table */
    padding: 0.3em 0.6em;
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: var(--border-radius-small);
    display: inline-block; /* Ensure badge behaves well */
}

.status-active-default {
    background-color: var(--primary-main);
    color: var(--primary-contrast);
}

.status-verified {
    background-color: var(--success-main);
    color: var(--primary-contrast); /* Assuming white text on success */
}

.status-expiring-soon {
    background-color: var(--warning-main);
    color: #000000; /* Dark text for yellow/orange warning background for better contrast */
}
[data-theme="dark"] .status-expiring-soon {
    /* Using primary-contrast (light text) for warning in dark mode */
    color: var(--primary-contrast);
}


.status-active { /* A generic active status, if used */
    background-color: var(--info-main);
    color: var(--primary-contrast); /* Assuming white text on info */
}

/* Action Buttons in Payment Methods Table */
#customer-payment-methods-tbody .btn-edit-pm,
#customer-payment-methods-tbody .btn-remove-pm {
    padding: 0.3rem 0.6rem; /* Slightly smaller padding for table buttons */
    font-size: 0.8rem;      /* Slightly smaller font size */
    border-width: 1px;
    border-style: solid;
    line-height: 1.5; /* Ensure text is vertically centered */
    border-radius: var(--border-radius-small);
}

#customer-payment-methods-tbody .btn-edit-pm {
    color: var(--primary-main);
    border-color: var(--primary-main);
    background-color: transparent;
}
#customer-payment-methods-tbody .btn-edit-pm:hover,
#customer-payment-methods-tbody .btn-edit-pm:focus {
    color: var(--primary-contrast);
    background-color: var(--primary-main);
    border-color: var(--primary-main);
}

#customer-payment-methods-tbody .btn-remove-pm {
    color: var(--error-main);
    border-color: var(--error-main);
    background-color: transparent;
}
#customer-payment-methods-tbody .btn-remove-pm:hover,
#customer-payment-methods-tbody .btn-remove-pm:focus {
    color: var(--primary-contrast); /* Assuming white text on error bg */
    background-color: var(--error-main);
    border-color: var(--error-main);
}

/* Ensure table cells have consistent padding and vertical alignment */
.theme-table td, .theme-table th {
    /* padding: 0.75rem; Bootstrap default, can be overridden by theme-table if it's more specific */
    vertical-align: middle;
}

/* ==========================================================================
   System Monitoring Page Specific Styles
   ========================================================================== */

.section-title {
    font-size: 1.75rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--primary-main);
}

.subsection-title {
    font-size: 1.25rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-top: 1.5rem;
    margin-bottom: 1rem;
}

/* General status badge for monitoring page - distinct from payment method badges */
.monitoring-status-badge {
    display: inline-block;
    padding: 0.45em 0.75em;
    font-size: .90em;
    font-weight: 700;
    line-height: 1;
    color: #fff; /* Default color, specific statuses will override background */
    text-align: center;
    white-space: nowrap;
    vertical-align: baseline;
    border-radius: var(--border-radius-medium);
}

.monitoring-status-badge.status-operational,
.monitoring-status-badge.status-connected,
.monitoring-status-badge.status-healthy {
    background-color: var(--success-main);
    color: var(--primary-contrast);
}

.monitoring-status-badge.status-degraded,
.monitoring-status-badge.status-warning {
    background-color: var(--warning-main);
    color: #000000; /* Dark text for warning for better contrast on light themes */
}
[data-theme="dark"] .monitoring-status-badge.status-degraded,
[data-theme="dark"] .monitoring-status-badge.status-warning {
    /* Using primary-contrast (light text) for warning in dark mode */
    color: var(--primary-contrast);
}


.monitoring-status-badge.status-error,
.monitoring-status-badge.status-disconnected,
.monitoring-status-badge.status-issues {
    background-color: var(--error-main);
    color: var(--primary-contrast);
}

.error-log-stream {
    height: 300px;
    background-color: var(--background-default); /* Use default bg for contrast */
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    overflow-y: auto;
    padding: 1rem;
}

#error-log-content {
    font-family: var(--font-family-monospace);
    font-size: 0.875rem;
    color: var(--text-primary);
    white-space: pre-wrap;
    word-break: break-all;
}

.theme-list-group-item { /* For alerts list */
    background-color: var(--background-paper);
    border-color: var(--border-color);
    color: var(--text-primary);
}

.list-group-item.theme-list-group-item + .list-group-item.theme-list-group-item {
    border-top-color: var(--border-color); /* Ensure consistent border color between items */
}

/* Ensure chart canvas elements are responsive by default */
canvas {
    max-width: 100%;
    height: auto; /* Default height, allows override by more specific rules or inline styles */
    display: block; /* Fixes potential inline spacing issues */
}

/* Styling for the chart wrapper on system monitoring page */
.system-monitoring-container .chart-wrapper {
    position: relative;
    height: 250px; /* Fixed height for the chart container */
    width: 100%;
}

/* Canvas within the wrapper should fill it */
.system-monitoring-container .card-body .chart-wrapper canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100% !important;
    height: 100% !important;
}

/* Status Badge Styling */
.status-badge {
    display: inline-block;
    padding: 0.4em 0.75em;
    font-size: 0.8rem; /* Slightly larger for better readability */
    font-weight: 600;
    line-height: 1;
    color: var(--primary-contrast); /* Default white text, good for colored backgrounds */
    text-align: center;
    white-space: nowrap;
    vertical-align: baseline;
    border-radius: var(--border-radius-medium); /* Consistent with card radius */
    letter-spacing: 0.5px;
}

.status-badge.status-operational {
    background-color: var(--success-main);
}

.status-badge.status-warning {
    background-color: var(--warning-main);
}

.status-badge.status-error {
    background-color: var(--error-main);
}

.status-badge.status-unknown {
    background-color: var(--neutral-medium);
    color: var(--background-paper); /* Ensure contrast if neutral-medium is light */
}

/* Ensure theme-card headers are styled correctly if not already covered */

/* Ensure theme-card headers are styled correctly if not already covered */
/* This might be redundant if .theme-card .card-header already exists and is sufficient */
.theme-card > .card-header {
    background-color: var(--background-paper); /* Ensure header matches theme */
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.75rem 1.25rem; /* Standard Bootstrap padding */
}


/* AI Training Page Styles */
.ai-training-container {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Agent Grid */
.agent-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 18px;
    margin-top: 18px;
}

.agent-card {
    background-color: var(--background-paper);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-medium);
    padding: 18px;
    transition: all var(--transition-speed) ease;
}

.agent-card:hover {
    box-shadow: var(--box-shadow-md);
    transform: translateY(-2px);
}

.agent-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
}

.agent-icon {
    font-size: 1.8rem;
}

.agent-header h3 {
    margin: 0;
    font-size: 1rem;
    color: var(--text-primary);
}

.agent-stats {
    display: flex;
    justify-content: space-between;
    margin-bottom: 14px;
}

.agent-stats .stat {
    text-align: center;
}

.stat-label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 3px;
}

.stat-value {
    display: block;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.agent-actions {
    display: flex;
    gap: 7px;
}

.btn-small {
    padding: 5px 11px;
    font-size: 0.8rem;
}

/* Training Tabs */
.training-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 20px;
    background: #1e1e1e;
    border-radius: 4px;
    overflow: hidden;
}

.tab-btn {
    background: #2c3e50;
    border: none;
    color: #a0a0a0;
    cursor: pointer;
    padding: 12px 24px;
    font-weight: 500;
    font-size: 14px;
    transition: all var(--transition-speed) var(--transition-cubic);
    flex: 1;
    position: relative;
}

.tab-btn:not(:last-child)::after {
    content: '';
    position: absolute;
    right: 0;
    top: 25%;
    height: 50%;
    width: 1px;
    background: #34495e;
}

.tab-btn.active {
    background: #3498db;
    color: white;
}

.tab-btn:hover:not(.active) {
    background: #34495e;
    color: #ffffff;
}

/* Upload Area */
.upload-area {
    margin: 20px 0;
}

.upload-dropzone {
    border: 2px dashed var(--border-color);
    border-radius: var(--border-radius-medium);
    padding: 40px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-speed) var(--transition-cubic);
}

.upload-dropzone:hover {
    border-color: var(--primary-main);
    background-color: var(--background-default);
}

.upload-dropzone.dragover {
    border-color: var(--primary-main);
    background-color: var(--primary-light);
    opacity: 0.1;
}

.upload-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 16px;
}

.upload-hint {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-top: 8px;
}

/* Uploaded Files */
.uploaded-files {
    margin-top: 20px;
}

.uploaded-file-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background-color: var(--background-default);
    border-radius: var(--border-radius-small);
    margin-bottom: 8px;
}

.file-icon {
    font-size: 1.5rem;
}

.file-name {
    flex: 1;
    font-weight: 500;
}

.file-size {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.remove-file-btn {
    background: none;
    border: none;
    color: var(--error-main);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Q&A Form */
.qa-form {
    max-width: 600px;
}

.qa-form .form-group {
    margin-bottom: 20px;
}

.qa-form label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-primary);
}

.qa-form textarea,
.qa-form select {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-small);
    background-color: var(--background-paper);
    color: var(--text-primary);
    font-family: var(--font-family-base);
    transition: border-color var(--transition-speed) var(--transition-cubic);
}

.qa-form textarea:focus,
.qa-form select:focus {
    outline: none;
    border-color: var(--primary-main);
}

/* Conversation List */
.conversation-list {
    max-height: 500px;
    overflow-y: auto;
}

.conversation-item {
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-medium);
    padding: 16px;
    margin-bottom: 12px;
    background-color: var(--background-paper);
}

.conversation-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
    font-size: 0.875rem;
}

.customer-name {
    font-weight: 600;
    color: var(--text-primary);
}

.agent-name {
    color: var(--primary-main);
}

.timestamp {
    color: var(--text-secondary);
}

.conversation-content p {
    margin: 8px 0;
}

.conversation-content strong {
    color: var(--text-primary);
}

.conversation-actions {
    text-align: right;
    margin-top: 10px; /* Space above action buttons */
}

/* Feedback List */
.feedback-list {
    max-height: 500px;
    overflow-y: auto;
}

.feedback-item {
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-medium);
    padding: 16px;
    margin-bottom: 12px;
    background-color: var(--background-paper);
}

.feedback-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
    font-size: 0.875rem;
}

.feedback-content p {
    margin: 8px 0;
}

.feedback-rating {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
}

.rating-btn {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-small);
    padding: 8px 12px;
    font-size: 1.25rem;
    cursor: pointer;
    transition: all var(--transition-speed) var(--transition-cubic);
}

.rating-btn:hover {
    background-color: var(--background-default);
    transform: scale(1.1);
}

.rating-btn.selected {
    background-color: var(--primary-main);
    border-color: var(--primary-main);
}

/* Customization Grid */
.customization-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.customization-item {
    text-align: center;
    padding: 20px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-medium);
    background-color: var(--background-default);
}

.customization-item h3 {
    margin: 0 0 8px 0;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.customization-item p {
    margin: 0 0 16px 0;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Feature Grid */
.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.feature-item {
    text-align: center;
    padding: 24px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-medium);
    background-color: var(--background-default);
    transition: all var(--transition-speed) var(--transition-cubic);
}

.feature-item:hover {
    box-shadow: var(--box-shadow-md);
    transform: translateY(-2px);
}

.feature-icon {
    font-size: 2.5rem;
    display: block;
    margin-bottom: 16px;
}

.feature-item h3 {
    margin: 0 0 8px 0;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.feature-item p {
    margin: 0 0 16px 0;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Notifications */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 16px 24px;
    border-radius: var(--border-radius-medium);
    background-color: var(--background-paper);
    box-shadow: var(--box-shadow-lg);
    transform: translateX(400px);
    transition: transform var(--transition-speed) var(--transition-cubic);
    z-index: 1000;
}

.notification.show {
    transform: translateX(0);
}

.notification-success {
    border-left: 4px solid var(--success-main);
}

.notification-info {
    border-left: 4px solid var(--info-main);
}

.notification-warning {
    border-left: 4px solid var(--warning-main);
}

.notification-error {
    border-left: 4px solid var(--error-main);
}

/* Button Variants */
.btn-secondary {
    background-color: var(--neutral-main);
    color: var(--neutral-contrast);
}

.btn-secondary:hover {
    background-color: var(--neutral-dark);
}

/* Responsive adjustments for AI Training */
@media (max-width: 768px) {
    .agent-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    }
    
    .training-tabs {
        flex-wrap: wrap;
    }
    
    .tab-btn {
        padding: 8px 16px;
        font-size: 0.875rem;
    }
    
    .customization-grid,
    .feature-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    }
}

/* Tab functionality CSS - AI Playground */
.training-tabs {
    display: flex;
    gap: 2px;
    margin-bottom: 20px;
}

.tab-btn {
    background: #495057;
    border: none;
    color: #ffffff;
    cursor: pointer;
    padding: 12px 24px;
    font-weight: 500;
    font-size: 14px;
    transition: all 0.3s ease;
    flex: 1;
    position: relative;
}

.tab-btn.active {
    background: #007bff;
    color: white;
}

.tab-btn:hover {
    background: #6c757d;
    color: white;
}

.tab-btn.active:hover {
    background: #0056b3;
}

/* Dark mode adjustments */
[data-theme="dark"] .tab-btn {
    background: #495057;
    color: #ffffff;
}

[data-theme="dark"] .tab-btn.active {
    background: #007bff;
    color: white;
}

[data-theme="dark"] .tab-btn:hover {
    background: #6c757d;
}

[data-theme="dark"] .tab-content {
    background: #2c3e50;
    border: 1px solid #34495e;
}

/* Tab content visibility - Essential for functionality */
.tab-content {
    background: transparent;
    padding: 0;
}

.tab-pane {
    display: none !important;
}

.tab-pane.active {
    display: block !important;
}

/* Dark mode adjustments for tabs */
[data-theme="dark"] .training-tabs {
    background: #1e1e1e;
}

[data-theme="dark"] .tab-btn {
    background: #2c3e50;
    color: #a0a0a0;
}

[data-theme="dark"] .tab-btn.active {
    background: #3498db;
    color: white;
}

[data-theme="dark"] .tab-btn:hover:not(.active) {
    background: #34495e;
    color: #ffffff;
}

/* Knowledge Upload Modal Form Check Alignment Fix */
.crawler-options .form-check {
    display: grid;
    grid-template-columns: 200px 20px;
    align-items: center;
    margin-bottom: 15px;
}

.crawler-options .form-check-input {
    margin: 0;
    width: 16px;
    height: 16px;
    justify-self: start;
}

.crawler-options .form-check-label {
    margin: 0;
    font-weight: 500;
    color: var(--text-secondary);
    justify-self: start;
}

/* Knowledge Upload Modal Tab Styling */
.upload-tab-container {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
}

.upload-tab {
    padding: 8px 16px;
    cursor: pointer;
    background-color: transparent;
    border: 1px solid transparent;
    border-bottom: none;
    border-radius: var(--border-radius-medium) var(--border-radius-medium) 0 0;
    color: var(--text-secondary);
    font-weight: 500;
    transition: all var(--transition-speed) ease;
}

.upload-tab:hover {
    background-color: var(--neutral-dark);
    color: var(--text-primary);
}

.upload-tab.active {
    background-color: var(--background-paper);
    color: var(--primary-main);
    border-color: var(--border-color);
    border-bottom: 1px solid var(--background-paper);
    transform: translateY(1px);
}

.upload-content {
    display: none;
}

.upload-content.active {
    display: block;
}

/* Spinner for loading states */
.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

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

/* Modal button danger style */
.btn-danger {
    background: #dc3545;
    border-color: #dc3545;
    color: white;
}

.btn-danger:hover {
    background: #c82333;
    border-color: #bd2130;
}

/* Dashboard Section Header with Date Filters */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 20px;
}

.section-header h2 {
    margin: 0;
}

.date-filters {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.date-filters label {
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 14px;
}

.date-range-select {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-small);
    background-color: var(--background-paper);
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    min-width: 140px;
}

.date-range-select:focus {
    outline: none;
    border-color: var(--primary-main);
    box-shadow: 0 0 0 2px rgba(127, 86, 217, 0.2);
}

.custom-date-range {
    display: flex;
    align-items: center;
    gap: 8px;
}

.custom-date-range span {
    color: var(--text-secondary);
}

.date-input {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-small);
    background-color: var(--background-paper);
    color: var(--text-primary);
    font-size: 14px;
}

.date-input:focus {
    outline: none;
    border-color: var(--primary-main);
}

.btn-sm {
    padding: 8px 16px;
    font-size: 14px;
}

.btn-secondary {
    background-color: var(--neutral-light);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background-color: var(--neutral-medium);
}

/* Dark mode support for date filters */
[data-theme="dark"] .date-range-select,
[data-theme="dark"] .date-input {
    background-color: var(--background-paper);
    border-color: var(--border-color);
    color: var(--text-primary);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .section-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .date-filters {
        width: 100%;
    }
}
