/*
 * 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.
 */

/* Global sizing for buttons and inputs to ensure consistent UI */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  padding: 0 16px;
  font-weight: 600;
  font-size: 0.875rem;
  line-height: 1;
  color: #ffffff;
  border-radius: 0.5rem;
  text-decoration: none;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease-in-out;
}

.btn-primary {
  background-color: #00b88a;
}

.btn-primary:hover {
  background-color: #00a17a;
}

.btn-gray {
  background-color: #ffffff;
  color: #334155;
  border: 1px solid #d1d5db;
}

.btn-gray:hover {
  background-color: #f9fafb;
}

.btn-secondary {
  background-color: #0ea5e9;
}

.btn-secondary:hover {
  background-color: #0284c7;
}

.btn-danger {
  background-color: #dc2626;
}

.btn-danger:hover {
  background-color: #b91c1c;
}

.btn-sm {
  height: 32px;
  padding: 0 12px;
  font-size: 0.75rem;
}

.input {
  min-height: 40px;
  padding-top: 0;
  padding-bottom: 0;
  padding-left: 12px;
  padding-right: 12px;
  font-size: 0.875rem;
  color: #0f172a;
  border: 1px solid #d1d5db;
  /* border-gray-300 */
  border-radius: 0.5rem;
  width: 100%;
  background-color: #ffffff;
  line-height: 1.4;
  transition: all 0.2s ease-in-out;
}

.input:focus {
  border-color: #00b88a;
  outline: 2px solid #00b88a;
  outline-offset: 0;
  box-shadow: 0 0 0 3px rgba(0, 184, 138, 0.15);
}

/* Custom select styling to avoid default browser look and match project UI */
select.input {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'><path stroke-linecap='round' stroke-linejoin='round' d='M19 9l-7 7-7-7'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px 16px;
  padding-right: 36px;
  cursor: pointer;
}

select.input:hover {
  border-color: #9ca3af;
  /* gray-400 */
}

select.input:disabled {
  background-color: #f3f4f6;
  /* gray-100 */
  color: #9ca3af;
  /* gray-400 */
  cursor: not-allowed;
}

textarea.input {
  min-height: 120px;
  padding: 10px 12px;
  line-height: 1.5;
  resize: vertical;
}

/* Modal animations */
@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes fadeOut {
  from {
    opacity: 1;
  }

  to {
    opacity: 0;
  }
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideOut {
  from {
    opacity: 1;
    transform: translateY(0);
  }

  to {
    opacity: 0;
    transform: translateY(20px);
  }
}

.animate-fade-in {
  animation: fadeIn 0.2s ease-out;
}

.animate-fade-out {
  animation: fadeOut 0.2s ease-out;
}

.animate-slide-in {
  animation: slideIn 0.2s ease-out;
}

.animate-slide-out {
  animation: slideOut 0.2s ease-out;
}

/* Drawer slide-in-right animations */
@keyframes slideInRight {
  from {
    transform: translateX(100%);
  }

  to {
    transform: translateX(0);
  }
}

@keyframes slideOutRight {
  from {
    transform: translateX(0);
  }

  to {
    transform: translateX(100%);
  }
}

.animate-slide-in-right {
  animation: slideInRight 0.3s ease-out;
}

.animate-slide-out-right {
  animation: slideOutRight 0.3s ease-out forwards;
}

/* Confirm dialog animations */
@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes scaleOut {
  from {
    opacity: 1;
    transform: scale(1);
  }

  to {
    opacity: 0;
    transform: scale(0.95);
  }
}

.animate-scale-in {
  animation: scaleIn 0.2s ease-out;
}

.animate-scale-out {
  animation: scaleOut 0.15s ease-in forwards;
}

/* Drawer responsive positioning - pinned to right edge, 50% of main block width */
.drawer-panel {
  left: auto !important;
  right: 0 !important;
}

/* Collapsible sidebar widths */
[data-sidebar-target="sidebar"][data-collapsed="true"] {
  width: 5rem !important;
}

/* Tooltips */
[data-tooltip] {
  position: relative;
  display: inline-flex;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-bottom: 0.375rem;
  padding: 0.375rem 0.625rem;
  background: #0f172a;
  color: #f9fafb;
  border-radius: 0.375rem;
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1.25;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.1s ease;
  z-index: 50;
}

[data-tooltip]::before {
  content: "";
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-bottom: -0.125rem;
  border: 4px solid transparent;
  border-top-color: #0f172a;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.1s ease;
  z-index: 50;
}

[data-tooltip]:hover::after,
[data-tooltip]:hover::before {
  opacity: 1;
  transform: translateX(-50%);
}

/* Bottom-positioned tooltips (for elements near top edge like sticky thead) */
[data-tooltip-position="bottom"]::after {
  bottom: auto;
  top: 100%;
  margin-bottom: 0;
  margin-top: 0.375rem;
}

[data-tooltip-position="bottom"]::before {
  bottom: auto;
  top: 100%;
  margin-bottom: 0;
  margin-top: -0.125rem;
  border-top-color: transparent;
  border-bottom-color: #0f172a;
}

/* Right-aligned tooltips (for elements near right edge) */
[data-tooltip-align="right"]::after {
  left: auto;
  right: 0;
  transform: none;
}

[data-tooltip-align="right"]::before {
  left: auto;
  right: 8px;
  transform: none;
}

[data-tooltip-align="right"]:hover::after,
[data-tooltip-align="right"]:hover::before {
  transform: none;
}

/* Sidebar tooltips: show to the right only when collapsed */
[data-sidebar-target="sidebar"] .sidebar-tooltip::after,
[data-sidebar-target="sidebar"] .sidebar-tooltip::before {
  display: none;
}

[data-sidebar-target="sidebar"][data-collapsed="true"] .sidebar-tooltip::after {
  display: block;
  bottom: auto;
  left: 100%;
  top: 50%;
  transform: translateY(-50%);
  margin-left: 0.5rem;
  margin-bottom: 0;
  font-size: 0.85rem;
}

[data-sidebar-target="sidebar"][data-collapsed="true"] .sidebar-tooltip::before {
  display: block;
  bottom: auto;
  left: 100%;
  top: 50%;
  transform: translateY(-50%);
  margin-left: -0.125rem;
  margin-bottom: 0;
  border: 4px solid transparent;
  border-right-color: #0f172a;
  border-top-color: transparent;
}

[data-sidebar-target="sidebar"][data-collapsed="true"] .sidebar-tooltip:hover::after {
  opacity: 1;
  transform: translate(0.1rem, -50%);
}

[data-sidebar-target="sidebar"][data-collapsed="true"] .sidebar-tooltip:hover::before {
  opacity: 1;
  transform: translate(0.1rem, -50%);
}

/* JSON syntax highlighting */
pre[style*="font-family"] {
  color: #1f2937;
}

pre[style*="font-family"]:has-text {
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* Basic JSON highlighting via regex would require JavaScript,
   but we can style the container for better readability */
pre.json-payload {
  background-color: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 0.375rem;
  padding: 0.75rem;
  font-size: 0.75rem;
  line-height: 1.5;
  max-height: 16rem;
  overflow: auto;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace;
}

.sidebar-link-active {
  background-color: #00b88a !important;
  color: #ffffff !important;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
}

.sidebar-link-active svg {
  color: #ffffff !important;
}

/* Time picker drum (horizontal) */
.time-picker {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 4px;
  user-select: none;
}

.time-picker__arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  color: #6b7280;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
  flex-shrink: 0;
}

.time-picker__arrow:hover {
  background-color: #f3f4f6;
  color: #111827;
}

.time-picker__arrow:active {
  background-color: #e5e7eb;
}

.time-picker__track {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0;
  position: relative;
  height: 44px;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
}

.time-picker__track:active {
  cursor: grabbing;
}

.time-picker__track::before,
.time-picker__track::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 32px;
  z-index: 1;
  pointer-events: none;
}

.time-picker__track::before {
  left: 0;
  background: linear-gradient(to right, rgba(255,255,255,1) 0%, rgba(255,255,255,0) 100%);
}

.time-picker__track::after {
  right: 0;
  background: linear-gradient(to left, rgba(255,255,255,1) 0%, rgba(255,255,255,0) 100%);
}

.time-picker__item {
  text-align: center;
  border-radius: 10px;
  font-variant-numeric: tabular-nums;
  transition: all 0.15s ease;
  line-height: 44px;
  white-space: nowrap;
  flex-shrink: 0;
}

.time-picker__item--active {
  font-size: 1.25rem;
  font-weight: 700;
  color: #00b88a;
  padding: 0 12px;
  background-color: #f0fdf9;
  border: 1.5px solid #99e9d2;
  line-height: 40px;
  border-radius: 10px;
}

.time-picker__item--near {
  font-size: 0.875rem;
  font-weight: 500;
  color: #6b7280;
  padding: 0 10px;
  cursor: pointer;
}

.time-picker__item--near:hover {
  color: #374151;
}

.time-picker__item--far {
  font-size: 0.75rem;
  font-weight: 400;
  color: #d1d5db;
  padding: 0 8px;
  cursor: pointer;
}

.time-picker__item--far:hover {
  color: #9ca3af;
}

/* Schedule row — one-line layout with responsive wrap */
.schedule-row {
  display: flex;
  align-items: center;
  gap: 0;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  overflow: hidden;
  flex-wrap: wrap;
}

.schedule-row__section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 16px;
  border-right: 1px solid #e5e7eb;
  flex-shrink: 0;
}

.schedule-row__section:last-child {
  border-right: none;
}

.schedule-row__section--toggle {
  flex-direction: row;
  align-items: center;
  gap: 10px;
}

.schedule-row__section--time {
  flex: 1;
  min-width: 0;
}

.schedule-row__label {
  font-size: 0.65rem;
  font-weight: 700;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
  margin: 0;
}

/* Day picker pills */
.day-picker {
  display: flex;
  gap: 5px;
}

.day-picker__pill {
  position: relative;
  cursor: pointer;
  user-select: none;
}

.day-picker__input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.day-picker__label {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 0.7rem;
  font-weight: 600;
  background-color: #f3f4f6;
  color: #6b7280;
  transition: background-color 0.15s, color 0.15s, transform 0.1s;
}

.day-picker__pill:hover .day-picker__label {
  background-color: #e5e7eb;
  color: #374151;
}

.day-picker__input:checked + .day-picker__label {
  background-color: #00b88a;
  color: #ffffff;
}

.day-picker__pill:hover .day-picker__input:checked + .day-picker__label {
  background-color: #00a17a;
}

.day-picker__pill:active .day-picker__label {
  transform: scale(0.92);
}

/* Region pills — same style as day-picker but text-based (variable width) */
.region-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  height: 28px;
  border-radius: 14px;
  font-size: 0.75rem;
  font-weight: 600;
  background-color: #f3f4f6;
  color: #6b7280;
  cursor: pointer;
  user-select: none;
  border: none;
  transition: background-color 0.15s, color 0.15s, transform 0.1s;
  white-space: nowrap;
}

.region-pill:hover {
  background-color: #e5e7eb;
  color: #374151;
}

.region-pill--active {
  background-color: #00b88a;
  color: #ffffff;
}

.region-pill--active:hover {
  background-color: #00a17a;
}

.region-pill:active {
  transform: scale(0.93);
}

/* iOS-style toggle */
.ios-toggle {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  flex-shrink: 0;
}

.ios-toggle__input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.ios-toggle__track {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 26px;
  border-radius: 13px;
  background-color: #d1d5db;
  transition: background-color 0.2s ease;
}

.ios-toggle__thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background-color: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2), 0 1px 2px rgba(0, 0, 0, 0.12);
  transition: transform 0.2s ease;
}

.ios-toggle__input:checked + .ios-toggle__track {
  background-color: #00b88a;
}

.ios-toggle__input:checked + .ios-toggle__track .ios-toggle__thumb {
  transform: translateX(18px);
}

.ios-toggle__input:focus-visible + .ios-toggle__track {
  outline: 2px solid #00b88a;
  outline-offset: 2px;
}

/* Schedule card layout */
.schedule-card {
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  overflow: hidden;
}

.schedule-card__toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid #e5e7eb;
}

.schedule-card__body {
  display: flex;
  flex-direction: column;
}

.schedule-card__body.hidden {
  display: none;
}

.schedule-card__section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 16px;
  flex-shrink: 0;
}

.schedule-card__divider {
  width: 1px;
  align-self: stretch;
  background-color: #e5e7eb;
  flex-shrink: 0;
}

/* Settings drawer sections */
.settings-drawer__section {
  padding-bottom: 1.25rem;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid #f3f4f6;
}

.settings-drawer__section:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.settings-drawer__section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  width: 100%;
  text-align: left;
}

.settings-drawer__section-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: #374151;
}

.settings-drawer__section-count {
  font-size: 0.75rem;
  font-weight: 400;
  color: #9ca3af;
  margin-left: 0.25rem;
}

.settings-drawer__add-row {
  margin-bottom: 0.75rem;
}

.settings-drawer__source-row {
  padding: 0.75rem 0;
}

.settings-drawer__source-row:first-child {
  padding-top: 0;
}

.settings-drawer__member-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 0;
}

/* Region toggle — ios toggle + label inline */
.settings-drawer__region-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  user-select: none;
}

.settings-drawer__region-label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: #374151;
}
