/* ==========================================================================
   CRM CDL - MODERN ENTERPRISE UI DESIGN SYSTEM
   Framework leve, ultrarrápido e sem dependência de compiladores JS no browser
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

:root {
    --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    
    /* Cores do Sistema */
    --bg-main: #f8fafc;
    --sidebar-bg: #090d16;
    --sidebar-border: #172033;
    --sidebar-text: #94a3b8;
    --sidebar-active: #0284c7;
    
    --card-bg: #ffffff;
    --card-border: #e2e8f0;
    --card-hover-border: #38bdf8;
    
    --primary: #0284c7;
    --primary-hover: #0369a1;
    --primary-light: #e0f2fe;
    
    --success: #10b981;
    --success-light: #d1fae5;
    
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    
    --danger: #ef4444;
    --danger-light: #fee2e2;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    width: 100%;
    overflow: hidden;
    font-family: var(--font-sans);
    background-color: var(--bg-main);
    color: #1e293b;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Scrollbars finos e elegantes */
::-webkit-scrollbar {
    width: 5px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 9999px;
}
::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Layout App */
.app-wrapper {
    display: flex;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

/* Sidebar */
.app-sidebar {
    width: 250px;
    min-width: 250px;
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    z-index: 40;
    user-select: none;
}

.sidebar-header {
    height: 60px;
    display: flex;
    align-items: center;
    padding: 0 1.25rem;
    border-bottom: 1px solid var(--sidebar-border);
    gap: 0.75rem;
}

.sidebar-logo-icon {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: linear-gradient(135deg, #0284c7 0%, #4f46e5 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.95rem;
    box-shadow: 0 4px 12px rgba(2, 132, 199, 0.3);
}

.sidebar-logo-text {
    font-size: 0.95rem;
    font-weight: 800;
    color: #ffffff;
    letter-spacing: -0.02em;
    line-height: 1.1;
}

.sidebar-logo-badge {
    font-size: 0.6rem;
    font-weight: 700;
    padding: 2px 5px;
    border-radius: 4px;
    background: rgba(14, 165, 233, 0.2);
    color: #38bdf8;
    border: 1px solid rgba(14, 165, 233, 0.3);
    margin-left: 4px;
}

.sidebar-btn-action {
    margin: 1rem 1rem 0.5rem 1rem;
    padding: 0.65rem 1rem;
    background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
    color: #ffffff;
    border: none;
    border-radius: 10px;
    font-size: 0.8rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(2, 132, 199, 0.25);
    transition: all 0.15s ease;
}
.sidebar-btn-action:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}
.sidebar-btn-action:active {
    transform: translateY(1px);
}

.sidebar-nav {
    flex: 1;
    padding: 0.75rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.sidebar-section-title {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #64748b;
    padding: 0.75rem 0.75rem 0.25rem 0.75rem;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.85rem;
    border-radius: 10px;
    color: #94a3b8;
    font-size: 0.8rem;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.15s ease;
    border-left: 3px solid transparent;
}

.sidebar-link:hover {
    color: #ffffff;
    background-color: rgba(255, 255, 255, 0.05);
}

.sidebar-link.active {
    color: #ffffff;
    background: linear-gradient(90deg, rgba(2, 132, 199, 0.2) 0%, rgba(2, 132, 199, 0.05) 100%);
    border-left-color: #0284c7;
    font-weight: 700;
}

.sidebar-link i {
    font-size: 0.95rem;
    width: 20px;
    text-align: center;
}

.sidebar-footer {
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--sidebar-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.7rem;
    color: #64748b;
}

/* Main Content Area */
.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    min-width: 0;
    overflow: hidden;
    background-color: #f1f5f9;
}

/* Topbar de Ações e Métricas */
.app-topbar {
    height: 54px;
    min-height: 54px;
    background: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.25rem;
    gap: 1rem;
    z-index: 20;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: 1;
}

.topbar-title {
    font-size: 0.95rem;
    font-weight: 800;
    color: #0f172a;
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
}

/* Busca Rápida */
.search-wrapper {
    position: relative;
    width: 320px;
    max-width: 100%;
}

.search-input {
    width: 100%;
    padding: 0.45rem 0.85rem 0.45rem 2.2rem;
    font-size: 0.78rem;
    font-family: inherit;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background-color: #f8fafc;
    color: #0f172a;
    transition: all 0.15s ease;
}
.search-input:focus {
    outline: none;
    border-color: #0284c7;
    background-color: #ffffff;
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.12);
}

.search-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.75rem;
    color: #94a3b8;
    pointer-events: none;
}

/* Pílulas de Contadores */
.metrics-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.metric-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.65rem;
    border-radius: 7px;
    font-size: 0.72rem;
    font-weight: 600;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    color: #475569;
    white-space: nowrap;
}
.metric-pill strong {
    font-weight: 800;
    color: #0f172a;
}
.metric-pill.active-blue {
    background: #f0f9ff;
    border-color: #bae6fd;
    color: #0369a1;
}
.metric-pill.active-amber {
    background: #fffbeb;
    border-color: #fde68a;
    color: #b45309;
}
.metric-pill.active-green {
    background: #ecfdf5;
    border-color: #a7f3d0;
    color: #047857;
}

/* ==========================================================================
   KANBAN BOARD: ALTURA ATÉ O LIMITE EXATO DA TELA (SEM SCROLL VERTICAL GERAL)
   ========================================================================== */
.kanban-view-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 54px);
    overflow: hidden;
    padding: 0.5rem 0.75rem 0 0.75rem;
}

.kanban-board {
    display: flex;
    gap: 0.75rem;
    overflow-x: auto;
    overflow-y: hidden;
    height: 100%;
    width: 100%;
    align-items: stretch;
    padding-bottom: 0;
}

.kanban-col {
    flex: 0 0 315px;
    width: 315px;
    height: 100%;
    max-height: 100%;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.03);
}

.kanban-col-header {
    padding: 0.65rem 0.85rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #e2e8f0;
    background: #ffffff;
    flex-shrink: 0;
}

.col-header-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.78rem;
    font-weight: 700;
    color: #0f172a;
}

.col-dot {
    width: 8px;
    height: 8px;
    border-radius: 9999px;
}

.col-count-badge {
    padding: 0.15rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.7rem;
    font-weight: 800;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    color: #475569;
}

/* Container de Cards com Scroll Interno até a base da tela */
.kanban-cards-container {
    padding: 0.65rem;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1;
    min-height: 0;
}

/* Estilo do Card */
.kanban-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 0.75rem 0.85rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
    cursor: grab;
    transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
    user-select: none;
    flex-shrink: 0;
}
.kanban-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 18px -4px rgba(15, 23, 42, 0.08);
    border-color: #38bdf8;
}
.kanban-card:active {
    cursor: grabbing;
}

.card-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.25;
    margin-bottom: 0.35rem;
    cursor: pointer;
}
.card-title:hover {
    color: #0284c7;
}

.card-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-bottom: 0.5rem;
}

.tag-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.18rem 0.45rem;
    border-radius: 5px;
    font-size: 0.68rem;
    font-weight: 600;
    background: #f1f5f9;
    color: #475569;
}

.tag-badge.contact {
    background: #eef2ff;
    color: #4338ca;
}

.card-phones {
    font-size: 0.72rem;
    color: #475569;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    margin-bottom: 0.5rem;
}

.card-obs-snippet {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 7px;
    padding: 0.45rem 0.6rem;
    font-size: 0.72rem;
    color: #334155;
    margin-bottom: 0.5rem;
    line-height: 1.35;
    font-style: italic;
}

.card-retorno-tag {
    background: #fef3c7;
    border: 1px solid #fde68a;
    color: #92400e;
    border-radius: 6px;
    padding: 0.25rem 0.5rem;
    font-size: 0.7rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin-bottom: 0.5rem;
}

.card-actions-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 0.5rem;
    border-top: 1px solid #f1f5f9;
}

.btn-icon-round {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.78rem;
    text-decoration: none;
    border: none;
    transition: all 0.12s ease;
    cursor: pointer;
}
.btn-icon-round.btn-whats {
    background: #dcfce7;
    color: #15803d;
}
.btn-icon-round.btn-whats:hover {
    background: #bbf7d0;
    transform: scale(1.08);
}
.btn-icon-round.btn-tel {
    background: #e0f2fe;
    color: #0369a1;
}
.btn-icon-round.btn-tel:hover {
    background: #bae6fd;
    transform: scale(1.08);
}
.btn-icon-round.btn-email {
    background: #eef2ff;
    color: #4338ca;
}
.btn-icon-round.btn-email:hover {
    background: #e0e7ff;
    transform: scale(1.08);
}

.btn-card-register {
    padding: 0.28rem 0.6rem;
    border-radius: 7px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    font-size: 0.72rem;
    font-weight: 700;
    color: #334155;
    cursor: pointer;
    transition: all 0.12s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}
.btn-card-register:hover {
    background: #e0f2fe;
    color: #0284c7;
    border-color: #bae6fd;
}

/* Sortable Drag Feedback */
.sortable-ghost {
    opacity: 0.3 !important;
    background: #f1f5f9 !important;
    border: 2px dashed #0284c7 !important;
}
.sortable-chosen {
    box-shadow: 0 12px 24px -6px rgba(15, 23, 42, 0.15) !important;
}

/* Modais com Backdrop Blur */
.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 50;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.modal-backdrop.hidden {
    display: none !important;
}

.modal-content {
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    width: 100%;
    max-width: 650px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: modalIn 0.15s ease-out;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.96);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}
