/*
 * RochaSign — Design System "Kinetic Trust"
 * CSS próprio, sem dependência de CDN (Tailwind Play, etc.) — essencial
 * para um sistema interno que pode rodar em rede sem acesso à internet.
 * Tokens espelham exemplo/DESIGN.md.
 */

@font-face {
    font-family: 'Inter';
    src: local('Inter');
    font-display: swap;
}

:root {
    --color-surface: #f8f9ff;
    --color-surface-dim: #cbdbf5;
    --color-surface-bright: #f8f9ff;
    --color-surface-container-lowest: #ffffff;
    --color-surface-container-low: #eff4ff;
    --color-surface-container: #e5eeff;
    --color-surface-container-high: #dce9ff;
    --color-surface-container-highest: #d3e4fe;
    --color-on-surface: #0b1c30;
    --color-on-surface-variant: #45464d;
    --color-outline: #76777d;
    --color-outline-variant: #c6c6cd;
    --color-primary: #000000;
    --color-on-primary: #ffffff;
    --color-primary-container: #131b2e;
    --color-on-primary-container: #7c839b;
    --color-secondary: #006c49;
    --color-on-secondary: #ffffff;
    --color-secondary-container: #6cf8bb;
    --color-on-secondary-container: #00714d;
    --color-secondary-fixed: #6ffbbe;
    --color-secondary-fixed-dim: #4edea3;
    --color-on-secondary-fixed: #002113;
    --color-tertiary-container: #001a42;
    --color-on-tertiary-container: #3980f4;
    --color-error: #ba1a1a;
    --color-on-error: #ffffff;
    --color-error-container: #ffdad6;
    --color-on-error-container: #93000a;
    --color-background: #f8f9ff;
    --color-hover-tint: #f1f5f9;
    --color-surface-variant: #d3e4fe;

    --radius: 0.25rem;
    --radius-lg: 0.5rem;
    --radius-full: 999px;

    --space-xs: 4px;
    --space-sm: 12px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --container-max: 1280px;

    --shadow-modal: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--color-background);
    color: var(--color-on-surface);
    font-family: var(--font-sans);
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; }

/* ---------------------------------------------------------------------
   Tipografia
   --------------------------------------------------------------------- */
.text-display { font-size: 48px; font-weight: 700; line-height: 56px; letter-spacing: -0.02em; }
.text-headline-lg { font-size: 32px; font-weight: 600; line-height: 40px; letter-spacing: -0.01em; }
.text-headline-md { font-size: 24px; font-weight: 600; line-height: 32px; }
.text-title-lg { font-size: 20px; font-weight: 600; line-height: 28px; }
.text-title-md { font-size: 16px; font-weight: 600; line-height: 24px; }
.text-body-lg { font-size: 16px; font-weight: 400; line-height: 24px; }
.text-body-md { font-size: 14px; font-weight: 400; line-height: 20px; }
.text-label-lg { font-size: 14px; font-weight: 500; line-height: 20px; }
.text-label-md { font-size: 12px; font-weight: 500; line-height: 16px; letter-spacing: 0.05em; }
.text-muted { color: var(--color-on-surface-variant); }
.text-primary { color: var(--color-primary); }
.text-error { color: var(--color-error); }
.text-mono { font-family: 'Consolas', 'Courier New', monospace; }
.uppercase { text-transform: uppercase; }

/* ---------------------------------------------------------------------
   Layout
   --------------------------------------------------------------------- */
.page { min-height: 100vh; display: flex; flex-direction: column; }
.container { max-width: var(--container-max); margin: 0 auto; width: 100%; padding: 0 var(--space-xl); }
.stack { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; }
.gap-xs { gap: var(--space-xs); }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }
.between { justify-content: space-between; }
.center { align-items: center; justify-content: center; }
.grow { flex: 1; }

.grid { display: grid; gap: var(--space-md); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 900px) { .grid-3 { grid-template-columns: 1fr; } }

/* ---------------------------------------------------------------------
   Navbar
   --------------------------------------------------------------------- */
.navbar {
    background: var(--color-surface-container-lowest);
    border-bottom: 1px solid var(--color-outline-variant);
    height: 64px;
    flex-shrink: 0;
}
.navbar .container { display: flex; align-items: center; justify-content: space-between; height: 100%; }
.navbar-brand { font-size: 20px; font-weight: 700; color: var(--color-primary); }
.navbar-links { display: flex; gap: var(--space-md); }
.navbar-links a {
    font-size: 14px; font-weight: 500; color: var(--color-on-surface-variant); padding-bottom: 2px;
}
.navbar-links a.active { color: var(--color-primary); border-bottom: 2px solid var(--color-primary); }

.main-content { flex: 1; overflow-y: auto; padding: var(--space-xl); }

/* ---------------------------------------------------------------------
   Botões
   --------------------------------------------------------------------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: var(--space-xs);
    height: 40px; padding: 0 var(--space-md); border-radius: var(--radius); border: 1px solid transparent;
    font-size: 14px; font-weight: 500; cursor: pointer; transition: background-color .15s, opacity .15s;
    white-space: nowrap;
}
.btn-primary { background: var(--color-primary); color: var(--color-on-primary); }
.btn-primary:hover { opacity: .88; }
.btn-secondary {
    background: var(--color-surface-container-lowest); color: var(--color-on-surface);
    border-color: var(--color-outline-variant);
}
.btn-secondary:hover { background: var(--color-surface-container-low); }
.btn-danger { background: var(--color-error); color: var(--color-on-error); }
.btn-ghost { background: transparent; color: var(--color-on-surface-variant); }
.btn-ghost:hover { color: var(--color-primary); }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------------------------------------------------------------------
   Cards
   --------------------------------------------------------------------- */
.card {
    background: var(--color-surface-container-lowest);
    border: 1px solid var(--color-outline-variant);
    border-radius: var(--radius-lg);
}
.card-header {
    padding: var(--space-lg); border-bottom: 1px solid var(--color-outline-variant);
    display: flex; align-items: center; justify-content: space-between;
}
.card-body { padding: var(--space-lg); }
.card-row:hover { background: var(--color-hover-tint); }

/* ---------------------------------------------------------------------
   Formulários
   --------------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: var(--space-xs); }
.field label { font-size: 12px; font-weight: 500; color: var(--color-on-surface-variant); }
.input, select.input, textarea.input {
    width: 100%; padding: 10px var(--space-sm); border: 1px solid var(--color-outline-variant);
    border-radius: var(--radius); font-family: var(--font-sans); font-size: 14px; background: var(--color-surface-container-lowest);
    color: var(--color-on-surface); outline: none; transition: border-color .15s;
}
.input:focus { border-color: #3B82F6; box-shadow: 0 0 0 1px #3B82F6; }
.input-otp {
    width: 48px; height: 56px; text-align: center; font-size: 24px; font-weight: 600;
    border: 1px solid var(--color-outline-variant); border-radius: var(--radius);
    background: var(--color-surface-container-low); color: var(--color-primary);
}
.input-otp:focus { border-color: var(--color-primary); outline: none; }

/* ---------------------------------------------------------------------
   Badges / status
   --------------------------------------------------------------------- */
.badge {
    display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: var(--radius);
    font-size: 12px; font-weight: 500; letter-spacing: 0.05em; text-transform: uppercase;
}
.badge-neutral { background: var(--color-surface-variant); color: var(--color-on-surface); }
.badge-info { background: var(--color-surface-container-high); color: var(--color-primary-container); }
.badge-success { background: var(--color-secondary-fixed-dim); color: var(--color-secondary); }
.badge-danger { background: var(--color-error-container); color: var(--color-on-error-container); }

/* ---------------------------------------------------------------------
   Progresso
   --------------------------------------------------------------------- */
.progress { flex: 1; height: 8px; background: var(--color-surface-variant); border-radius: var(--radius-full); overflow: hidden; }
.progress-bar { height: 100%; background: var(--color-primary); }
.progress-bar.success { background: var(--color-secondary); }

/* ---------------------------------------------------------------------
   Login
   --------------------------------------------------------------------- */
.auth-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: var(--space-md); }
.auth-card {
    width: 100%; max-width: 400px; background: var(--color-surface-container-lowest);
    border: 1px solid var(--color-outline-variant); border-radius: var(--radius-lg);
    padding: var(--space-xl); box-shadow: var(--shadow-modal);
}
.auth-logo {
    width: 56px; height: 56px; border-radius: var(--radius-lg); background: var(--color-primary);
    color: var(--color-on-primary); display: flex; align-items: center; justify-content: center;
    margin-bottom: var(--space-md); box-shadow: 0 4px 10px rgba(0, 0, 0, 0.18);
}
.alert {
    padding: 10px var(--space-sm); border-radius: var(--radius); font-size: 14px; margin-bottom: var(--space-md);
}
.alert-error { background: var(--color-error-container); color: var(--color-on-error-container); }
.alert-success { background: var(--color-secondary-container); color: var(--color-on-secondary-container); }

/* ---------------------------------------------------------------------
   Modal
   --------------------------------------------------------------------- */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(19, 27, 46, 0.35); backdrop-filter: blur(2px);
    z-index: 50; align-items: center; justify-content: center; padding: var(--space-md);
    display: none;
}
.modal-overlay.open { display: flex; }
.modal {
    background: var(--color-surface-container-lowest); border-radius: var(--radius-lg);
    box-shadow: var(--shadow-modal); border: 1px solid var(--color-outline-variant);
    width: 100%; max-width: 480px; padding: var(--space-xl);
}

/* ---------------------------------------------------------------------
   Upload / dropzone
   --------------------------------------------------------------------- */
.dropzone {
    border: 2px dashed var(--color-outline-variant); border-radius: var(--radius-lg);
    padding: var(--space-xl); display: flex; flex-direction: column; align-items: center; justify-content: center;
    text-align: center; cursor: pointer; min-height: 220px; transition: background-color .15s;
}
.dropzone:hover { background: var(--color-surface-container-low); }

/* ---------------------------------------------------------------------
   Reordenação de signatários (botões subir/descer)
   --------------------------------------------------------------------- */
.reorder-btn {
    width: 24px; height: 20px; padding: 0; display: flex; align-items: center; justify-content: center;
    border: 1px solid var(--color-outline-variant); border-radius: var(--radius);
    background: var(--color-surface-container-lowest); color: var(--color-on-surface-variant);
    font-size: 10px; line-height: 1; cursor: pointer; transition: background-color .15s;
}
.reorder-btn:hover:not(:disabled) { background: var(--color-surface-container-low); color: var(--color-primary); }
.reorder-btn:disabled { opacity: .3; cursor: not-allowed; }

/* ---------------------------------------------------------------------
   Chips de campo (tela de posicionamento — um por signatário/tipo)
   --------------------------------------------------------------------- */
.field-chip {
    display: inline-flex; align-items: center; padding: 4px 10px; border-radius: var(--radius-full);
    border: 1px solid var(--color-outline-variant); background: var(--color-surface-container-lowest);
    font-size: 12px; font-weight: 500; cursor: pointer; transition: background-color .15s, color .15s;
}
.field-chip:hover { background: var(--color-surface-container-low); }

/* ---------------------------------------------------------------------
   Botão flutuante "Assinar" (tela pública de assinatura)
   --------------------------------------------------------------------- */
.sign-trigger {
    position: fixed; left: 50%; bottom: 64px; z-index: 20;
    transform: translateX(-50%);
    display: inline-flex; align-items: center; gap: 8px;
    background: var(--color-primary); color: var(--color-on-primary);
    border: none; border-radius: var(--radius-full); padding: 14px 24px;
    font-size: 15px; font-weight: 600; cursor: pointer;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
    transition: transform .15s, box-shadow .15s;
}
.sign-trigger:hover { transform: translateX(-50%) translateY(-2px); box-shadow: 0 10px 24px rgba(0, 0, 0, 0.3); }

/* ---------------------------------------------------------------------
   Ícones (fallback simples sem Material Symbols/CDN)
   --------------------------------------------------------------------- */
.icon { display: inline-block; line-height: 1; }

/* ---------------------------------------------------------------------
   Utilitários
   --------------------------------------------------------------------- */
.hidden { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.divider { border: 0; border-top: 1px solid var(--color-outline-variant); margin: var(--space-md) 0; }
