/*
 * Orbit MVNO Portal - Main Application Styles
 */

/* Animation keyframes */
@keyframes slide-in {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes slide-out {
  from { transform: translateX(0); opacity: 1; }
  to { transform: translateX(100%); opacity: 0; }
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes pulse-ring {
  0% { transform: scale(0.95); opacity: 1; }
  50% { transform: scale(1.05); opacity: 0.7; }
  100% { transform: scale(0.95); opacity: 1; }
}

.animate-slide-in { animation: slide-in 0.3s ease-out; }
.animate-slide-out { animation: slide-out 0.3s ease-in; }
.animate-fade-in { animation: fade-in 0.2s ease-out; }
.animate-pulse-ring { animation: pulse-ring 2s ease-in-out infinite; }

/* Activation celebration: a brief confetti burst when a line goes active.
   Pieces are injected by activation_celebration_controller.js, which sets each
   one's colour, offset and delay, and skips the burst entirely when the viewer
   prefers reduced motion. */
@keyframes confetti-fall {
  0% { transform: translateY(-10%) rotate(0deg); opacity: 1; }
  100% { transform: translateY(320px) rotate(540deg); opacity: 0; }
}

@keyframes pop-in {
  0% { transform: scale(0.6); opacity: 0; }
  70% { transform: scale(1.08); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

.confetti-piece {
  position: absolute;
  top: 0;
  width: 8px;
  height: 14px;
  border-radius: 2px;
  animation-name: confetti-fall;
  animation-timing-function: ease-in;
  animation-fill-mode: forwards;
}

.animate-pop-in { animation: pop-in 0.45s cubic-bezier(0.34, 1.56, 0.64, 1); }

@media (prefers-reduced-motion: reduce) {
  .animate-pop-in { animation: none; }
  .confetti-piece { display: none; }
}

/* Custom scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Select dropdown arrow positioning */
select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23334155' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 1.25rem;
  padding-right: 2.5rem;
}

/* Form input focus states with brand color.

   Text-like fields only. A radio or checkbox keeps :focus after the click that
   checked it, and this glow is a square, so on a round control it drew a box
   beside every selection; those controls get a keyboard-only ring below instead.
   This file is unlayered, so a Tailwind utility on the element cannot override it
   — the exclusion has to live here. */
input:not([type="radio"]):not([type="checkbox"]):focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-primary) 15%, transparent);
}

input[type="radio"]:focus-visible,
input[type="checkbox"]:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--color-primary) 60%, transparent);
  outline-offset: 2px;
}

/* Button hover states */
button:not(:disabled):hover,
.btn:not(:disabled):hover {
  transform: translateY(-1px);
}

button:not(:disabled):active,
.btn:not(:disabled):active {
  transform: translateY(0);
}

/* Dialog centering */
dialog[open] {
  margin: auto;
}

/*
 * Sheet dialogs: full-screen sheet on phones, centered 640px panel from `sm` up.
 * Layout properties stay behind [open] so the author `display: flex` can never
 * override the UA `dialog:not([open]) { display: none }` rule and leak a closed
 * dialog onto the page. Mark the scrolling region `[data-dialog-body]`; anything
 * outside it (header/footer) stays put while that region scrolls.
 *
 * The sheet is sized twice over because a modal dialog is a positioned box: the UA
 * stylesheet gives `dialog:modal` `position: fixed` with *both* block insets at 0,
 * and an auto height between two resolved insets means "stretch to fill", not "fit
 * the content". So the desktop rule below asks for fit-content explicitly, and
 * leaves the margins auto to centre what that produces.
 */
dialog.dialog-sheet[open] {
  display: flex;
  flex-direction: column;
  width: 100vw;
  max-width: 100vw;
  height: 100dvh;
  max-height: 100dvh;
  margin: 0;
  padding: 0;
  border-radius: 0;
  overflow: hidden;
}

.dialog-sheet > form,
.dialog-sheet > [data-dialog-panel] {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}

/* A dialog whose body and footer live in a Turbo Frame (so one step can swap them
   in place) keeps the same column: the frame is a flex item that passes the
   flexibility down, or the body inside it would never scroll. */
.dialog-sheet > form > turbo-frame,
.dialog-sheet > [data-dialog-panel] > turbo-frame {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}

.dialog-sheet [data-dialog-body] {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.dialog-sheet [data-dialog-header],
.dialog-sheet [data-dialog-footer] {
  flex: 0 0 auto;
}

@media (min-width: 40rem) {
  dialog.dialog-sheet[open] {
    width: 100%;
    max-width: 640px;
    /* Not `auto`: see above. A short dialog ends under its own footer instead of
       spanning the viewport with the flexible body absorbing the slack. */
    height: fit-content;
    /* A long one still caps at the viewport and scrolls [data-dialog-body]. The
       margins are auto rather than `2rem auto` so the sheet is centred on both
       axes; at the cap they resolve to the 2rem of breathing room this subtracts. */
    max-height: calc(100dvh - 4rem);
    margin: auto;
    border-radius: 1rem;
  }
}

/* Card styles */
.card {
  background: white;
  border-radius: 1rem;
  box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
}

.card-hover {
  transition: all 0.2s ease;
}

.card-hover:hover {
  box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  transform: translateY(-2px);
}

/* Donut chart center text positioning */
.chart-center-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}

/* Status indicators */
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.status-active { background-color: #10b981; }
.status-pending { background-color: #f59e0b; }
.status-suspended { background-color: #ef4444; }
.status-inactive { background-color: #6b7280; }

/* Loading spinner */
.spinner {
  border: 2px solid #f3f4f6;
  border-top-color: var(--color-primary);
  border-radius: 50%;
  width: 20px;
  height: 20px;
  animation: spin 0.8s linear infinite;
}

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