/* ============================================================
   Vivero — Design Tokens & Component Patterns
   Sibling of Entreflor's styles.css; same naming contract.
   ============================================================ */

/* ------------------------------------------------------------
   1. Design Tokens — Color Palette
   Colors defined as RGB channels for Tailwind opacity support.
   Usage: color: rgb(var(--color-primary));
         background: rgb(var(--color-danger) / 0.1);
   ------------------------------------------------------------ */
:root {
  /* Primary */
  --color-primary:        253 141 40;
  --color-primary-hover:  229 122 26;
  --color-primary-active: 204 108 21;
  --color-primary-link:   75 85 99;

  /* Surfaces */
  --color-background:     255 255 255;
  --color-surface:        248 249 250;
  --color-surface-accent: 255 242 230;
  --color-navbar:         16 13 27;
  --color-navbar-hover:   30 26 46;

  /* Text */
  --color-text:           26 26 46;
  --color-text-secondary: 107 114 128;
  --color-text-muted:     156 163 175;
  --color-text-on-dark:   229 229 235;
  --color-text-on-primary:255 255 255;

  /* Borders */
  --color-border:         229 231 235;
  --color-border-focus:   253 141 40;

  /* Feedback */
  --color-success:        22 163 74;
  --color-danger:         220 38 38;
  --color-warning:        217 119 6;
  --color-info:           37 99 235;
}

/* ------------------------------------------------------------
   2. Typography
   ------------------------------------------------------------ */
.font-display {
  font-family: "Outfit", system-ui, sans-serif;
}

.font-mono {
  font-family: "JetBrains Mono", monospace;
}

/* ------------------------------------------------------------
   3. Page Containers
   ------------------------------------------------------------ */
.page-container {
  width: 100%;
  max-width: 1200px;
  margin-inline: auto;
  padding-inline: 1rem;
}

@media (min-width: 768px) {
  .page-container { padding-inline: 1.5rem; }
}

@media (min-width: 1024px) {
  .page-container { padding-inline: 2rem; }
}

/* ------------------------------------------------------------
   4. Sidebar
   ------------------------------------------------------------ */
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 1rem;
  border-left: 3px solid transparent;
  color: rgb(var(--color-text-on-dark));
  text-decoration: none;
  transition: background-color 150ms ease;
}

.sidebar-link:hover {
  background-color: rgb(var(--color-navbar-hover));
}

.sidebar-link.active {
  border-left-color: rgb(var(--color-primary));
  background-color: rgb(var(--color-navbar-hover));
  color: rgb(var(--color-text-on-primary));
}

.sidebar-link.active i {
  color: rgb(var(--color-primary));
}

@media (min-width: 768px) {
  #main-content {
    margin-left: 240px;
    transition: margin-left 300ms ease;
  }

  html.sidebar-is-collapsed #main-content {
    margin-left: 64px;
  }

  html.sidebar-is-collapsed .sidebar {
    width: 64px;
  }

  html.sidebar-is-collapsed .sidebar-brand {
    justify-content: center;
    padding-inline: 0;
  }

  html.sidebar-is-collapsed .sidebar-label {
    display: none;
  }

  html.sidebar-is-collapsed .sidebar-link {
    justify-content: center;
    padding-inline: 0;
  }

  html.sidebar-is-collapsed .sidebar-link i {
    font-size: 1.25rem;
  }

  html.sidebar-is-collapsed .sidebar-user {
    justify-content: center;
    padding-inline: 0;
  }
}

/* ------------------------------------------------------------
   5. Component Patterns
   ------------------------------------------------------------ */

/* 5.1 Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-weight: 500;
  font-family: "DM Sans", system-ui, sans-serif;
  cursor: pointer;
  transition: background-color 150ms ease;
  border: 1px solid transparent;
  line-height: 1.5;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-icon {
  padding: 0.5rem;
  aspect-ratio: 1;
  justify-content: center;
}

.btn-primary {
  background-color: rgb(var(--color-primary));
  color: rgb(var(--color-text-on-primary));
}

.btn-primary:hover:not(:disabled) {
  background-color: rgb(var(--color-primary-hover));
}

.btn-primary:active:not(:disabled) {
  background-color: rgb(var(--color-primary-active));
}

.btn-secondary {
  background-color: transparent;
  color: rgb(var(--color-text));
  border-color: rgb(var(--color-border));
}

.btn-secondary:hover:not(:disabled) {
  background-color: rgb(var(--color-surface));
}

.btn-danger {
  background-color: transparent;
  color: rgb(var(--color-danger));
  border-color: rgb(var(--color-danger));
}

.btn-danger:hover:not(:disabled) {
  background-color: rgb(var(--color-danger) / 0.1);
}

.btn-ghost {
  background-color: transparent;
  color: rgb(var(--color-text-secondary));
  border: none;
}

.btn-ghost:hover:not(:disabled) {
  background-color: rgb(var(--color-surface));
}

/* 5.2 Form Inputs */
.form-input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid rgb(var(--color-border));
  border-radius: 8px;
  font-family: "DM Sans", system-ui, sans-serif;
  font-size: 1rem;
  line-height: 1.5;
  color: rgb(var(--color-text));
  background-color: rgb(var(--color-background));
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.form-input:focus {
  outline: none;
  border-color: rgb(var(--color-border-focus));
  box-shadow: 0 0 0 3px rgb(var(--color-primary) / 0.15);
}

.form-input.is-error {
  border-color: rgb(var(--color-danger));
}

.form-label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: rgb(var(--color-text));
}

.form-helper {
  margin-top: 0.25rem;
  font-size: 0.75rem;
  color: rgb(var(--color-text-muted));
}

.form-helper.is-error {
  color: rgb(var(--color-danger));
}

/* 5.3 Tables */
.table {
  width: 100%;
  border-collapse: collapse;
}

.table th {
  background-color: rgb(var(--color-surface));
  font-weight: 600;
  font-size: 0.875rem;
  text-align: left;
  padding: 0.75rem 1rem;
}

.table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid rgb(var(--color-border));
}

.table tbody tr:hover {
  background-color: rgb(var(--color-surface));
}

/* 5.4 Cards */
.card {
  background-color: rgb(var(--color-background));
  border: 1px solid rgb(var(--color-border));
  border-radius: 8px;
  padding: 1.5rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.card-highlighted {
  background-color: rgb(var(--color-surface-accent));
  border: none;
  border-radius: 8px;
  padding: 1.5rem;
}

/* 5.5 Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1;
}

/* Billing agent required names */
.badge-pending {
  background-color: rgb(var(--color-info) / 0.1);
  color: rgb(var(--color-info));
}

.badge-in-progress,
.badge-in_progress {
  background-color: rgb(var(--color-warning) / 0.12);
  color: rgb(var(--color-warning));
}

.badge-completed {
  background-color: rgb(var(--color-success) / 0.1);
  color: rgb(var(--color-success));
}

.badge-cancelled {
  background-color: rgb(var(--color-danger) / 0.1);
  color: rgb(var(--color-danger));
}

/* Tenant status badges */
.badge-provisioning {
  background-color: rgb(var(--color-info) / 0.1);
  color: rgb(var(--color-info));
}

.badge-ready {
  background-color: rgb(var(--color-success) / 0.1);
  color: rgb(var(--color-success));
}

.badge-failed {
  background-color: rgb(var(--color-danger) / 0.1);
  color: rgb(var(--color-danger));
}

.badge-decommissioned {
  background-color: rgb(var(--color-text-muted) / 0.15);
  color: rgb(var(--color-text-secondary));
}

.badge-suspended {
  background-color: rgb(var(--color-warning) / 0.12);
  color: rgb(var(--color-warning));
}

/* Operation status badges */
.badge-op-pending {
  background-color: rgb(var(--color-info) / 0.1);
  color: rgb(var(--color-info));
}

.badge-op-running {
  background-color: rgb(var(--color-warning) / 0.12);
  color: rgb(var(--color-warning));
}

.badge-op-succeeded {
  background-color: rgb(var(--color-success) / 0.1);
  color: rgb(var(--color-success));
}

.badge-op-failed {
  background-color: rgb(var(--color-danger) / 0.1);
  color: rgb(var(--color-danger));
}

/* Billing mode badges */
.badge-trial {
  background-color: rgb(var(--color-info) / 0.1);
  color: rgb(var(--color-info));
}

.badge-manual {
  background-color: rgb(var(--color-text-muted) / 0.15);
  color: rgb(var(--color-text-secondary));
}

.badge-stripe {
  background-color: rgb(99 91 255 / 0.1);
  color: rgb(99 91 255);
}

/* 5.6 Empty States */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1.5rem;
  text-align: center;
}

.empty-state i {
  font-size: 2.5rem;
  color: rgb(var(--color-text-muted));
  margin-bottom: 1rem;
}

.empty-state p {
  color: rgb(var(--color-text-secondary));
  margin-bottom: 1.5rem;
}

/* 5.8 Confirmation Dialog */
.dialog-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 60;
}

.dialog-card {
  background-color: rgb(var(--color-background));
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  width: 100%;
  max-width: 400px;
  margin: 1rem;
}

/* 5.9 Toast Notifications */
.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 70;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  background-color: rgb(var(--color-background));
  border-radius: 8px;
  padding: 1rem 1.25rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  border-left: 4px solid rgb(var(--color-info));
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 300px;
  max-width: 420px;
}

.toast-success { border-left-color: rgb(var(--color-success)); }
.toast-error   { border-left-color: rgb(var(--color-danger)); }
.toast-warning { border-left-color: rgb(var(--color-warning)); }

/* ------------------------------------------------------------
   6. Sidebar animations
   ------------------------------------------------------------ */
.sidebar-enter {
  animation: sidebar-slide-in 300ms ease forwards;
}

.sidebar-exit {
  animation: sidebar-slide-out 300ms ease forwards;
}

@keyframes sidebar-slide-in {
  from { transform: translateX(-100%); }
  to   { transform: translateX(0); }
}

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

/* ------------------------------------------------------------
   7. Alert box (used in tenant_created password display)
   ------------------------------------------------------------ */
.alert-warning {
  background-color: rgb(var(--color-warning) / 0.08);
  border: 1px solid rgb(var(--color-warning) / 0.3);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  color: rgb(var(--color-text));
}

.alert-info {
  background-color: rgb(var(--color-info) / 0.08);
  border: 1px solid rgb(var(--color-info) / 0.3);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  color: rgb(var(--color-text));
}
