/*
 * This is a manifest file that'll be compiled into application.css.
 *
 * With Propshaft, assets are served efficiently without preprocessing steps. You can still include
 * application-wide styles in this file, but keep in mind that CSS precedence will follow the standard
 * cascading order, meaning styles declared later in the document or manifest will override earlier ones,
 * depending on specificity.
 *
 * Consider organizing styles into separate files for maintainability.
 */
.tall-modal {
    min-height: 80vh;
    overflow-y: auto;
}

.clickable-row {
  transition: background-color 0.2s ease;
}

.clickable-row:hover {
  background-color: rgba(0, 0, 0, 0.05) !important;
}

.overdue-row {
  background-color: #fff8f8;
}

/* Light (default) */
:root {
  --background-color: #ffffff;
  --text-color: #212121;
  --muted-text-color: #666666;
  --card-bg-color: #ffffff;
  --nav-text-color: #ffffff;
}

/*
 * Dark: dimmed greys rather than near-black, to soften the contrast. Navigation
 * and footer keep their teal (Materialize colour classes with !important).
 * color-scheme darkens native controls, scrollbars and date pickers.
 */
:root[data-theme='dark'] {
  color-scheme: dark;
  --background-color: #242529;
  --text-color: #dcdde0;
  --muted-text-color: #a9adb4;
  --card-bg-color: #2f3035;
  --nav-text-color: #ffffff;
  /* Dims light surfaces while keeping their hue; background-image paints over background-color */
  --dim-overlay: linear-gradient(rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0.8));
  --tint-overlay: linear-gradient(rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.6));
  --dark-border-color: rgba(255, 255, 255, 0.12);
}

/* Apply to body + common Materialize elements */
body {
  background-color: var(--background-color);
  color: var(--text-color);
}

nav a,
nav .brand-logo,
nav ul a {
  color: var(--nav-text-color) !important;
}

.card,
.sidenav {
  background-color: var(--card-bg-color);
  color: var(--text-color);
}

.btn, .btn-large, .btn-small {
  /* Keep Materialize colors for background, but adjust text if needed */
  color: var(--nav-text-color);
}

/*
 * Text in dark mode. Only containers and Materialize components are forced here;
 * plain text elements inherit, so status colours set on them (inline or by page
 * styles) stay visible.
 */
:root[data-theme='dark'] body,
:root[data-theme='dark'] body .card,
:root[data-theme='dark'] body .card-content,
:root[data-theme='dark'] body .card-title,
:root[data-theme='dark'] body .collection-item,
:root[data-theme='dark'] body .breadcrumb,
:root[data-theme='dark'] body .tabs .tab a,
:root[data-theme='dark'] body .tabs .tab a.active,
:root[data-theme='dark'] body .pagination li a,
:root[data-theme='dark'] body .sidenav a,
:root[data-theme='dark'] body .modal,
:root[data-theme='dark'] body .modal-content {
  color: var(--text-color) !important;
}

/* Materialize components that set a dark text colour of their own */
:root[data-theme='dark'] .btn-flat,
:root[data-theme='dark'] .dropdown-content li,
:root[data-theme='dark'] .sidenav li > a > i.material-icons {
  color: var(--text-color);
}

:root[data-theme='dark'] .input-field .helper-text,
:root[data-theme='dark'] span.badge,
:root[data-theme='dark'] .sidenav .subheader {
  color: var(--muted-text-color);
}

:root[data-theme='dark'] .grey-text.text-darken-1,
:root[data-theme='dark'] .grey-text.text-darken-2,
:root[data-theme='dark'] .grey-text.text-darken-3,
:root[data-theme='dark'] .grey-text.text-darken-4 {
  color: var(--muted-text-color) !important;
}

/* Neutral dark greys set inline in views */
:root[data-theme='dark'] [style*="color: #666"],
:root[data-theme='dark'] [style*="color: #757575"],
:root[data-theme='dark'] [style*="color: #9e9e9e"] {
  color: var(--muted-text-color) !important;
}

/* Dark red on a dark background is too faint */
:root[data-theme='dark'] [style*="color: #d32f2f"] {
  color: #ef5350 !important;
}

/* Form labels + inputs */
:root[data-theme='dark'] label,
:root[data-theme='dark'] .input-field label {
  color: var(--text-color) !important;
}

/* Native buttons keep their light background, so they keep their dark text */
:root[data-theme='dark'] input:not([type='submit']):not([type='button']):not([type='reset']),
:root[data-theme='dark'] textarea,
:root[data-theme='dark'] select {
  color: var(--text-color);
}

/* Materialize gives selects a near-white background (e.g. the creator filter on the home page) */
:root[data-theme='dark'] select {
  background-color: var(--card-bg-color);
  border-color: var(--dark-border-color);
}

/* Links in dark mode (including link_to) */
:root[data-theme='dark'] a,
:root[data-theme='dark'] a:visited {
  color: var(--text-color) !important;
}

/* But keep button-style links using their own colors */
:root[data-theme='dark'] a.btn,
:root[data-theme='dark'] a.btn-large,
:root[data-theme='dark'] a.btn-small,
:root[data-theme='dark'] a.btn-flat {
  color: var(--nav-text-color) !important;
}

/* Materialize surfaces that default to white or light grey */
:root[data-theme='dark'] .card-panel,
:root[data-theme='dark'] .card .card-reveal,
:root[data-theme='dark'] .modal,
:root[data-theme='dark'] .modal .modal-footer,
:root[data-theme='dark'] .dropdown-content,
:root[data-theme='dark'] .collection .collection-item,
:root[data-theme='dark'] .collapsible-header,
:root[data-theme='dark'] .tabs {
  background-color: var(--card-bg-color);
}

:root[data-theme='dark'] .dropdown-content li:hover,
:root[data-theme='dark'] .dropdown-content li.active {
  background-color: rgba(255, 255, 255, 0.08);
}

:root[data-theme='dark'] .divider {
  background-color: rgba(255, 255, 255, 0.12);
}

/* Tables: Materialize draws row borders, stripes and hover in black/light grey */
:root[data-theme='dark'] tr {
  border-bottom-color: rgba(255, 255, 255, 0.1);
}

:root[data-theme='dark'] table.striped > tbody > tr:nth-child(odd) {
  background-color: rgba(255, 255, 255, 0.04);
}

:root[data-theme='dark'] table.highlight > tbody > tr:hover,
:root[data-theme='dark'] .clickable-row:hover {
  background-color: rgba(255, 255, 255, 0.06) !important;
}

/* Sticky table headers get a light grey background in the customer page styles */
:root[data-theme='dark'] .responsive-table thead {
  background-color: var(--card-bg-color);
}

:root[data-theme='dark'] .overdue-row {
  background-color: rgba(211, 47, 47, 0.18);
}

/* Chips without a colour class */
:root[data-theme='dark'] .chip {
  background-color: rgba(255, 255, 255, 0.12);
  color: var(--text-color);
}

:root[data-theme='dark'] .chip:hover {
  background-color: rgba(255, 255, 255, 0.2);
}

/*
 * Light tints (lighten-3..5, light greys) are set by Materialize with !important.
 * Dim them with an overlay instead of replacing the colour, so the hue survives.
 */
:root[data-theme='dark'] .grey.lighten-1,
:root[data-theme='dark'] .grey.lighten-2,
:root[data-theme='dark'] .lighten-3,
:root[data-theme='dark'] .lighten-4,
:root[data-theme='dark'] .lighten-5 {
  background-image: var(--tint-overlay);
  color: var(--text-color) !important;
}

:root[data-theme='dark'] .lighten-3 [class*='text-darken'],
:root[data-theme='dark'] .lighten-4 [class*='text-darken'],
:root[data-theme='dark'] .lighten-5 [class*='text-darken'] {
  color: var(--text-color) !important;
}

/*
 * Customer pages (deployment, deactivation and batch modals, customer graph).
 * Their <style> blocks load after this file, hence the :root[data-theme='dark'] prefix
 * for specificity rather than relying on order.
 */
:root[data-theme='dark'] .customer-list,
:root[data-theme='dark'] .customer-progress-bar,
:root[data-theme='dark'] .progress-bar,
:root[data-theme='dark'] .stat-item,
:root[data-theme='dark'] .batch-actions-area,
:root[data-theme='dark'] .step-icon,
:root[data-theme='dark'] .status-message,
:root[data-theme='dark'] .error-details,
:root[data-theme='dark'] .error-message,
:root[data-theme='dark'] .customer-details,
:root[data-theme='dark'] .warning-message,
:root[data-theme='dark'] .customer-graph,
:root[data-theme='dark'] .filter-btn:not(:hover) {
  background-image: var(--dim-overlay);
}

/* Inline light greys; the `background:` shorthand also resets background-image inline */
:root[data-theme='dark'] [style*="background: #f5f5f5"],
:root[data-theme='dark'] [style*="background-color: #f5f5f5"] {
  background-image: var(--dim-overlay) !important;
}

/*
 * Batch deployment rows: white by default, translucent tints for running/error.
 * An overlay would turn the tints black, so let the dimmed list show through instead.
 * :where() keeps this below the page's `.customer-deployment-item.running` rules.
 */
:root[data-theme='dark'] :where(.customer-deployment-item) {
  background-color: transparent;
}

/* On the customer show page .customer-details is a plain column without a background */
:root[data-theme='dark'] .customer-layout > .customer-details {
  background-image: none;
}

/* Step icons carry their status as a tint; a flat overlay would erase it */
:root[data-theme='dark'] .step.running .step-icon {
  background-image: none;
  background-color: rgba(255, 152, 0, 0.2);
}

:root[data-theme='dark'] .step.success .step-icon {
  background-image: none;
  background-color: rgba(76, 175, 80, 0.2);
}

:root[data-theme='dark'] .step.error .step-icon {
  background-image: none;
  background-color: rgba(244, 67, 54, 0.2);
}

:root[data-theme='dark'] .error-details,
:root[data-theme='dark'] .error-message {
  border-color: rgba(244, 67, 54, 0.4);
}

:root[data-theme='dark'] .error-message {
  color: #ef9a9a;
}

:root[data-theme='dark'] .spinner {
  border-color: rgba(255, 152, 0, 0.2);
  border-top-color: #ff9800;
}

:root[data-theme='dark'] .customer-deployments-header,
:root[data-theme='dark'] .deployment-confirm-header,
:root[data-theme='dark'] .customer-deployment-item {
  border-bottom-color: var(--dark-border-color);
}

:root[data-theme='dark'] .customer-list {
  border-color: var(--dark-border-color);
}

:root[data-theme='dark'] .modal-footer {
  border-top-color: var(--dark-border-color);
}

:root[data-theme='dark'] .step:not(.running):not(.success):not(.error) {
  border-left-color: var(--dark-border-color);
}

:root[data-theme='dark'] .searching .card-content::after {
  background-color: rgba(0, 0, 0, 0.4);
}

/* Neutral text colours from the customer page styles (#333 / #666 / #999) */
:root[data-theme='dark'] .customer-deployments-header h6,
:root[data-theme='dark'] .customer-name,
:root[data-theme='dark'] .deployment-title h4,
:root[data-theme='dark'] .detail-label,
:root[data-theme='dark'] .detail-value,
:root[data-theme='dark'] .warning-message p {
  color: var(--text-color);
}

:root[data-theme='dark'] .customer-count,
:root[data-theme='dark'] .customer-url:not(:hover),
:root[data-theme='dark'] .customer-progress-text,
:root[data-theme='dark'] .stat-label,
:root[data-theme='dark'] .completed-message p,
:root[data-theme='dark'] .deployment-subtitle,
:root[data-theme='dark'] .progress-text,
:root[data-theme='dark'] .step-description,
:root[data-theme='dark'] .deployment-success p,
:root[data-theme='dark'] .detail-row i,
:root[data-theme='dark'] .filter-btn:not(:hover),
:root[data-theme='dark'] .step.waiting .step-icon,
:root[data-theme='dark'] .step.waiting .step-status,
:root[data-theme='dark'] .search-match-hint {
  color: var(--muted-text-color);
}
