/* ============================================================
   Sello CRM v2 — Main Stylesheet
   ============================================================ */

:root {
    --sello-primary:       #4f46e5;
    --sello-sidebar-bg:    #ffffff;
    --sello-sidebar-text:  #475569;
    --sello-sidebar-w:     234px;
    --sello-topbar-h:      56px;
    --sello-text:          #1e293b;
    --sello-muted:         #64748b;
    --sello-border:        #e2e8f0;
    --sello-bg:            #f8fafc;
    --sello-card-bg:       #ffffff;
}

/* ── Reset / Base ──────────────────────────────────────────── */
* { box-sizing: border-box; }

body {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: 0.875rem;
    color: var(--sello-text);
    background: var(--sello-bg);
    margin: 0;
}

/* ── Layout ────────────────────────────────────────────────── */
#wrapper {
    min-height: 100vh;
}

/* ── Sidebar ───────────────────────────────────────────────── */
#sidebar {
    width: var(--sello-sidebar-w);
    min-height: 100vh;
    background: var(--sello-sidebar-bg);
    border-right: 1px solid var(--sello-border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: margin-left 0.2s ease;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-header {
    padding: 1.25rem 1rem;
    border-bottom: 1px solid var(--sello-border);
}

.sidebar-brand {
    text-decoration: none;
    color: var(--sello-primary);
    font-size: 1.05rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.sidebar-brand-text { color: var(--sello-primary); }

.sidebar-logo {
    max-height: 36px;
    max-width: 160px;
    object-fit: contain;
}

.sidebar-nav {
    list-style: none;
    padding: 0.5rem 0;
    margin: 0;
    flex: 1;
}

.sidebar-nav .nav-item { margin: 0; }

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    margin: 1px 0.5rem;
    padding: 0.5rem 0.75rem;
    color: var(--sello-sidebar-text);
    text-decoration: none;
    font-size: 0.82rem;
    font-weight: 500;
    border-radius: 0.5rem;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
}

.sidebar-nav .nav-link:hover {
    background: #f1f5f9;
    color: var(--sello-text);
}

.sidebar-nav .nav-link.active {
    background: rgba(79,70,229,0.1);
    color: var(--sello-primary);
    font-weight: 600;
}

.sidebar-nav .nav-link .material-icons-two-tone {
    font-size: 19px;
    flex-shrink: 0;
    opacity: 0.85;
}

.sidebar-nav .nav-link.active .material-icons-two-tone { opacity: 1; }

.nav-section-label {
    padding: 1rem 1.25rem 0.35rem;
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #94a3b8;
}

.sidebar-footer {
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--sello-border);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: #f8fafc;
}

.sidebar-footer a { color: var(--sello-text) !important; }
.sidebar-footer .opacity-75, .sidebar-footer .opacity-50 { color: var(--sello-muted) !important; opacity: 1 !important; }

.avatar-sm {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--sello-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    flex-shrink: 0;
}

.x-small { font-size: 0.7rem; }

/* ── Topbar ────────────────────────────────────────────────── */
#page-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar {
    height: var(--sello-topbar-h);
    background: #fff;
    border-bottom: 1px solid var(--sello-border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.search-bar .form-control {
    width: 240px;
    font-size: 0.8rem;
}

/* ── Content area ──────────────────────────────────────────── */
.content-area {
    padding: 1.5rem;
    flex: 1;
}

/* ── Cards ─────────────────────────────────────────────────── */
.card {
    border: 1px solid var(--sello-border);
    border-radius: 0.75rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.card-header {
    background: #fff;
    border-bottom: 1px solid var(--sello-border);
    padding: 0.875rem 1.25rem;
    font-weight: 600;
}

/* ── Account / Contact cards ───────────────────────────────── */
.account-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1rem;
}

.account-card {
    background: #fff;
    border: 1px solid var(--sello-border);
    border-radius: 0.75rem;
    padding: 1rem;
    transition: box-shadow 0.15s, border-color 0.15s;
    text-decoration: none;
    color: inherit;
    display: block;
}

.account-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    border-color: var(--sello-primary);
    color: inherit;
}

.account-card-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--sello-text);
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.account-card-meta {
    font-size: 0.75rem;
    color: var(--sello-muted);
}

.account-card-type {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.15rem 0.5rem;
    border-radius: 100px;
    background: #e0e7ff;
    color: #3730a3;
    margin-bottom: 0.5rem;
}

/* ── Star button ───────────────────────────────────────────── */
.btn-star {
    background: none;
    border: none;
    padding: 0;
    color: #cbd5e1;
    cursor: pointer;
    transition: color 0.15s;
    line-height: 1;
}

.btn-star:hover,
.btn-star.starred { color: #f59e0b; }

/* ── KPI tiles ─────────────────────────────────────────────── */
.kpi-card {
    background: #fff;
    border: 1px solid var(--sello-border);
    border-radius: 0.75rem;
    padding: 1.25rem;
}

.kpi-label {
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--sello-muted);
    margin-bottom: 0.4rem;
}

.kpi-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--sello-text);
    line-height: 1;
}

.kpi-icon {
    width: 40px;
    height: 40px;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

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

.kanban-col {
    min-width: 240px;
    width: 240px;
    background: #f1f5f9;
    border-radius: 0.75rem;
    padding: 0.75rem;
    flex-shrink: 0;
}

.kanban-col-header {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--sello-muted);
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.kanban-card {
    background: #fff;
    border: 1px solid var(--sello-border);
    border-radius: 0.5rem;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    font-size: 0.8rem;
    cursor: pointer;
    transition: box-shadow 0.15s;
}

.kanban-card:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* ── Activity timeline ─────────────────────────────────────── */
.timeline { position: relative; padding-left: 2rem; }

.timeline::before {
    content: '';
    position: absolute;
    left: 0.6rem;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--sello-border);
}

.timeline-item {
    position: relative;
    margin-bottom: 1.25rem;
}

.timeline-icon {
    position: absolute;
    left: -2rem;
    top: 0.15rem;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--sello-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    flex-shrink: 0;
}

.timeline-body {
    background: #fff;
    border: 1px solid var(--sello-border);
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
}

.timeline-meta {
    font-size: 0.72rem;
    color: var(--sello-muted);
}

/* ── Invoice status badges ─────────────────────────────────── */
.badge-status {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.2rem 0.5rem;
    border-radius: 100px;
}

.badge-created   { background: #e2e8f0; color: #475569; }
.badge-sent      { background: #dbeafe; color: #1d4ed8; }
.badge-half-paid { background: #fef3c7; color: #92400e; }
.badge-fully-paid{ background: #dcfce7; color: #166534; }
.badge-void      { background: #fee2e2; color: #991b1b; }

/* ── Tables ────────────────────────────────────────────────── */
.table { font-size: 0.82rem; }
.table th { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--sello-muted); }
.table-hover tbody tr:hover { background: #f8fafc; }

/* ── Forms ─────────────────────────────────────────────────── */
.form-label { font-size: 0.8rem; font-weight: 500; color: var(--sello-text); }
.form-control, .form-select { font-size: 0.85rem; }
.form-section-title {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--sello-muted);
    border-bottom: 1px solid var(--sello-border);
    padding-bottom: 0.4rem;
    margin-bottom: 1rem;
}

/* ── Auth layout ───────────────────────────────────────────── */
.auth-body {
    background: linear-gradient(135deg, #e0e7ff 0%, #f8fafc 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-wrapper {
    width: 100%;
    max-width: 420px;
    padding: 1rem;
}

.auth-card {
    background: #fff;
    border-radius: 1rem;
    padding: 2.5rem;
    box-shadow: 0 10px 40px rgba(0,0,0,0.1);
}

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

/* ── Utilities ─────────────────────────────────────────────── */
.text-primary { color: var(--sello-primary) !important; }
.bg-primary   { background: var(--sello-primary) !important; }
.btn-primary  { background: var(--sello-primary); border-color: var(--sello-primary); }
.btn-primary:hover { background: #4338ca; border-color: #4338ca; }

.cursor-pointer { cursor: pointer; }
.gap-1 { gap: 0.25rem; }

/* Extra-small buttons */
.btn-xs {
    padding: 0.15rem 0.5rem;
    font-size: 0.72rem;
    border-radius: 0.35rem;
    line-height: 1.4;
}

/* ── Sidebar collapse (desktop) ────────────────────────────── */
#wrapper.sidebar-collapsed #sidebar {
    margin-left: calc(-1 * var(--sello-sidebar-w));
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 768px) {
    #sidebar {
        position: fixed;
        z-index: 200;
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        box-shadow: 2px 0 12px rgba(0,0,0,0.1);
    }

    #sidebar.show {
        transform: translateX(0);
    }

    /* On mobile, the collapse class shouldn't push it off twice */
    #wrapper.sidebar-collapsed #sidebar { margin-left: 0; }

    .search-bar .form-control { width: 140px; }
}
