/* ==========================================================================
   Padel CRM - Design System (inspirado em Material Design / HubSpot / Linear)
   ========================================================================== */

:root {
    --md-primary: #4F46E5;
    --md-primary-dark: #4338CA;
    --md-primary-light: #6366F1;
    --md-on-primary: #FFFFFF;

    --md-background: #F7F7FB;
    --md-surface: #FFFFFF;
    --md-surface-alt: #F1F1F6;
    --md-on-surface: #1F2430;
    --md-on-surface-muted: #6B7280;
    --md-outline: #E2E4EA;

    --md-error: #DC2626;
    --md-error-bg: #FEE2E2;
    --md-success: #16A34A;
    --md-success-bg: #DCFCE7;

    --md-radius-sm: 6px;
    --md-radius-md: 10px;
    --md-radius-lg: 16px;

    --md-shadow-sm: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .10);
    --md-shadow-md: 0 4px 16px rgba(16, 24, 40, .08);

    --md-space-1: 4px;
    --md-space-2: 8px;
    --md-space-3: 12px;
    --md-space-4: 16px;
    --md-space-5: 24px;
    --md-space-6: 32px;

    color-scheme: light;
}

[data-theme="dark"] {
    --md-background: #0F1115;
    --md-surface: #171A21;
    --md-surface-alt: #1E222B;
    --md-on-surface: #E5E7EB;
    --md-on-surface-muted: #9CA3AF;
    --md-outline: #2A2F3A;

    --md-primary: #6366F1;
    --md-primary-dark: #4F46E5;
    --md-on-primary: #FFFFFF;

    --md-error-bg: #3B1220;
    --md-success-bg: #0F2A1B;

    --md-shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --md-shadow-md: 0 4px 16px rgba(0, 0, 0, .4);

    color-scheme: dark;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
}

body {
    font-family: "Roboto", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--md-background);
    color: var(--md-on-surface);
    -webkit-font-smoothing: antialiased;
    transition: background-color .15s ease, color .15s ease;
}

h1, h2, h3, h4 {
    font-weight: 500;
    margin: 0 0 var(--md-space-3);
}

p {
    margin: 0 0 var(--md-space-3);
    color: var(--md-on-surface-muted);
}

a {
    color: var(--md-primary);
}

code {
    background: var(--md-surface-alt);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: .9em;
}

/* -------------------------------------------------------------------- */
/* Layout autenticado                                                    */
/* -------------------------------------------------------------------- */

.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 240px;
    flex-shrink: 0;
    background: var(--md-surface);
    border-right: 1px solid var(--md-outline);
    padding: var(--md-space-5) var(--md-space-3);
    display: flex;
    flex-direction: column;
    gap: var(--md-space-5);
}

.sidebar__brand {
    display: flex;
    align-items: center;
    gap: var(--md-space-2);
    font-weight: 700;
    font-size: 1.1rem;
    padding: 0 var(--md-space-2);
}

.sidebar__logo {
    font-size: 1.4rem;
}

.sidebar__nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-link {
    display: block;
    padding: var(--md-space-3) var(--md-space-3);
    border-radius: var(--md-radius-sm);
    color: var(--md-on-surface);
    text-decoration: none;
    font-size: .95rem;
    cursor: pointer;
}

.nav-link:hover {
    background: var(--md-surface-alt);
}

.nav-link.is-active {
    background: var(--md-primary);
    color: var(--md-on-primary);
}

.nav-link.is-disabled {
    color: var(--md-on-surface-muted);
    cursor: not-allowed;
    opacity: .55;
}

.nav-link.is-disabled:hover {
    background: none;
}

.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--md-space-3) var(--md-space-5);
    background: var(--md-surface);
    border-bottom: 1px solid var(--md-outline);
}

.topbar__actions {
    display: flex;
    align-items: center;
    gap: var(--md-space-3);
}

.topbar__search {
    flex: 1;
    max-width: 360px;
}

.topbar__search input {
    width: 100%;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid var(--md-outline);
    background: var(--md-surface-alt);
    color: var(--md-on-surface);
    font-size: 0.875rem;
}

.topbar__user {
    font-size: .9rem;
    color: var(--md-on-surface-muted);
}

.app-content {
    padding: var(--md-space-6);
    flex: 1;
}

.page-header {
    margin-bottom: var(--md-space-5);
}

/* -------------------------------------------------------------------- */
/* Grid & cartoes                                                        */
/* -------------------------------------------------------------------- */

.grid {
    display: grid;
    gap: var(--md-space-5);
}

.grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

.card {
    background: var(--md-surface);
    border: 1px solid var(--md-outline);
    border-radius: var(--md-radius-lg);
    padding: var(--md-space-5);
    box-shadow: var(--md-shadow-sm);
}

.card h3 {
    font-size: 1rem;
    margin-bottom: var(--md-space-3);
}

.page-header--row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--md-space-4);
}

/* -------------------------------------------------------------------- */
/* Tabelas                                                               */
/* -------------------------------------------------------------------- */

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: .9rem;
}

.table th,
.table td {
    text-align: left;
    padding: var(--md-space-3) var(--md-space-3);
    border-bottom: 1px solid var(--md-outline);
}

.table th {
    color: var(--md-on-surface-muted);
    font-weight: 500;
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .02em;
}

.table tbody tr:last-child td {
    border-bottom: none;
}

.color-dot {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 1px solid var(--md-outline);
}

.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 500;
}

.badge-success {
    background: var(--md-success-bg);
    color: var(--md-success);
}

.badge-muted {
    background: var(--md-surface-alt);
    color: var(--md-on-surface-muted);
}

/* -------------------------------------------------------------------- */
/* Kanban                                                                */
/* -------------------------------------------------------------------- */

.kanban {
    display: flex;
    gap: var(--md-space-4);
    overflow-x: auto;
    padding-bottom: var(--md-space-4);
}

.kanban__column {
    background: var(--md-surface-alt);
    border-radius: var(--md-radius-md);
    width: 260px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 240px);
}

.kanban__column-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--md-space-3) var(--md-space-3);
    font-size: .85rem;
    font-weight: 500;
    border-top: 3px solid var(--md-outline);
    border-radius: var(--md-radius-md) var(--md-radius-md) 0 0;
}

.kanban__cards {
    display: flex;
    flex-direction: column;
    gap: var(--md-space-3);
    padding: var(--md-space-3);
    overflow-y: auto;
    min-height: 60px;
}

.kanban__card {
    display: flex;
    flex-direction: column;
    gap: 2px;
    background: var(--md-surface);
    border: 1px solid var(--md-outline);
    border-radius: var(--md-radius-sm);
    padding: var(--md-space-3);
    box-shadow: var(--md-shadow-sm);
    text-decoration: none;
    color: var(--md-on-surface);
    cursor: grab;
}

.kanban__card:active {
    cursor: grabbing;
}

.kanban__card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: var(--md-space-2);
}

.sortable-ghost {
    opacity: .4;
}

/* -------------------------------------------------------------------- */
/* Timeline & tarefas (ficha da lead)                                    */
/* -------------------------------------------------------------------- */

.timeline {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: var(--md-space-4);
}

.timeline__item {
    display: flex;
    gap: var(--md-space-3);
    align-items: flex-start;
}

.timeline__icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--md-surface-alt);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: .85rem;
}

.task-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: var(--md-space-2);
}

.task-list__item {
    display: flex;
    align-items: center;
    gap: var(--md-space-2);
    font-size: .9rem;
}

.task-list__item.is-done span:first-of-type {
    text-decoration: line-through;
    color: var(--md-on-surface-muted);
}

.task-list__check {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    padding: 0;
    line-height: 1;
}

/* -------------------------------------------------------------------- */
/* Formularios (backoffice)                                              */
/* -------------------------------------------------------------------- */

.form-grid {
    display: flex;
    flex-direction: column;
    gap: var(--md-space-5);
    max-width: 760px;
}

.form-section {
    border: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: var(--md-space-4);
}

.form-section legend {
    font-weight: 500;
    padding: 0 0 var(--md-space-2);
    border-bottom: 1px solid var(--md-outline);
    width: 100%;
    margin-bottom: var(--md-space-2);
}

.field-row {
    display: flex;
    gap: var(--md-space-4) var(--md-space-4);
    row-gap: var(--md-space-4);
    flex-wrap: wrap;
}

.field-row .field {
    flex: 1;
    min-width: 160px;
}

.field-inline {
    flex-direction: row;
    align-items: center;
    gap: var(--md-space-2);
}

.field-inline input {
    width: auto;
}

.field-hint {
    font-size: .82rem;
    margin: 0;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--md-space-3);
}

input[type="color"] {
    padding: 2px;
    height: 42px;
}

.status-list, .roadmap-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: var(--md-space-2);
    color: var(--md-on-surface-muted);
    font-size: .9rem;
}

.roadmap-list {
    list-style: decimal;
    padding-left: 1.1rem;
}

.dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: var(--md-space-2);
}

.dot-ok {
    background: var(--md-success);
}

.text-success {
    color: var(--md-success);
}

.text-error {
    color: var(--md-error);
}

/* -------------------------------------------------------------------- */
/* Autenticacao (guest)                                                  */
/* -------------------------------------------------------------------- */

.guest-body {
    min-height: 100vh;
    display: flex;
}

.guest-main {
    margin: auto;
    width: 100%;
    max-width: 380px;
    padding: var(--md-space-5);
}

.auth-card {
    background: var(--md-surface);
    border: 1px solid var(--md-outline);
    border-radius: var(--md-radius-lg);
    padding: var(--md-space-6);
    box-shadow: var(--md-shadow-md);
}

.auth-card__brand {
    text-align: center;
    margin-bottom: var(--md-space-5);
}

.auth-card__logo {
    font-size: 2rem;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: var(--md-space-4);
}

.theme-toggle {
    position: fixed;
    top: var(--md-space-4);
    right: var(--md-space-4);
}

/* -------------------------------------------------------------------- */
/* Componentes                                                           */
/* -------------------------------------------------------------------- */

.field {
    display: flex;
    flex-direction: column;
    gap: var(--md-space-1);
    font-size: .9rem;
}

.field span {
    color: var(--md-on-surface-muted);
    font-weight: 500;
}

.field input,
.field select,
.field textarea {
    font-family: inherit;
    font-size: 1rem;
    padding: 12px 14px;
    border: 1.5px solid var(--md-outline);
    border-radius: var(--md-radius-md);
    background: var(--md-surface);
    color: var(--md-on-surface);
    transition: border-color .15s ease, box-shadow .15s ease;
}

.field input::placeholder,
.field textarea::placeholder {
    color: var(--md-on-surface-muted);
    opacity: .7;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
    outline: none;
    border-color: var(--md-primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--md-primary) 18%, transparent);
}

/* -------------------------------------------------------------------- */
/* Chips (selecao visual - nivel, dias, horarios, genero, ...)          */
/* -------------------------------------------------------------------- */

.chip-group {
    display: flex;
    flex-wrap: wrap;
    column-gap: var(--md-space-2);
    row-gap: var(--md-space-3);
}

.chip-input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.chip-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    border-radius: 999px;
    border: 1.5px solid var(--md-outline);
    background: var(--md-surface);
    color: var(--md-on-surface);
    cursor: pointer;
    user-select: none;
    font-size: .88rem;
    font-weight: 500;
    transition: all .15s ease;
}

.chip-label:hover {
    border-color: var(--md-primary-light);
}

.chip-input:checked + .chip-label {
    background: var(--md-primary);
    border-color: var(--md-primary);
    color: var(--md-on-primary);
}

.chip-input:focus-visible + .chip-label {
    outline: 2px solid var(--md-primary-light);
    outline-offset: 2px;
}

.consent-card {
    display: flex;
    align-items: flex-start;
    gap: var(--md-space-3);
    padding: var(--md-space-4);
    border: 1.5px solid var(--md-outline);
    border-radius: var(--md-radius-md);
    cursor: pointer;
    transition: border-color .15s ease, background .15s ease;
}

.consent-card:hover {
    border-color: var(--md-primary-light);
}

.consent-card input {
    margin-top: 3px;
    width: 18px;
    height: 18px;
    accent-color: var(--md-primary);
    flex-shrink: 0;
}

.consent-card span {
    font-size: .88rem;
    color: var(--md-on-surface);
    line-height: 1.5;
}

[x-cloak] {
    display: none !important;
}

.btn {
    display: inline-block;
    font-family: inherit;
    font-size: .95rem;
    font-weight: 500;
    padding: var(--md-space-3) var(--md-space-4);
    border-radius: var(--md-radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    background: none;
    color: var(--md-on-surface);
    text-decoration: none;
    line-height: 1.3;
}

.btn-block {
    width: 100%;
}

.btn-primary {
    background: var(--md-primary);
    color: var(--md-on-primary);
}

.btn-primary:hover {
    background: var(--md-primary-dark);
}

.btn-text {
    color: var(--md-primary);
    padding: var(--md-space-2) var(--md-space-3);
}

.btn-text:hover {
    background: var(--md-surface-alt);
}

.icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--md-outline);
    background: var(--md-surface);
    cursor: pointer;
    font-size: 1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:hover {
    background: var(--md-surface-alt);
}

.alert {
    padding: var(--md-space-3) var(--md-space-4);
    border-radius: var(--md-radius-sm);
    font-size: .9rem;
    margin-bottom: var(--md-space-4);
    transition: opacity .3s ease;
}

.alert--dismissed {
    opacity: 0;
}

.alert-error {
    background: var(--md-error-bg);
    color: var(--md-error);
}

.alert-success {
    background: var(--md-success-bg);
    color: var(--md-success);
}

/* -------------------------------------------------------------------- */
/* Responsividade                                                        */
/* -------------------------------------------------------------------- */

@media (max-width: 960px) {
    .grid-3 {
        grid-template-columns: 1fr;
    }
}

/* -------------------------------------------------------------------- */
/* Formulario publico (captacao de leads)                               */
/* -------------------------------------------------------------------- */

.lead-page {
    min-height: 100vh;
    padding-bottom: 64px;
}

.lead-hero {
    padding: 56px 20px 120px;
    text-align: center;
    color: #fff;
    position: relative;
    z-index: 0;
}

.lead-hero__logo {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .18);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: var(--md-space-4);
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, .5);
}

.lead-hero__logo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.lead-hero h1 {
    color: #fff;
    font-size: 1.7rem;
    margin-bottom: 6px;
}

.lead-hero p {
    color: rgba(255, 255, 255, .88);
    margin: 0;
    font-size: 1rem;
}

.lead-wrap {
    max-width: 620px;
    margin: -48px auto 0;
    padding: 0 16px;
    position: relative;
    z-index: 1;
}

.lead-card {
    background: var(--md-surface);
    border-radius: var(--md-radius-lg);
    box-shadow: var(--md-shadow-md);
    padding: var(--md-space-6) var(--md-space-5);
}

.lead-card form section {
    display: flex;
    flex-direction: column;
    gap: var(--md-space-4);
}

.lead-progress {
    display: flex;
    gap: 6px;
    margin-bottom: var(--md-space-5);
}

.lead-progress__step {
    flex: 1;
    height: 4px;
    border-radius: 999px;
    background: var(--md-outline);
    transition: background .2s ease;
}

.lead-progress__step.is-done {
    background: var(--md-primary);
}

.lead-step-title {
    font-size: 1.2rem;
    margin-bottom: 4px;
}

.lead-step-subtitle {
    font-size: .88rem;
    margin-bottom: var(--md-space-5);
}

.lead-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: var(--md-space-5);
    gap: var(--md-space-3);
}

.lead-actions .btn-primary {
    margin-left: auto;
}

.lead-success {
    text-align: center;
    padding: 40px 24px;
}

.lead-success__icon {
    font-size: 2.6rem;
    margin-bottom: var(--md-space-3);
}

@media (max-width: 560px) {
    .lead-hero {
        padding: 40px 16px 88px;
    }

    .lead-card {
        padding: var(--md-space-5) var(--md-space-4);
    }
}

@media (max-width: 768px) {
    .app-shell {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        flex-direction: row;
        align-items: center;
        overflow-x: auto;
        border-right: none;
        border-bottom: 1px solid var(--md-outline);
        padding: var(--md-space-3);
    }

    .sidebar__nav {
        flex-direction: row;
    }

    .app-content {
        padding: var(--md-space-4);
    }
}
