/* Custom styles for Despachante */

@font-face {
    font-family: 'Haskoy';
    src: url('../fonts/Haskoy-variable.woff2') format('woff2');
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}

:root {
    color-scheme: light;
    --page-bg: #f4efe7;
    --page-bg-alt: #eadfce;
    --surface: rgba(255, 251, 245, 0.82);
    --surface-strong: #fffaf4;
    --text: #1f2430;
    --muted: #667180;
    --border: rgba(31, 36, 48, 0.12);
    --primary: #1f6f79;
    --primary-strong: #175862;
    --primary-soft: rgba(31, 111, 121, 0.12);
    --primary-contrast: #f7fcfd;
    --danger: #b24747;
    --danger-soft: rgba(178, 71, 71, 0.12);
    --success: #2f7a4b;
    --shadow: 0 18px 45px rgba(25, 30, 38, 0.08);
}

[data-theme="terra-dark"] {
    color-scheme: dark;
    --page-bg: #111613;
    --page-bg-alt: #171f1b;
    --surface: rgba(23, 29, 26, 0.82);
    --surface-strong: #1b2420;
    --text: #edf2ef;
    --muted: #a7b0ab;
    --border: rgba(237, 242, 239, 0.12);
    --primary: #77c6cf;
    --primary-strong: #4daab4;
    --primary-soft: rgba(119, 198, 207, 0.14);
    --primary-contrast: #0e1614;
    --danger: #ef8c8c;
    --danger-soft: rgba(239, 140, 140, 0.14);
    --success: #8bd1a1;
    --shadow: 0 22px 60px rgba(0, 0, 0, 0.35);
}

[data-theme="terra-dim"] {
    color-scheme: dark;
    --page-bg: #202724;
    --page-bg-alt: #2a342f;
    --surface: rgba(33, 41, 37, 0.84);
    --surface-strong: #2b3531;
    --text: #eef2ef;
    --muted: #b2bbb6;
    --border: rgba(238, 242, 239, 0.12);
    --primary: #78c0c7;
    --primary-strong: #5ca7af;
    --primary-soft: rgba(120, 192, 199, 0.14);
    --primary-contrast: #101816;
    --danger: #ee9b9b;
    --danger-soft: rgba(238, 155, 155, 0.14);
    --success: #93d0a7;
    --shadow: 0 22px 60px rgba(0, 0, 0, 0.28);
}

[data-theme="terra-light"] {
    color-scheme: light;
    --page-bg: #f4efe7;
    --page-bg-alt: #e9ddcb;
    --surface: rgba(255, 251, 245, 0.82);
    --surface-strong: #fffaf4;
    --text: #1f2430;
    --muted: #667180;
    --border: rgba(31, 36, 48, 0.12);
    --primary: #1f6f79;
    --primary-strong: #175862;
    --primary-soft: rgba(31, 111, 121, 0.12);
    --primary-contrast: #f7fcfd;
    --danger: #b24747;
    --danger-soft: rgba(178, 71, 71, 0.12);
    --success: #2f7a4b;
    --shadow: 0 18px 45px rgba(25, 30, 38, 0.08);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    padding: 24px 20px 40px;
    font-family: 'Haskoy', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: var(--text);
    line-height: 1.5;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    background:
        radial-gradient(circle at top left, rgba(31, 111, 121, 0.12), transparent 34%),
        radial-gradient(circle at top right, rgba(183, 145, 92, 0.12), transparent 30%),
        linear-gradient(180deg, var(--page-bg) 0%, var(--page-bg-alt) 100%);
}

.page-content,
.messages,
.topbar {
    width: min(1120px, 100%);
    margin-left: auto;
    margin-right: auto;
}

.topbar {
    margin-bottom: 18px;
    padding: 14px 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    align-items: center;
    justify-content: space-between;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 22px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(14px);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    color: var(--text);
    text-decoration: none;
}

.brand:hover {
    text-decoration: none;
}

.brand-mark {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    background: linear-gradient(180deg, var(--primary), var(--primary-strong));
    color: var(--primary-contrast);
    font-weight: 800;
    box-shadow: 0 12px 26px rgba(31, 111, 121, 0.22);
}

.brand-text {
    display: grid;
    line-height: 1.05;
}

.brand-text strong {
    font-size: 1rem;
}

.brand-text small {
    color: var(--muted);
}

.topbar nav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin: 0;
    padding: 0;
    background: transparent;
    border: 0;
    box-shadow: none;
    backdrop-filter: none;
}

.topbar nav a {
    padding: 8px 11px;
}

.topbar-actions {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.user-chip,
.ghost-link {
    display: inline-flex;
    align-items: center;
    min-height: 38px;
    padding: 0 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.4);
    border: 1px solid var(--border);
}

.user-chip {
    color: var(--muted);
    font-size: 0.92rem;
}

.ghost-link {
    color: var(--text);
    text-decoration: none;
}

.ghost-link:hover {
    background: var(--primary-soft);
}

body:not(.auth-page) main.page-content {
    padding-bottom: 10px;
}

body.auth-page {
    display: grid;
    place-items: center;
    padding-top: 32px;
}

body.auth-page .page-content {
    width: min(520px, 100%);
}

body.auth-page .messages {
    width: min(520px, 100%);
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
    outline: 3px solid rgba(31, 111, 121, 0.28);
    outline-offset: 2px;
}

nav {
    display: contents;
}

nav a {
    padding: 8px 10px;
    border-radius: 999px;
    color: var(--text);
    transition: background-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

nav a:hover {
    background: var(--primary-soft);
    color: var(--primary-strong);
    text-decoration: none;
    transform: translateY(-1px);
}

main {
    display: grid;
    gap: 18px;
}

.page-hero {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: end;
    justify-content: space-between;
    margin-bottom: 6px;
}

.page-hero p,
.section-copy {
    color: var(--muted);
    max-width: 60ch;
}

.hero-actions,
.section-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.surface-card,
.auth-shell,
.content-card,
.stats-grid,
.details-grid,
.split-grid,
.settings-stack {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 24px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(12px);
}

.surface-card,
.content-card,
.auth-shell {
    padding: 20px;
}

.content-card {
    display: grid;
    gap: 14px;
}

.auth-shell {
    width: 100%;
    display: grid;
    gap: 18px;
}

.auth-shell .brand {
    justify-content: center;
}

.auth-shell .auth-copy {
    text-align: center;
    color: var(--muted);
}

.auth-shell form {
    max-width: none;
}

.auth-footer {
    text-align: center;
    color: var(--muted);
}

.stats-grid {
    padding: 16px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

.stat-card {
    padding: 16px;
    border-radius: 18px;
    background: var(--surface-strong);
    border: 1px solid var(--border);
}

.stat-card strong {
    display: block;
    font-size: 1.55rem;
    margin-top: 2px;
}

.stat-card span {
    color: var(--muted);
    font-size: 0.92rem;
}

.details-grid,
.split-grid,
.settings-stack {
    padding: 16px;
    display: grid;
    gap: 14px;
}

.details-grid {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.detail-card,
.empty-state,
.panel {
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--surface-strong);
}

.detail-card h3,
.panel h2,
.panel h3 {
    margin-bottom: 6px;
}

.detail-label {
    display: block;
    margin-bottom: 4px;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
}

.detail-value {
    margin: 0;
    word-break: break-word;
}

.meta-line {
    display: block;
    margin-top: 2px;
    color: var(--muted);
    font-size: 0.86rem;
}

.empty-state {
    text-align: center;
    color: var(--muted);
}

.empty-state strong {
    display: block;
    margin-bottom: 6px;
    color: var(--text);
}

.table-card {
    overflow: hidden;
    padding: 0;
}

.table-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.table-wrap {
    overflow-x: auto;
}

.badge,
.status-badge,
.pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 30px;
    padding: 0 10px;
    border-radius: 999px;
    background: var(--primary-soft);
    color: var(--primary-strong);
    font-size: 0.82rem;
    font-weight: 700;
    white-space: nowrap;
}

.badge.is-muted,
.status-badge.is-muted,
.pill.is-muted {
    background: rgba(102, 113, 128, 0.12);
    color: var(--muted);
}

.badge.is-success,
.status-badge.is-success,
.pill.is-success {
    background: rgba(47, 122, 75, 0.12);
    color: var(--success);
}

.badge.is-danger,
.status-badge.is-danger,
.pill.is-danger {
    background: var(--danger-soft);
    color: var(--danger);
}

h1,
h2,
h3 {
    margin: 0 0 8px;
    line-height: 1.1;
    letter-spacing: -0.02em;
}

h1 {
    font-size: clamp(1.65rem, 2.6vw, 2.4rem);
}

h2 {
    font-size: clamp(1.1rem, 1.8vw, 1.5rem);
}

p {
    margin: 0 0 12px;
}

.messages {
    max-width: 1120px;
    margin: 0 auto 18px;
    display: grid;
    gap: 10px;
}

.message {
    margin: 0;
    padding: 12px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 4px solid var(--primary);
    border-radius: 16px;
    box-shadow: var(--shadow);
}

form {
    display: grid;
    gap: 12px;
    max-width: 760px;
    padding: 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 22px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(12px);
}

.form-grid {
    max-width: none;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    align-items: start;
}

.field {
    display: grid;
    gap: 8px;
    grid-column: span 12;
}

.field.half {
    grid-column: span 6;
}

.field.third {
    grid-column: span 4;
}

.field.two-thirds {
    grid-column: span 8;
}

.field.full,
.field.actions {
    grid-column: 1 / -1;
}

.field.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: space-between;
    align-items: center;
    margin-top: 4px;
}

.permission-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
}

.check-card {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--surface-strong);
    color: var(--text);
}

.check-card input {
    width: auto;
    margin-top: 4px;
}

.check-card span {
    display: grid;
    gap: 2px;
}

.check-card small {
    color: var(--muted);
    font-weight: 500;
}

.danger-check {
    border-color: rgba(178, 71, 71, 0.22);
    background: var(--danger-soft);
}

label {
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--muted);
}

input,
select,
textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface-strong);
    color: var(--text);
    font: inherit;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

input::placeholder,
textarea::placeholder {
    color: var(--muted);
    opacity: 0.75;
}

textarea {
    min-height: 140px;
    resize: vertical;
}

select[multiple] {
    min-height: 160px;
}

input[type="file"] {
    padding: 10px;
    background: transparent;
    border-style: dashed;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type="number"] {
    -moz-appearance: textfield;
}

button,
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: max-content;
    padding: 12px 18px;
    border: 0;
    border-radius: 999px;
    background: linear-gradient(180deg, var(--primary), var(--primary-strong));
    color: var(--primary-contrast);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 12px 26px rgba(31, 111, 121, 0.18);
    transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

button:hover,
.button:hover {
    transform: translateY(-1px);
    box-shadow: 0 16px 30px rgba(31, 111, 121, 0.22);
    text-decoration: none;
}

button:active,
.button:active {
    transform: translateY(0);
    opacity: 0.96;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 22px;
    overflow: hidden;
    box-shadow: var(--shadow);
}

thead {
    position: sticky;
    top: 0;
    z-index: 1;
}

th,
td {
    padding: 12px 14px;
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid var(--border);
}

th {
    background: rgba(255, 255, 255, 0.5);
    color: var(--muted);
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

tr:last-child td {
    border-bottom: 0;
}

ul,
ol {
    margin: 0 0 16px;
    padding-left: 1.25rem;
}

li {
    margin: 0 0 8px;
}

main > p {
    padding: 14px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: var(--shadow);
}

.section-head {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: end;
    justify-content: space-between;
}

.section-head p {
    margin: 0;
    color: var(--muted);
}

.stack {
    display: grid;
    gap: 12px;
}

.list-card {
    display: grid;
    gap: 10px;
}

.list-item {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--surface-strong);
}

.list-item-main {
    display: grid;
    gap: 4px;
}

.list-item-title {
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
}

.list-item-title:hover {
    color: var(--primary-strong);
    text-decoration: underline;
}

.list-item-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 12px;
    color: var(--muted);
    font-size: 0.92rem;
}

.list-item-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.mini-link {
    color: var(--muted);
}

.mini-link:hover {
    color: var(--primary-strong);
}

main > a {
    display: inline-flex;
    width: fit-content;
    padding: 10px 14px;
    border-radius: 999px;
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

/* ── Kanban ── */

@keyframes cardIn {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }

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

.kanban-card {
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    animation: cardIn 0.2s ease;
}

.kanban-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.kanban-card.dragging {
    opacity: 0.4;
    transform: rotate(2deg) scale(0.95);
}

.kanban-column.drop-highlight {
    background: var(--primary-soft);
    border: 2px dashed rgba(31, 111, 121, 0.35);
}

.kanban-placeholder {
    height: 3px;
    background: var(--primary);
    border-radius: 2px;
    margin: 4px 0;
}

.pipeline-board {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(280px, 1fr);
    gap: 14px;
    overflow-x: auto;
    padding-bottom: 8px;
}

.pipeline-column {
    display: grid;
    gap: 12px;
    align-content: start;
    min-width: 280px;
    padding: 16px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.pipeline-column h2 {
    margin: 0;
}

.pipeline-item {
    display: grid;
    gap: 6px;
    padding: 14px;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: var(--surface-strong);
}

.pipeline-item strong {
    font-size: 0.98rem;
}

#pipeline {
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
}

.kanban-column-wrapper {
    scroll-snap-align: start;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(31, 36, 48, 0.22);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(31, 36, 48, 0.32);
}

/* ── Sidebar ── */

.sidebar-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    margin: 0 0.5rem;
    border-radius: 0.5rem;
    border-left: 3px solid transparent;
    color: rgba(31, 36, 48, 0.72);
    transition: all 0.15s ease;
    white-space: nowrap;
    text-decoration: none;
    font-size: 0.875rem;
}

.sidebar-item:hover {
    background: rgba(31, 36, 48, 0.08);
    color: var(--text);
}

.sidebar-item.active {
    border-left-color: var(--primary);
    background: var(--primary-soft);
    color: var(--primary-strong);
}

.sidebar-label {
    opacity: 0;
    transition: opacity 0.15s ease;
    pointer-events: none;
}

.group\/sidebar:hover .sidebar-label,
#sidebar.sidebar-open .sidebar-label,
#sidebar.sidebar-pinned .sidebar-label {
    opacity: 1;
    pointer-events: auto;
}

#sidebar.sidebar-pinned {
    width: 14rem;
}

#main-content.sidebar-pinned-margin {
    margin-left: 14rem;
}

.sidebar-logo {
    transition: transform 0.2s ease;
}

.sidebar-logo:hover {
    transform: scale(1.05);
}

#sidebar .divider {
    height: 1px;
    margin-top: 0.25rem;
    margin-bottom: 0.25rem;
}

@media (max-width: 767px) {
    #sidebar.sidebar-open {
        transform: translateX(0);
        width: 14rem;
    }
}

/* ── WhatsApp Indicator ── */

.wa-indicator {
    display: inline-flex;
    align-items: center;
}

.wa-indicator.hidden {
    display: none;
}

/* ── Drop Zone (Document Upload) ── */

.drop-zone {
    transition: border-color 0.2s ease, background-color 0.2s ease;
}

.drop-zone.drop-highlight {
    border-color: var(--primary);
    background: var(--primary-soft);
}

.drop-zone.drop-error {
    border-color: var(--danger);
    background: var(--danger-soft);
}

/* ── Integration Cards (Settings) ── */

.integration-card > summary {
    list-style: none;
}

.integration-card > summary::-webkit-details-marker {
    display: none;
}

.integration-card > summary:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: -2px;
}
