@use 'sass:color';

$bareos-blue: #0075be;
$bareos-blue-dark: #005a96;

.bareos-panel {
  border-radius: 4px;
  overflow: hidden;

  .q-card__section.panel-header {
    background-color: $bareos-blue;
    color: white;
    padding: 10px 16px;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: 0;

    .q-field {
      color: rgba(255, 255, 255, 0.95);
    }

    .q-field__control,
    .q-field__native,
    .q-field__input,
    .q-field__label,
    .q-field__marginal,
    .q-select__dropdown-icon {
      color: rgba(255, 255, 255, 0.95);
    }

    .q-field__native::placeholder,
    .q-field__input::placeholder {
      color: rgba(255, 255, 255, 0.7);
      opacity: 1;
    }

    .q-field--outlined .q-field__control::before,
    .q-field--outlined .q-field__control::after {
      border-color: rgba(255, 255, 255, 0.7);
    }

    .q-field--focused .q-field__label,
    .q-field--highlighted .q-field__label,
    .q-field--focused .q-field__marginal,
    .q-field--highlighted .q-field__marginal,
    .q-field--focused .q-select__dropdown-icon,
    .q-field--highlighted .q-select__dropdown-icon {
      color: white;
    }

    .q-field--outlined.q-field--focused .q-field__control::after,
    .q-field--outlined.q-field--highlighted .q-field__control::after {
      border-color: white;
    }
  }

  .q-table__container,
  .q-table__top,
  .q-table__middle,
  .q-table__bottom {
    border-radius: 0;
  }

  .q-table thead tr:first-child th:first-child {
    border-top-left-radius: 0;
  }

  .q-table thead tr:first-child th:last-child {
    border-top-right-radius: 0;
  }
}

.status-badge {
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 0.78rem;
  font-weight: 600;
  display: inline-block;
}

.stat-number {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
}

.stat-label {
  font-size: 0.8rem;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.page-tabs .q-tab {
  text-transform: none;
  font-size: 0.875rem;
}

.q-table thead th {
  background-color: $bareos-blue;
  color: white;
  font-weight: 600;
}

.q-table tbody tr:hover {
  background-color: #f0f7fd;
}

.bareos-toolbar {
  background-color: $bareos-blue !important;
}

.bareos-statusbar {
  background-color: color.adjust($bareos-blue, $lightness: -10%) !important;
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.72rem;
  height: 22px;
  min-height: 22px;
  line-height: 22px;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  gap: 6px;
}

.panel-refresh-countdown {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  opacity: 0.7;
}

.panel-refresh-countdown__value {
  display: inline-block;
  width: 3ch;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.nav-link-text {
  font-size: 0.875rem;
}

.console-output {
  font-family: 'Courier New', monospace;
  font-size: 0.8rem;
  background: #1e1e1e;
  color: #d4d4d4;
  padding: 12px;
  border-radius: 4px;
  height: 500px;
  overflow-y: auto;
  white-space: pre-wrap;
}

.job-log {
  font-family: 'Courier New', monospace;
  font-size: 0.8rem;
  background: #f8f9fa;
  color: #333;
  white-space: pre-wrap;
  word-break: break-all;
  border-radius: 0 0 4px 4px;
  max-height: 320px;
  overflow-y: auto;
}

.text-mono {
  font-family: 'Courier New', monospace;
}

.animated-spin {
  animation: hourglass-spin 1.4s ease-in-out infinite;
}

@keyframes hourglass-spin {
  0%   { transform: rotate(0deg); }
  45%  { transform: rotate(0deg); }
  55%  { transform: rotate(180deg); }
  100% { transform: rotate(180deg); }
}

// ── Scheduler Calendar ────────────────────────────────────────────────────────
.sched-calendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
}

.sched-cal-header {
  text-align: center;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 4px 2px;
  color: #555;
}

.sched-cal-cell {
  min-height: 72px;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  padding: 3px;
  overflow: hidden;
  position: relative;
}

.sched-cal-cell--week {
  min-height: 200px;
}

.sched-cal-empty {
  background: #fafafa;
  border-color: transparent;
}

.sched-cal-today {
  border-color: var(--q-primary) !important;
  border-width: 2px;
}

.sched-cal-day-num {
  font-size: 0.72rem;
  font-weight: 600;
  color: #666;
  margin-bottom: 2px;
}

.sched-cal-run {
  font-size: 0.62rem;
  color: #fff;
  border-radius: 3px;
  padding: 1px 4px;
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  gap: 3px;
  overflow: hidden;
  cursor: default;
}

.sched-cal-run-level {
  flex-shrink: 0;
  transform: scale(0.78);
  transform-origin: left center;
  margin-right: -2px;
}

.sched-cal-run-time {
  flex-shrink: 0;
  opacity: 0.9;
}

.sched-cal-run-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sched-group-header td {
  background: rgba(0, 0, 0, 0.04);
  font-size: 0.8rem;
}
.body--dark .sched-group-header td {
  background: rgba(255, 255, 255, 0.06);
}

// ── Timeline ──────────────────────────────────────────────────────────────────
.tl-container {
  position: relative;
  overflow-x: auto;
}

.tl-tooltip {
  position: fixed;
  background: rgba(30, 30, 30, 0.92);
  color: #eee;
  font-size: 0.78rem;
  line-height: 1.6;
  padding: 8px 12px;
  border-radius: 6px;
  pointer-events: none;
  white-space: nowrap;
  z-index: 10;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.tl-legend-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 2px;
  flex-shrink: 0;
}

// ── Dark mode overrides ───────────────────────────────────────────────────────
body.body--dark {
  .bareos-panel {
    .q-card__section.panel-header {
      background-color: $bareos-blue-dark;
    }
  }

  .stat-label {
    color: #aaa;
  }

  .q-table thead th {
    background-color: $bareos-blue-dark;
  }

  .q-table tbody tr:hover {
    background-color: rgba(255, 255, 255, 0.07);
  }

  .job-log {
    background: #2a2a2a;
    color: #ccc;
  }
}

// ── Print (subscription PDF export) ──────────────────────────────────────────
@media print {
  // Hide everything except the subscription report overlay
  body > * { display: none !important; }
  #subscription-print-root { display: block !important; }

  #subscription-print-root {
    position: fixed;
    inset: 0;
    background: white;
    color: black;
    padding: 20mm 18mm;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 10pt;
  }
}
