/* ========================================
   Design Tokens - Single Source of Truth
   ======================================== */

:root {
    /* ---- Text ---- */
    --text-primary: #111827;
    --text-secondary: #374151;
    --text-tertiary: #4b5563;
    --text-muted: #6b7280;
    --text-placeholder: #9ca3af;
    --text-faint: #d1d5db;
    /*---- Buttons ----*/
    --text-btnprimary: #ffffff;
    --font-btnsize: 14px;
    --font-btnweight: 500;
    /* ---- Backgrounds ---- */
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --bg-tertiary: #f3f4f6;
    --bg-quaternary: #e5e7eb;
    /* ---- Borders ---- */
    --border-primary: #e5e7eb;
    --border-secondary: #f3f4f6;
    --border-strong: #d1d5db;
    /* ---- Brand / Primary ---- */
    --color-primary: #2563eb;
    --color-primary-hover: #1d4ed8;
    --color-primary-light: #0284c7;
    --color-primary-bg: #dbeafe;
    --color-primary-bg-subtle: #eff6ff;
    --color-primary-gradient: linear-gradient(135deg, #2563eb 0%, #0284c7 100%);
    /* ---- Success ---- */
    --color-success: #059669;
    --color-success-text: #065f46;
    --color-success-light: #16a34a;
    --color-success-bg: #d1fae5;
    --color-success-bg-subtle: #f0fdf4;
    --color-success-border: #bbf7d0;
    /* ---- Warning ---- */
    --color-warning: #f59e0b;
    --color-warning-hover: #d97706;
    --color-warning-text: #92400e;
    --color-warning-bg: #fef3c7;
    /* ---- Danger ---- */
    --color-danger: #dc2626;
    --color-danger-hover: #b91c1c;
    --color-danger-dark: #991b1b;
    --color-danger-bg: #fee2e2;
    --color-danger-bg-subtle: #fef2f2;
    --color-danger-border: #fecaca;
    /* ---- Info ---- */
    --color-info: #3b82f6;
    --color-info-text: #1e40af;
    --color-info-bg: #dbeafe;
    /* ---- Purple (accent) ---- */
    --color-purple: #7c3aed;
    --color-purple-bg: #ede9fe;
    --color-indigo: #4f46e5;
    --color-indigo-bg: #e0e7ff;
    /* ---- Shadows ---- */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    --shadow-focus: 0 0 0 3px rgba(37, 99, 235, 0.1);
    --shadow-primary: 0 4px 12px rgba(37, 99, 235, 0.4);
    /* ---- Border Radius ---- */
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;
    --radius-xl: 12px;
    --radius-2xl: 16px;
    --radius-full: 9999px;
    /* ---- Font Family ---- */
    --font-sans: -apple-system, BlinkMacSystemFont, Helvetica, Arial, sans-serif;
}

/* ============================================================================
   Buttons — canonical styling (single source of truth)
   ============================================================================
   These rules match the "New Clause" button on the Clauses page, which is the
   reference design per CLAUDE.md's ##UI Design## section. Every primary
   "create" action across the app (New Template, New Letter, New Clause,
   New Rule, New Flow, Create User) uses .btn .btn-primary .btn-sm.

   Page-level CSS should NOT redefine .btn / .btn-primary / .btn-sm. If a
   surface needs a variant, add a new modifier class instead (e.g.
   .btn-ai-suggest-sm, .btn-icon-only).

   Many page CSS files currently still have their own .btn-primary rules that
   override these — those should be removed in a follow-up consolidation pass,
   page by page, so this becomes the only definition.
   ============================================================================ */

/* Base shape applied to .btn AND every variant — so the colored variants
   work standalone (e.g. <button class="btn-primary">) without needing the
   .btn base class. Without this grouped selector, the variant-only buttons
   end up with browser-default square corners. */
.btn,
.btn-primary,
.btn-secondary,
.btn-danger,
.btn-success,
.btn-outline-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: var(--radius-lg);          /* 8px */
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 500;
    line-height: 1;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
    border: none;
    white-space: nowrap;
}

.btn {
    color: var(--text-primary);
    background: transparent;
}

.btn:disabled,
.btn[disabled],
.btn-primary:disabled,
.btn-secondary:disabled,
.btn-danger:disabled,
.btn-success:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ---- Primary — gradient Engage blue, lifts on hover for a smoother feel.
   Matches the visual treatment of .btn-success in the template editor so
   action-bar buttons (Save / Submit / Send for Review / Send for Signature)
   all read as the same family. The flat solid variant is kept on .btn-sm
   .btn-primary for compact create-action buttons (New Clause, etc.). ---- */
.btn-primary {
    background: var(--color-primary-gradient);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

.btn-primary:disabled {
    transform: none;
    box-shadow: none;
}

/* ---- Secondary — outlined / muted, same lift-on-hover for parity ---- */
.btn-secondary {
    background: white;
    color: var(--text-secondary);
    border: 1px solid var(--border-primary);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--bg-secondary);
    border-color: var(--text-faint);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

.btn-secondary:disabled {
    transform: none;
    box-shadow: none;
}

/* ---- Danger / destructive ---- */
.btn-danger {
    background: var(--color-danger);
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background: var(--color-danger-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.35);
}

.btn-danger:disabled {
    transform: none;
    box-shadow: none;
}

/* ---- Success — green gradient. Used by the "Submit" button on the Letter
   Review action bar and the "Approve" button on multiple surfaces. ---- */
.btn-success {
    background: linear-gradient(135deg, #22c55e, var(--color-success-light));
    color: white;
}

.btn-success:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.4);
}

.btn-success:disabled {
    transform: none;
    box-shadow: none;
}

/* ---- Small size modifier — keeps the flat-solid New Clause look ---- */
.btn-sm {
    gap: 6px;
    padding: 6px 12px;
    font-size: 12px;
    border-radius: var(--radius-md);          /* 6px */
}

/* btn-sm + btn-primary stays flat-solid (no gradient, no lift). This is the
   compact create-action button used in page-headers (New Template, New Letter,
   New Clause, etc.) — they should read as a different, tighter button family
   than the gradient action-bar buttons. */
.btn-sm.btn-primary {
    background: var(--color-primary);
}

.btn-sm.btn-primary:hover:not(:disabled) {
    background: var(--color-primary-hover);
    transform: none;
    box-shadow: none;
}

.btn-sm.btn-secondary:hover:not(:disabled) {
    transform: none;
    box-shadow: none;
}

/* ---- Outline variant (used by templates, flow editor, etc.) ---- */
.btn-outline-primary {
    background: white;
    color: var(--color-primary);
    border: 1px solid var(--color-primary);
}

.btn-outline-primary:hover:not(:disabled) {
    background: var(--color-primary-bg-subtle);
    border-color: var(--color-primary-hover);
    color: var(--color-primary-hover);
}

/* ---- Icon-only buttons (download, attach, history, etc.) ---- */
.btn-icon-only {
    padding: 6px 8px;
    gap: 0;
}
.btn-icon-only.btn-sm {
    padding: 4px 6px;
}