/* ============================================
   site.css — shared layout utilities
   NOTE: site-theme-dark.css loads AFTER this file and supplies themed
   colors, borders, and fonts. Rules here should be LAYOUT-ONLY
   (responsive sizing, animations, specific component chrome). Do NOT
   hardcode colors here — use var(--cs-*) with fallbacks so the Theme
   Editor can retarget them.
   ============================================ */

/* Base typography - mobile first */
html {
  font-size: 14px;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

/* Layout */
html {
  position: relative;
  min-height: 100%;
}

/* Smooth scrolling */
html {
  scroll-behavior: smooth;
}

/* Mobile-optimized card hover (layout only — colors themed in site-theme-dark.css) */
.card {
  transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
  transform: translateY(-2px);
}

/* Responsive navbar */
@media (max-width: 991.98px) {
  .navbar-nav {
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
  }

  .navbar-nav .nav-link {
    padding: 0.5rem 0;
  }
}

/* Button shape (color + radius themed in site-theme-dark.css) */
.btn {
  font-weight: 500;
  transition: all 0.2s;
}

.btn-lg {
  padding: 0.75rem 1.5rem;
}

/* Mobile touch targets */
@media (max-width: 767.98px) {
  .btn {
    min-height: 44px;
    padding: 0.5rem 1rem;
  }

  .form-control, .form-select {
    min-height: 44px;
  }

  .nav-link {
    min-height: 44px;
    display: flex;
    align-items: center;
  }
}

/* Hero primary background (Bootstrap .bg-primary override).
   Uses theme gradient endpoints so it retargets with the brand. */
.bg-primary {
  background: linear-gradient(135deg,
    var(--cs-modal-header-bg-start, var(--cs-purple, #667eea)) 0%,
    var(--cs-modal-header-bg-end, var(--cs-blue, #764ba2)) 100%) !important;
}

/* Feature icons */
.feature-icon {
  font-size: 2rem;
}

/* Stats cards on dashboard */
.card-body h3 {
  font-size: 2rem;
  font-weight: 700;
}

/* Mobile spacing adjustments */
@media (max-width: 767.98px) {
  .py-5 {
    padding-top: 2rem !important;
    padding-bottom: 2rem !important;
  }

  .display-4 {
    font-size: 2rem;
  }

  .display-5 {
    font-size: 1.75rem;
  }
}

/* Alert animations */
.alert {
  animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Loading states */
.btn.loading {
  position: relative;
  color: transparent !important;
}

.btn.loading::after {
  content: "";
  position: absolute;
  width: 1rem;
  height: 1rem;
  top: 50%;
  left: 50%;
  margin-left: -0.5rem;
  margin-top: -0.5rem;
  border: 2px solid currentColor;
  border-radius: 50%;
  border-top-color: transparent;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Responsive tables */
@media (max-width: 767.98px) {
  .table-responsive {
    font-size: 0.875rem;
  }
}

/* Badge improvements */
.badge {
  font-weight: 500;
  padding: 0.35em 0.65em;
}

/* List group improvements */
.list-group-item {
  border-left: none;
  border-right: none;
}

.list-group-item:first-child {
  border-top: none;
}

.list-group-item:last-child {
  border-bottom: none;
}

/* Accessibility improvements */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ===== Camera Schedule Grid ===== */
.schedule-card:hover {
    transform: none !important;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075) !important;
}

.schedule-grid {
    user-select: none;
    -webkit-user-select: none;
    cursor: default;
}

.schedule-grid .schedule-time-col {
    width: 70px;
    min-width: 70px;
}

.schedule-grid .schedule-time-label {
    font-size: 0.7rem;
    color: var(--cs-text-secondary, #6c757d);
    white-space: nowrap;
    padding: 1px 4px !important;
    vertical-align: middle;
    border-right: 2px solid var(--cs-border, #dee2e6);
}

.schedule-grid .schedule-day-header {
    font-size: 0.8rem;
    padding: 4px 2px !important;
}

.schedule-grid .schedule-cell {
    padding: 0 !important;
    height: 6px;
    min-width: 28px;
    cursor: pointer;
    transition: background-color 0.05s;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

/* schedule-on / schedule-off use semantic success/danger theme colors */
.schedule-grid .schedule-cell.schedule-on {
    background-color: var(--cs-alert-success, #28a745);
}

.schedule-grid .schedule-cell.schedule-off {
    background-color: var(--cs-alert-danger, #f8d7da);
    opacity: 0.5;
}

.schedule-grid .schedule-cell:hover {
    outline: 2px solid var(--cs-blue, #0d6efd);
    outline-offset: -2px;
    z-index: 1;
    position: relative;
}

.schedule-grid .schedule-time-label.schedule-highlight {
    background-color: var(--cs-alert-warning, #fff3cd) !important;
    color: var(--cs-dark-bg, #664d03) !important;
    font-weight: 600;
}

.schedule-grid .schedule-day-header.schedule-highlight {
    background-color: var(--cs-alert-warning, #fff3cd) !important;
    color: var(--cs-dark-bg, #664d03) !important;
}

.schedule-grid tr[data-hour-boundary] td {
    border-top: 1px solid var(--cs-border, #adb5bd);
}

.schedule-tabs .nav-link {
    font-size: 0.85rem;
    padding: 0.3rem 0.75rem;
}

.schedule-tabs .nav-link.active {
    font-weight: 600;
}

/* "All Hours ON" quick-fill button — match the grid's green on-cell color
   (the themed btn-success renders purple on the dark theme). */
.schedule-quickfill .btn-schedule-on,
.schedule-quickfill .btn-schedule-on:hover,
.schedule-quickfill .btn-schedule-on:focus,
.schedule-quickfill .btn-schedule-on:active {
    background-color: var(--cs-alert-success, #28a745) !important;
    border-color: var(--cs-alert-success, #1e7e34) !important;
    color: #000 !important;
}

/* Black text on the green ON and red OFF buttons for readability */
.schedule-quickfill .btn-schedule-on,
.schedule-quickfill .btn-danger,
.schedule-quickfill .btn-danger:hover,
.schedule-quickfill .btn-danger:focus,
.schedule-quickfill .btn-danger:active {
    color: #000 !important;
}

/* ===== Mobile scheduler — day-at-a-time touch editor (PT-00356) ===== */

/* Separate the schedule grid from the action buttons above it */
#scheduleGridHost {
    margin-top: 16px;
}

/* Panel around the day selector + grid for visual separation */
.schedule-mobile {
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    padding: 12px;
    background: rgba(0, 0, 0, 0.15);
}

/* Day selector pills */
.schedule-day-pills {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 6px;
    margin-bottom: 12px;
}

.sm-day-pill {
    flex: 1 0 auto;
    min-width: 44px;
    min-height: 44px;
    border: 1px solid var(--cs-border, #dee2e6);
    background: #fff;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--cs-text-secondary, #495057);
}

.sm-day-pill.active {
    background: var(--cs-blue, #0d6efd);
    border-color: var(--cs-blue, #0d6efd);
    color: #fff;
}

/* Mobile grid: hour rows x quarter cells.
   touch-action: manipulation kills double-tap zoom on rapid taps;
   -webkit-touch-callout/user-select kill the iOS long-press text callout/magnifier. */
.schedule-mobile-grid {
    touch-action: manipulation;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

.sm-hour-row {
    display: flex;
    align-items: stretch;
    border-top: 1px solid var(--cs-border, #e9ecef);
}

.sm-hour-label {
    flex: 0 0 56px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 8px;
    font-size: 0.9rem;
    color: var(--cs-text-secondary, #6c757d);
}

.sm-quarters {
    display: flex;
    flex: 1 1 auto;
    gap: 2px;
    padding: 2px 0;
}

.sm-quarter {
    flex: 1 1 0;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    cursor: pointer;
    border: 1px solid rgba(0, 0, 0, 0.08);
}

.sm-quarter .sm-q-label {
    font-size: 0.85rem;
    color: #000;
    opacity: 0.8;
    pointer-events: none;
}

.sm-quarter.schedule-on {
    background-color: var(--cs-alert-success, #28a745);
    color: #000;
}

.sm-quarter.schedule-off {
    background-color: var(--cs-alert-danger, #f8d7da);
}

/* Phone layout: full-width tappable controls inside the scheduler card */
@media (max-width: 767.98px) {
    #scheduleContainer .form-select,
    #scheduleContainer .form-select-sm {
        width: 100% !important;
        min-width: 0 !important;
        min-height: 44px;
    }

    #scheduleContainer .schedule-controls > div {
        width: 100%;
    }

    #scheduleContainer .schedule-mobile-selector .form-select {
        flex: 1 1 auto;
    }

    /* Stack the action buttons full-width and aligned (one per row) */
    #scheduleContainer .schedule-quickfill {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    #scheduleContainer .schedule-quickfill > .btn {
        width: 100%;
        flex: 0 0 auto;
        min-height: 44px;
        justify-content: center;
    }

    /* Hide the flex spacer and the inline help icons on phones (declutter) */
    #scheduleContainer .schedule-quickfill > .flex-grow-1 {
        display: none;
    }

    #scheduleContainer .schedule-quickfill > .help-tooltip-container,
    #scheduleContainer .schedule-pushgroup .help-tooltip-container {
        display: none;
    }

    /* Push button stacks full-width like the rest */
    #scheduleContainer .schedule-pushgroup {
        width: 100%;
    }

    #scheduleContainer .btn-deploy-schedule {
        width: 100%;
        min-height: 44px;
        justify-content: center;
    }
}

/* ========================================
   Help Tooltip (reusable question-mark icon)
   ======================================== */
.help-tooltip-container {
    position: relative;
    display: inline-block;
}

.help-tooltip-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    background: linear-gradient(135deg,
      var(--cs-alert-info, #17a2b8) 0%,
      var(--cs-blue, #138496) 100%);
    color: #ffffff;
    border-radius: 50%;
    font-size: 11px;
    font-weight: bold;
    cursor: help;
    margin-left: 6px;
    transition: transform 0.2s, box-shadow 0.2s;
    border: none;
    vertical-align: middle;
}

.help-tooltip-trigger:hover {
    transform: scale(1.15);
    box-shadow: 0 3px 10px var(--cs-focus-ring, rgba(23, 162, 184, 0.4));
}

.help-tooltip-content {
    visibility: hidden;
    opacity: 0;
    position: absolute;
    z-index: 1050;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    width: 320px;
    background: linear-gradient(135deg,
      var(--cs-card-bg, #1a1a2e) 0%,
      var(--cs-dark-bg, #16213e) 100%);
    color: var(--cs-text-primary, #ffffff);
    padding: 14px;
    border-radius: 10px;
    font-size: 0.85em;
    line-height: 1.5;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
    transition: opacity 0.25s, visibility 0.25s;
    text-align: left;
}

.help-tooltip-content::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 8px solid transparent;
    border-top-color: var(--cs-dark-bg, #16213e);
}

.help-tooltip-container:hover .help-tooltip-content,
.help-tooltip-container.show .help-tooltip-content {
    visibility: visible;
    opacity: 1;
}

.help-tooltip-content .tooltip-title {
    font-weight: 600;
    color: var(--cs-yellow, #ffd700);
    margin-bottom: 8px;
    font-size: 1.05em;
}

.help-tooltip-content .tooltip-section {
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.help-tooltip-content .tooltip-section:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.help-tooltip-content .tooltip-label {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 0.75em;
    font-weight: 600;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.help-tooltip-content .tooltip-label.label-info {
    background: var(--cs-alert-info, #17a2b8);
    color: #ffffff;
}

.help-tooltip-content .tooltip-label.label-advanced {
    background: var(--cs-alert-warning, #ffc107);
    color: var(--cs-dark-bg, #212529);
}

.help-tooltip-content .tooltip-tip {
    background: rgba(23, 162, 184, 0.2);
    border-left: 3px solid var(--cs-alert-info, #17a2b8);
    padding: 6px 10px;
    border-radius: 0 5px 5px 0;
    font-size: 0.9em;
    margin-top: 8px;
}

@media (max-width: 768px) {
    .help-tooltip-content {
        width: 260px;
        left: 0;
        transform: translateX(0);
    }
    .help-tooltip-content::after {
        left: 15px;
        transform: translateX(0);
    }
}

/* Modal positioning fix for mobile (PT-00029)
   On small screens, show modals at the top of the viewport instead of
   vertically centered, so they are always visible and not hidden off-screen. */
@media (max-width: 767.98px) {
  .modal-dialog.modal-dialog-centered {
    align-items: flex-start;
  }
}

/* ===== Cookie Consent Banner ===== */
.cookie-consent-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1060;
    background: linear-gradient(135deg,
      var(--cs-card-bg, #1a1a2e) 0%,
      var(--cs-dark-bg, #16213e) 100%);
    color: var(--cs-text-primary, #f8f9fa);
    padding: 1rem 0;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
    transform: translateY(100%);
    transition: transform 0.3s ease-out;
}

.cookie-consent-banner.cookie-consent-visible {
    transform: translateY(0);
}

.cookie-consent-banner.cookie-consent-hiding {
    transform: translateY(100%);
    transition: transform 0.3s ease-in;
}

.cookie-consent-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
}

.cookie-consent-text {
    flex: 1;
    font-size: 0.9rem;
    line-height: 1.5;
}

.cookie-consent-link {
    color: var(--cs-link-color, #86b7fe);
    text-decoration: underline;
    font-weight: 500;
}

.cookie-consent-link:hover {
    color: var(--cs-link-hover-color, #b6d4fe);
}

.cookie-consent-buttons {
    display: flex;
    gap: 0.75rem;
    flex-shrink: 0;
}

.cookie-consent-btn {
    min-width: 100px;
    font-weight: 500;
    white-space: nowrap;
}

@media (max-width: 767.98px) {
    .cookie-consent-content {
        flex-direction: column;
        text-align: center;
        gap: 1rem;
    }

    .cookie-consent-buttons {
        width: 100%;
        justify-content: center;
    }

    .cookie-consent-btn {
        flex: 1;
        min-width: 0;
    }
}

/* ------------------------------------------------------------------
   PT-00266 follow-up: Agreement checkboxes (Terms / Privacy / EULA).
   On the dark theme the default Bootstrap checkbox is barely visible,
   so users were missing the "I agree" gate before pressing the action
   button next to it. Apply the `.agreement-checkbox` class to any
   "I agree" / "I have read" checkbox on a dark-theme form. The glow
   pulses while unchecked, fades to a calm solid border once checked.
   ------------------------------------------------------------------ */
.agreement-checkbox {
    /* Bigger hit target + brighter outline so the unchecked state
       stands out against the navy card backgrounds. */
    width: 1.35rem;
    height: 1.35rem;
    border: 2px solid var(--cs-primary, #6c5ce7);
    background-color: var(--cs-surface, rgba(255, 255, 255, 0.04));
    box-shadow: 0 0 0 0 rgba(108, 92, 231, 0.55);
    animation: agreement-checkbox-pulse 1.8s ease-in-out infinite;
    cursor: pointer;
    transition: box-shadow 200ms ease, border-color 200ms ease, background-color 200ms ease;
}

.agreement-checkbox:checked {
    /* Calm state once accepted — no pulse, success-coloured border. */
    animation: none;
    border-color: var(--cs-success, #2ecc71);
    box-shadow: 0 0 6px 1px rgba(46, 204, 113, 0.45);
}

.agreement-checkbox:focus {
    outline: none;
    box-shadow: 0 0 0 4px rgba(108, 92, 231, 0.4);
}

@keyframes agreement-checkbox-pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(108, 92, 231, 0.55);
    }
    50% {
        box-shadow: 0 0 8px 4px rgba(108, 92, 231, 0.45);
    }
}

/* Bump the label so the row reads as a single "tap target" — and so
   the user notices it sits next to a glowing control. */
.agreement-checkbox + label,
label.agreement-checkbox-label {
    font-weight: 500;
    margin-left: 0.4rem;
    cursor: pointer;
}

/* Respect users who've opted out of motion. */
@media (prefers-reduced-motion: reduce) {
    .agreement-checkbox {
        animation: none;
        box-shadow: 0 0 6px 1px rgba(108, 92, 231, 0.55);
    }
}

/* ------------------------------------------------------------------
   Radio-button glow. The default Bootstrap radio circle is nearly
   invisible on the dark theme (reported on the onboarding Payment
   billing-cycle chooser). Apply `.radio-glow` to a form-check-input
   radio to give it a brighter outline + brand-color glow that
   brightens to the success color once selected. Mirrors the
   .agreement-checkbox treatment, but a steady glow (no attention
   pulse) — these are an ordinary either/or choice, not a gate.
   ------------------------------------------------------------------ */
.radio-glow {
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid var(--cs-primary, #6c5ce7);
    background-color: var(--cs-surface, rgba(255, 255, 255, 0.04));
    box-shadow: 0 0 6px 1px rgba(108, 92, 231, 0.5);
    cursor: pointer;
    transition: box-shadow 200ms ease, border-color 200ms ease, background-color 200ms ease;
}

/* Leave background-color/-image to Bootstrap on :checked so the inner
   dot still renders; we only brighten the ring + glow. */
.radio-glow:checked {
    border-color: var(--cs-success, #2ecc71);
    box-shadow: 0 0 8px 2px rgba(46, 204, 113, 0.5);
}

.radio-glow:focus {
    outline: none;
    box-shadow: 0 0 0 4px rgba(108, 92, 231, 0.4);
}

