@tailwind base;
@tailwind components;
@tailwind utilities;

@layer base {
  :root {
    --surface-page: 249 250 251;
    --surface-card: 255 255 255;
    --surface-subtle: 249 250 251;
    --surface-muted: 243 244 246;
    --surface-brand: 238 242 255;
    --line-subtle: 243 244 246;
    --line-default: 229 231 235;
    --line-strong: 209 213 219;
    --ink-primary: 17 24 39;
    --ink-secondary: 55 65 81;
    --ink-muted: 107 114 128;
    --ink-placeholder: 156 163 175;
    --ink-brand: 79 70 229;
    --action: 79 70 229;
    --action-hover: 67 56 202;
    --action-on: 255 255 255;
    --focus-ring: 99 102 241;

    --success-subtle: 247 254 231;
    --success-line: 217 249 157;
    --success-ink: 63 98 18;
    --success-solid: 77 124 15;
    --success-on: 255 255 255;
    --pending-subtle: 255 251 235;
    --pending-line: 253 230 138;
    --pending-ink: 146 64 14;
    --pending-solid: 217 119 6;
    --pending-on: 17 24 39;
    --warning-subtle: 255 247 237;
    --warning-line: 254 215 170;
    --warning-ink: 154 52 18;
    --warning-solid: 194 65 12;
    --warning-on: 255 255 255;
    --danger-subtle: 255 241 242;
    --danger-line: 254 205 211;
    --danger-ink: 190 18 60;
    --danger-solid: 225 29 72;
    --danger-on: 255 255 255;
    --info-subtle: 238 242 255;
    --info-line: 199 210 254;
    --info-ink: 67 56 202;
    --info-solid: 79 70 229;
    --info-on: 255 255 255;
    --neutral-subtle: 243 244 246;
    --neutral-line: 229 231 235;
    --neutral-ink: 55 65 81;
    --neutral-solid: 75 85 99;
    --neutral-on: 255 255 255;

    --duration-fast: 120ms;
    --duration-base: 180ms;
    --duration-slow: 240ms;
    --ease-out-soft: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-in-soft: cubic-bezier(0.4, 0, 1, 1);
  }

  html {
    -webkit-text-size-adjust: 100%;
  }

  body {
    @apply bg-surface-page text-ink-primary antialiased;
    font-feature-settings: "cv11", "ss01";
  }

  :focus-visible {
    outline: 2px solid rgb(var(--focus-ring));
    outline-offset: 2px;
  }
}

@layer components {
  .num {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
  }

  .glass {
    background-color: rgb(255 255 255 / 0.8);
    background-image: linear-gradient(90deg, rgb(255 255 255 / 0.85) 0%, rgb(224 231 255 / 0.85) 55%, rgb(237 233 254 / 0.9) 100%);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border-color: rgb(199 210 254 / 0.7);
  }

  @supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    .glass {
      background-color: rgb(255 255 255);
      background-image: linear-gradient(90deg, rgb(255 255 255) 0%, rgb(224 231 255) 55%, rgb(237 233 254) 100%);
    }
  }

  @media (prefers-reduced-transparency: reduce) {
    .glass {
      background-color: rgb(255 255 255);
      background-image: linear-gradient(90deg, rgb(255 255 255) 0%, rgb(224 231 255) 55%, rgb(237 233 254) 100%);
      -webkit-backdrop-filter: none;
      backdrop-filter: none;
    }
  }
}

@layer components {
  [data-confirm-modal-target="submitButton"][data-tone="default"] { @apply bg-action text-action-on hover:bg-action-hover; }
  [data-confirm-modal-target="submitButton"][data-tone="warning"] { @apply bg-warning-solid text-warning-on hover:bg-orange-800; }
  [data-confirm-modal-target="submitButton"][data-tone="danger"] { @apply bg-danger-solid text-danger-on hover:bg-rose-700; }
  [data-confirm-modal-target="iconWarning"][data-tone="danger"] { @apply bg-danger-subtle text-danger-ink; }
}

@layer components {
  @keyframes overlay-in { from { opacity: 0; } to { opacity: 1; } }
  @keyframes dialog-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
  @keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
  @keyframes pop-in { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: none; } }

  [data-modal]:not(.hidden) { animation: overlay-in var(--duration-base) var(--ease-out-soft); }
  [data-modal]:not(.hidden) > * { animation: dialog-in var(--duration-slow) var(--ease-out-soft); }
  [data-toast] { animation: toast-in var(--duration-base) var(--ease-out-soft); }
  [data-dropdown-panel]:not(.hidden) { animation: pop-in var(--duration-base) var(--ease-out-soft); transform-origin: top right; }

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

  [data-pending-feedback].is-pending { pointer-events: none; cursor: progress; opacity: 0.85; }
  [data-pending-feedback].is-pending::before {
    content: "";
    flex: none;
    width: 1rem;
    height: 1rem;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 9999px;
    animation: pending-spin 700ms linear infinite;
  }
  [data-pending-feedback][data-pending-icon].is-pending > * { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 100ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 100ms !important;
    scroll-behavior: auto !important;
  }

  [data-pending-feedback].is-pending::before {
    animation-duration: 1400ms !important;
    animation-iteration-count: infinite !important;
  }
}

/* TomSelect - Match form input styling */
.ts-wrapper {
  @apply mt-1;
  width: 100% !important;
}

.ts-wrapper .ts-control {
  @apply block w-full rounded-md border-gray-300 shadow-sm py-2 px-3 text-base;
  @apply focus:border-indigo-500 focus:ring-indigo-500;
  background-image: none !important;
  min-height: 42px;
  height: auto;
}

/* Selected item as blue badge with X */
.ts-wrapper .ts-control .item {
  @apply bg-indigo-100 text-indigo-800 rounded-md px-2 py-1 text-sm font-medium inline-flex items-center gap-1;
}

.ts-wrapper .ts-control .item .remove {
  @apply text-indigo-600 hover:text-indigo-800 cursor-pointer ml-1;
  font-size: 14px;
  line-height: 1;
}

.ts-wrapper .ts-control .item .remove:hover {
  @apply text-red-600;
}

.ts-wrapper.focus .ts-control {
  @apply border-indigo-500 ring-1 ring-indigo-500;
}

.ts-wrapper .ts-control input {
  @apply text-base flex-grow;
  width: 100% !important;
}

.ts-wrapper .ts-control input::placeholder {
  @apply text-gray-400;
  text-overflow: ellipsis;
}

.ts-wrapper .ts-dropdown {
  @apply mt-1 rounded-md border border-gray-300 shadow-lg bg-white z-50;
}

.ts-wrapper .ts-dropdown .ts-dropdown-content {
  @apply max-h-60 overflow-y-auto;
}

.ts-wrapper .ts-dropdown .option {
  @apply py-2 px-3 text-sm text-gray-900 cursor-pointer;
}

.ts-wrapper .ts-dropdown .option:hover,
.ts-wrapper .ts-dropdown .option.active {
  @apply bg-indigo-50 text-indigo-900;
}

.ts-wrapper .ts-dropdown .option.selected {
  @apply bg-indigo-100;
}

.ts-wrapper .ts-dropdown .create {
  @apply py-2 px-3 text-sm text-indigo-600 font-medium cursor-pointer border-t border-gray-200;
}

.ts-wrapper .ts-dropdown .create:hover {
  @apply bg-indigo-50;
}

.ts-wrapper .ts-dropdown .no-results {
  @apply py-2 px-3 text-sm text-gray-500;
}

/* Trix editor customizations - Word-like look, A4 size */
trix-editor {
  width: 100%;
  min-height: 1000px; /* Approximate A4 content height */
  padding: 60px 80px;
  margin: 0 auto;
  background-color: white;
  box-shadow: none;
  font-family: Arial, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: #000;
  border: none !important;
  outline: none !important;
}

trix-toolbar {
  @apply mb-4;
  background: white;
  padding: 8px 12px;
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

trix-toolbar .trix-button-group {
  @apply border-gray-200;
}

/* Trix editor content styles */
trix-editor h1 {
  font-size: 24px;
  font-weight: bold;
  margin-bottom: 16px;
  margin-top: 24px;
  color: #000;
}

trix-editor strong {
  font-weight: bold;
}

trix-editor em {
  font-style: italic;
}

trix-editor del {
  text-decoration: line-through;
}

trix-editor a {
  color: #4f46e5;
  text-decoration: underline;
}

trix-editor blockquote {
  border-left: 4px solid #d1d5db;
  padding-left: 16px;
  font-style: italic;
  color: #4b5563;
  margin: 16px 0;
}

trix-editor pre {
  background: #f3f4f6;
  padding: 16px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 11px;
  overflow-x: auto;
  margin: 16px 0;
}

trix-editor ul {
  list-style-type: disc;
  list-style-position: inside;
  margin: 8px 0 8px 16px;
}

trix-editor ol {
  list-style-type: decimal;
  list-style-position: inside;
  margin: 8px 0 8px 16px;
}

trix-editor li {
  margin: 4px 0;
}

trix-editor p {
  margin-bottom: 8px;
}

/* Contract Preview - Force black text */
.contract-preview-content,
.contract-preview-content * {
  color: #000 !important;
}

/* Trix Editor Styling - Indigo toolbar */
.trix-editor-wrapper trix-toolbar {
  @apply bg-indigo-50 border-indigo-200;
}

.trix-editor-wrapper trix-toolbar .trix-button-group {
  @apply border-indigo-200;
}

.trix-editor-wrapper trix-toolbar .trix-button {
  @apply text-gray-700 hover:bg-indigo-100;
}

.trix-editor-wrapper trix-toolbar .trix-button.trix-active {
  @apply bg-indigo-200 text-indigo-900;
}

.trix-editor-wrapper trix-editor {
  @apply bg-white;
}
/*
 * This is a manifest file that'll be compiled into application.css, which will include all the files
 * listed below.
 *
 * Any CSS (and SCSS, if configured) file within this directory, lib/assets/stylesheets, or any plugin's
 * vendor/assets/stylesheets directory can be referenced here using a relative path.
 *
 * You're free to add application-wide styles to this file and they'll appear at the bottom of the
 * compiled file so the styles you add here take precedence over styles defined in any other CSS
 * files in this directory. Styles in this file should be added after the last require_* statement.
 * It is generally better to create a new file per style scope.
 *


 */
