/* === CRM JJM — Design System === */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Space+Grotesk:wght@500;600;700&display=swap');

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

:root {
    --bg-main: #0a0c14;
    --bg-sidebar: #0d0f1a;
    --bg-card: #111425;
    --bg-card-hover: #161a30;
    --bg-input: #0d0f1a;
    --border: rgba(255,255,255,0.07);
    --border-hover: rgba(255,255,255,0.15);
    --text-primary: #eef0ff;
    --text-secondary: #7e85a3;
    --text-muted: #4a4f6a;
    --accent: #4f8eff;
    --accent-glow: rgba(79,142,255,0.15);
    --accent-purple: #9f6bff;
    --accent-green: #34d399;
    --accent-amber: #f59e0b;
    --accent-red: #ef4444;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 4px 24px rgba(0,0,0,0.3);
    --transition: 0.2s ease;
    --sidebar-width: 240px;
}

html { scroll-behavior: smooth; }

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg-main);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    -webkit-font-smoothing: antialiased;
    line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* === Sidebar === */
.sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 100;
    padding: 1.5rem 0;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0 1.5rem 1.5rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1rem;
}

.brand-icon {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.8rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent), var(--accent-purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.brand-icon.large { font-size: 2.8rem; }

.brand-text {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text-primary);
}

.sidebar-nav { flex: 1; padding: 0 0.75rem; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 0.75rem;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all var(--transition);
    text-decoration: none;
    margin-bottom: 2px;
}

.nav-item:hover {
    background: var(--accent-glow);
    color: var(--text-primary);
    text-decoration: none;
}

.nav-item.active {
    background: var(--accent-glow);
    color: var(--accent);
}

.nav-item svg { flex-shrink: 0; opacity: 0.7; }
.nav-item.active svg, .nav-item:hover svg { opacity: 1; }

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.user-badge { display: flex; align-items: center; gap: 0.5rem; }

.user-avatar {
    width: 30px; height: 30px;
    border-radius: 50%;
    background: var(--accent-glow);
    color: var(--accent);
    display: flex; align-items: center; justify-content: center;
    font-size: 0.75rem; font-weight: 600;
}

.user-name { font-size: 0.8rem; color: var(--text-secondary); }

.logout-link {
    color: var(--text-muted);
    padding: 4px;
    transition: color var(--transition);
}
.logout-link:hover { color: var(--accent-red); }

/* === Main Content === */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 2rem 2.5rem;
    min-height: 100vh;
}

.main-content.auth-page {
    margin-left: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* === Page Header === */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
}

.page-header h1 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.6rem;
    font-weight: 600;
}

.page-subtitle { color: var(--text-secondary); font-size: 0.85rem; margin-top: 0.2rem; }

/* === Flash Messages === */
.flash-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.flash {
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    animation: slideIn 0.3s ease;
    box-shadow: var(--shadow);
}

.flash-success { background: rgba(52,211,153,0.15); color: var(--accent-green); border: 1px solid rgba(52,211,153,0.3); }
.flash-error { background: rgba(239,68,68,0.15); color: var(--accent-red); border: 1px solid rgba(239,68,68,0.3); }
.flash-info { background: rgba(79,142,255,0.15); color: var(--accent); border: 1px solid rgba(79,142,255,0.3); }

/* === Auth Pages === */
.auth-container {
    width: 100%;
    max-width: 420px;
}

.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2.5rem;
    box-shadow: var(--shadow);
}

.auth-header {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-header h1 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.5rem;
    margin: 0.75rem 0 0.25rem;
}

.auth-header p { color: var(--text-secondary); font-size: 0.85rem; }

.auth-form { display: flex; flex-direction: column; gap: 1rem; }
.auth-footer { text-align: center; margin-top: 1.5rem; font-size: 0.85rem; color: var(--text-secondary); }

/* === Cards === */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.card-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-header h2 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1rem;
    font-weight: 600;
}

.card-body { padding: 1.5rem; }
.card-body.no-padding { padding: 0; }

/* === Metrics Grid === */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.metric-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: all var(--transition);
}

.metric-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.metric-icon {
    width: 48px; height: 48px;
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}

.metric-icon.blue { background: rgba(79,142,255,0.12); color: var(--accent); }
.metric-icon.purple { background: rgba(159,107,255,0.12); color: var(--accent-purple); }
.metric-icon.amber { background: rgba(245,158,11,0.12); color: var(--accent-amber); }
.metric-icon.green { background: rgba(52,211,153,0.12); color: var(--accent-green); }

.metric-value {
    display: block;
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.2;
}

.metric-label { font-size: 0.78rem; color: var(--text-secondary); }

/* === Dashboard Grid === */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
    gap: 1.5rem;
}

/* === Funnel === */
.funnel-list { display: flex; flex-direction: column; gap: 0.75rem; }

.funnel-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.funnel-label { font-size: 0.82rem; color: var(--text-secondary); width: 130px; flex-shrink: 0; }
.funnel-bar-container { flex: 1; height: 8px; background: rgba(255,255,255,0.04); border-radius: 4px; overflow: hidden; }
.funnel-bar { height: 100%; border-radius: 4px; transition: width 0.4s ease; }
.funnel-bar.stage-prospeccao { background: var(--accent); }
.funnel-bar.stage-qualificacao { background: var(--accent-purple); }
.funnel-bar.stage-proposta { background: var(--accent-amber); }
.funnel-bar.stage-negociacao { background: #f97316; }
.funnel-bar.stage-fechado_ganho { background: var(--accent-green); }
.funnel-bar.stage-fechado_perdido { background: var(--accent-red); }
.funnel-count { font-size: 0.85rem; font-weight: 600; color: var(--text-primary); width: 30px; text-align: right; }

/* === Activity List === */
.activity-list { display: flex; flex-direction: column; gap: 0.6rem; }

.activity-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--border);
}
.activity-item:last-child { border-bottom: none; }

.activity-type-badge {
    font-size: 0.6rem;
    font-weight: 700;
    padding: 3px 6px;
    border-radius: 4px;
    letter-spacing: 0.05em;
    flex-shrink: 0;
}

.type-call { background: rgba(79,142,255,0.15); color: var(--accent); }
.type-meeting { background: rgba(159,107,255,0.15); color: var(--accent-purple); }
.type-email { background: rgba(245,158,11,0.15); color: var(--accent-amber); }
.type-task { background: rgba(52,211,153,0.15); color: var(--accent-green); }
.type-note { background: rgba(255,255,255,0.05); color: var(--text-secondary); }

.activity-info { flex: 1; min-width: 0; }
.activity-title { display: block; font-size: 0.85rem; font-weight: 500; }
.activity-meta { display: block; font-size: 0.72rem; color: var(--text-muted); }
.activity-status { font-size: 1rem; color: var(--text-muted); }
.activity-status.done { color: var(--accent-green); }

/* === Forms === */
.form-group { display: flex; flex-direction: column; gap: 0.35rem; }

.form-group label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-group input,
.form-group select,
.form-group textarea {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.6rem 0.85rem;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.88rem;
    transition: border-color var(--transition);
    outline: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { border-color: var(--accent); }

.form-group textarea { resize: vertical; min-height: 80px; }

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
}

.full-width { grid-column: 1 / -1; }

.form-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    padding-top: 0.5rem;
}

/* === Buttons === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.55rem 1.1rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    border: none;
    transition: all var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

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

.btn-primary {
    background: var(--accent);
    color: #fff;
}
.btn-primary:hover { background: #3a7ae6; box-shadow: 0 0 20px var(--accent-glow); }

.btn-secondary {
    background: rgba(255,255,255,0.06);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.btn-secondary:hover { background: rgba(255,255,255,0.1); color: var(--text-primary); }

.btn-full { width: 100%; }

.btn-icon {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    font-size: 0.9rem;
    transition: color var(--transition);
}
.btn-icon:hover { color: var(--accent); }
.btn-icon.danger:hover { color: var(--accent-red); }
.btn-icon.small { font-size: 0.75rem; }

/* === Search === */
.search-form {
    display: flex;
    gap: 0.5rem;
    flex: 1;
}

.search-input {
    flex: 1;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.85rem;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.85rem;
    outline: none;
}
.search-input:focus { border-color: var(--accent); }

/* === Data Table === */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    text-align: left;
    padding: 0.75rem 1.25rem;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    background: rgba(255,255,255,0.02);
    border-bottom: 1px solid var(--border);
}

.data-table td {
    padding: 0.75rem 1.25rem;
    font-size: 0.85rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
}

.data-table tbody tr { transition: background var(--transition); }
.data-table tbody tr:hover { background: rgba(255,255,255,0.02); }
.data-table tbody tr:last-child td { border-bottom: none; }

.td-name { color: var(--text-primary); font-weight: 500; }
.td-actions { display: flex; align-items: center; gap: 0.5rem; }
.inline-form { display: inline; }

/* === Kanban Board === */
.kanban-board {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    padding-bottom: 1rem;
}

.kanban-column {
    min-width: 260px;
    max-width: 300px;
    flex-shrink: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
}

.kanban-header {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.kanban-title {
    font-size: 0.82rem;
    font-weight: 600;
    font-family: 'Space Grotesk', sans-serif;
}

.kanban-count {
    font-size: 0.7rem;
    font-weight: 700;
    background: rgba(255,255,255,0.06);
    color: var(--text-secondary);
    padding: 2px 8px;
    border-radius: 10px;
}

.kanban-cards {
    padding: 0.75rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-height: 120px;
    transition: background var(--transition);
}

.kanban-cards.drag-over { background: var(--accent-glow); }

.kanban-card {
    background: var(--bg-main);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.85rem 1rem;
    cursor: grab;
    transition: all var(--transition);
    position: relative;
}

.kanban-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.kanban-card.dragging { opacity: 0.4; }

.deal-title {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.35rem;
}

.deal-value {
    font-size: 0.8rem;
    color: var(--accent-green);
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.deal-contact, .deal-company {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.deal-actions {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    opacity: 0;
    transition: opacity var(--transition);
}

.kanban-card:hover .deal-actions { opacity: 1; }

/* === Modal === */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    z-index: 200;
    align-items: center;
    justify-content: center;
}

.modal-overlay.show { display: flex; }

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 90%;
    max-width: 500px;
    max-height: 85vh;
    overflow-y: auto;
}

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h2 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.1rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.3rem;
    cursor: pointer;
    transition: color var(--transition);
}
.modal-close:hover { color: var(--text-primary); }

.modal-body {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

/* === Empty State === */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* === Animations === */
@keyframes slideIn {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

/* === Responsive === */
@media (max-width: 768px) {
    .sidebar {
        width: 60px;
        overflow: hidden;
    }
    .sidebar .brand-text,
    .sidebar .nav-item span,
    .sidebar .user-name { display: none; }
    .sidebar-brand { padding: 0 0.75rem 1rem; justify-content: center; }
    .sidebar-nav { padding: 0 0.5rem; }
    .nav-item { justify-content: center; padding: 0.7rem; }
    .sidebar-footer { flex-direction: column; gap: 0.5rem; padding: 0.75rem; }
    .main-content { margin-left: 60px; padding: 1.5rem; }
    .kanban-board { flex-direction: column; }
    .kanban-column { max-width: none; min-width: auto; }
    .metrics-grid { grid-template-columns: 1fr 1fr; }
    .dashboard-grid { grid-template-columns: 1fr; }
    .form-grid { grid-template-columns: 1fr; }
}
