/* ============================================
   LEGNSOFT LEADS CRM - Main Stylesheet
   ============================================ */

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

/* === CSS VARIABLES === */
:root {
    --primary:        #2563EB;
    --primary-light:  #EFF6FF;
    --primary-dark:   #1D4ED8;
    --accent:         #0EA5E9;
    --success:        #10B981;
    --warning:        #F59E0B;
    --danger:         #EF4444;
    --purple:         #8B5CF6;

    --bg:             #F8FAFC;
    --bg-card:        #FFFFFF;
    --sidebar-bg:     #0F172A;
    --sidebar-text:   #94A3B8;
    --sidebar-active: #FFFFFF;

    --text:           #0F172A;
    --text-muted:     #64748B;
    --text-light:     #94A3B8;

    --border:         #E2E8F0;
    --border-light:   #F1F5F9;
    --shadow-sm:      0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --shadow:         0 4px 16px rgba(0,0,0,.08);
    --shadow-lg:      0 10px 40px rgba(0,0,0,.12);

    --radius:         10px;
    --radius-sm:      6px;
    --radius-lg:      16px;
    --sidebar-w:      240px;
    --font:           'Plus Jakarta Sans', sans-serif;
    --font-mono:      'JetBrains Mono', monospace;
    --transition:     .2s ease;
}

/* === RESET === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body { font-family: var(--font); background: var(--bg); color: var(--text); min-height: 100vh; display: flex; }
a { text-decoration: none; color: inherit; }
ul { list-style: none; }
input, select, textarea, button { font-family: var(--font); font-size: 1rem; }

/* === SCROLLBAR === */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }

/* === LAYOUT === */
.layout { display: flex; width: 100%; min-height: 100vh; }

/* === SIDEBAR === */
.sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    transition: transform var(--transition);
}

.sidebar-logo {
    padding: 24px 20px 20px;
    border-bottom: 1px solid rgba(255,255,255,.06);
}

.sidebar-logo .logo-mark {
    display: flex; align-items: center; gap: 10px;
}

.logo-icon {
    width: 36px; height: 36px;
    background: var(--primary);
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; font-weight: 700; color: #fff;
    letter-spacing: -1px;
}

.logo-text { font-size: 1rem; font-weight: 700; color: #fff; line-height: 1.1; }
.logo-text span { display: block; font-size: .65rem; font-weight: 400; color: var(--sidebar-text); letter-spacing: .05em; text-transform: uppercase; }

.sidebar-nav { flex: 1; padding: 16px 12px; overflow-y: auto; }

.nav-section-label {
    font-size: .6rem; font-weight: 600; letter-spacing: .1em; text-transform: uppercase;
    color: #475569; padding: 8px 8px 6px; margin-top: 8px;
}

.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 12px; border-radius: var(--radius-sm);
    color: var(--sidebar-text); font-size: .875rem; font-weight: 500;
    cursor: pointer; transition: all var(--transition); margin-bottom: 2px;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-item .nav-icon { width: 18px; text-align: center; flex-shrink: 0; }

.sidebar-footer {
    padding: 16px 12px;
    border-top: 1px solid rgba(255,255,255,.06);
}

.user-info {
    display: flex; align-items: center; gap: 10px;
    padding: 8px; border-radius: var(--radius-sm);
}
.user-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--primary); display: flex; align-items: center; justify-content: center;
    font-size: .75rem; font-weight: 700; color: #fff; flex-shrink: 0;
}
.user-name { font-size: .8rem; font-weight: 600; color: #fff; }
.user-role { font-size: .65rem; color: var(--sidebar-text); }

.logout-btn {
    display: flex; align-items: center; gap: 8px;
    width: 100%; padding: 8px 12px; border-radius: var(--radius-sm);
    background: none; border: none; color: #EF4444; font-size: .8rem; font-weight: 500;
    cursor: pointer; transition: background var(--transition); margin-top: 4px;
}
.logout-btn:hover { background: rgba(239,68,68,.1); }

/* === MAIN CONTENT === */
.main-content {
    margin-left: var(--sidebar-w);
    flex: 1; display: flex; flex-direction: column; min-height: 100vh;
}

.topbar {
    background: var(--bg-card); border-bottom: 1px solid var(--border);
    padding: 0 28px; height: 60px;
    display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; z-index: 50;
}

.topbar-left { display: flex; align-items: center; gap: 12px; }
.page-title { font-size: 1.1rem; font-weight: 700; }
.breadcrumb { font-size: .8rem; color: var(--text-muted); display: flex; align-items: center; gap: 6px; }
.breadcrumb span { color: var(--text-light); }

.topbar-right { display: flex; align-items: center; gap: 12px; }

.mobile-menu-btn {
    display: none; background: none; border: none; cursor: pointer;
    color: var(--text); font-size: 1.2rem; padding: 6px;
}

.content-area { padding: 28px; flex: 1; }

/* === CARDS === */
.card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 24px;
    box-shadow: var(--shadow-sm);
}

/* === STAT CARDS === */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 28px; }

.stat-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 20px 22px;
    display: flex; align-items: center; gap: 16px;
    transition: transform var(--transition), box-shadow var(--transition);
    box-shadow: var(--shadow-sm);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }

.stat-icon {
    width: 48px; height: 48px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem; flex-shrink: 0;
}
.stat-icon.blue   { background: #EFF6FF; color: var(--primary); }
.stat-icon.green  { background: #ECFDF5; color: var(--success); }
.stat-icon.orange { background: #FFFBEB; color: var(--warning); }
.stat-icon.red    { background: #FEF2F2; color: var(--danger); }

.stat-value { font-size: 1.8rem; font-weight: 700; line-height: 1; }
.stat-label { font-size: .78rem; color: var(--text-muted); margin-top: 4px; font-weight: 500; }

/* === BUTTONS === */
.btn {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 9px 18px; border-radius: var(--radius-sm);
    font-size: .875rem; font-weight: 600; cursor: pointer; border: none;
    transition: all var(--transition); white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { filter: brightness(1.1); }
.btn-danger  { background: var(--danger); color: #fff; }
.btn-danger:hover  { filter: brightness(1.1); }
.btn-outline {
    background: transparent; color: var(--text);
    border: 1.5px solid var(--border);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.btn-sm { padding: 6px 12px; font-size: .8rem; }
.btn-icon { padding: 8px; border-radius: var(--radius-sm); background: var(--bg); border: 1px solid var(--border); cursor: pointer; transition: all var(--transition); color: var(--text-muted); }
.btn-icon:hover { border-color: var(--primary); color: var(--primary); }

/* === BADGE / STATUS === */
.badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 10px; border-radius: 99px; font-size: .72rem; font-weight: 600;
}
.badge-green  { background: #ECFDF5; color: #059669; }
.badge-red    { background: #FEF2F2; color: #DC2626; }
.badge-yellow { background: #FFFBEB; color: #D97706; }
.badge-gray   { background: #F1F5F9; color: #64748B; }
.badge-blue   { background: #EFF6FF; color: #2563EB; }

/* === PRIORITY STARS === */
.stars { display: inline-flex; gap: 2px; color: #CBD5E1; font-size: .85rem; }
.stars .filled { color: #F59E0B; }

/* === TABLE === */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead tr { background: var(--bg); }
th {
    padding: 11px 16px; text-align: left; font-size: .75rem; font-weight: 600;
    color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em;
    border-bottom: 1px solid var(--border); white-space: nowrap;
}
td { padding: 13px 16px; border-bottom: 1px solid var(--border-light); font-size: .875rem; vertical-align: middle; }
tbody tr { transition: background var(--transition); }
tbody tr:hover { background: var(--bg); }
tbody tr:last-child td { border-bottom: none; }

.lead-name-cell { font-weight: 600; color: var(--text); }
.lead-mobile { font-family: var(--font-mono); font-size: .82rem; color: var(--primary); }

/* === FORMS === */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full { grid-column: 1 / -1; }

label { font-size: .8rem; font-weight: 600; color: var(--text-muted); letter-spacing: .01em; }

.form-control {
    padding: 10px 14px; border: 1.5px solid var(--border);
    border-radius: var(--radius-sm); background: var(--bg-card);
    font-size: .9rem; color: var(--text); transition: border-color var(--transition), box-shadow var(--transition);
    width: 100%;
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.form-control::placeholder { color: var(--text-light); }

select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 100px; }

.form-hint { font-size: .72rem; color: var(--text-light); }

/* === STAR RATING INPUT === */
.star-rating { display: flex; gap: 6px; flex-direction: row-reverse; }
.star-rating input { display: none; }
.star-rating label {
    font-size: 1.5rem; color: #CBD5E1; cursor: pointer;
    transition: color var(--transition);
}
.star-rating label:hover,
.star-rating label:hover ~ label,
.star-rating input:checked ~ label { color: #F59E0B; }

/* === TODO BUTTONS === */
.todo-options { display: flex; gap: 8px; flex-wrap: wrap; }
.todo-btn {
    padding: 8px 16px; border-radius: 99px; border: 1.5px solid var(--border);
    background: none; font-size: .82rem; font-weight: 500; cursor: pointer;
    transition: all var(--transition); color: var(--text-muted);
}
.todo-btn:hover, .todo-btn.selected {
    border-color: var(--primary); background: var(--primary); color: #fff;
}

/* === SERVICE TAGS === */
.service-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.service-tag {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 10px; background: var(--primary-light); color: var(--primary);
    border-radius: 99px; font-size: .75rem; font-weight: 600;
}
.service-tag .remove { cursor: pointer; line-height: 1; opacity: .7; }
.service-tag .remove:hover { opacity: 1; }

.service-input-row { display: flex; gap: 8px; margin-top: 8px; }
.service-input-row input { flex: 1; }

/* === SEARCH BAR === */
.search-filter-bar {
    display: flex; gap: 12px; align-items: center; margin-bottom: 20px; flex-wrap: wrap;
}
.search-wrapper { position: relative; flex: 1; min-width: 200px; }
.search-wrapper .search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-light); pointer-events: none; }
.search-input { width: 100%; padding: 10px 14px 10px 38px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); font-size: .875rem; background: var(--bg-card); color: var(--text); transition: border-color var(--transition); }
.search-input:focus { outline: none; border-color: var(--primary); }
.filter-select { padding: 10px 14px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); font-size: .875rem; background: var(--bg-card); cursor: pointer; color: var(--text); min-width: 140px; }
.filter-select:focus { outline: none; border-color: var(--primary); }

/* === ACTIVITY TIMELINE === */
.timeline { position: relative; padding-left: 28px; }
.timeline::before { content: ''; position: absolute; left: 9px; top: 0; bottom: 0; width: 2px; background: var(--border); }
.timeline-item { position: relative; margin-bottom: 20px; }
.timeline-dot {
    position: absolute; left: -24px; top: 4px;
    width: 10px; height: 10px; border-radius: 50%;
    background: var(--primary); border: 2px solid var(--bg-card);
    outline: 2px solid var(--primary);
}
.timeline-time { font-size: .7rem; color: var(--text-light); margin-bottom: 4px; font-family: var(--font-mono); }
.timeline-note { font-size: .875rem; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 14px; }

/* === WHATSAPP BTN === */
.wa-btn {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 8px 16px; background: #25D366; color: #fff;
    border-radius: var(--radius-sm); font-size: .82rem; font-weight: 600;
    transition: filter var(--transition);
}
.wa-btn:hover { filter: brightness(1.1); }

/* === PAGINATION === */
.pagination { display: flex; align-items: center; gap: 6px; justify-content: flex-end; margin-top: 16px; }
.page-btn {
    width: 34px; height: 34px; border-radius: var(--radius-sm); border: 1.5px solid var(--border);
    background: var(--bg-card); display: flex; align-items: center; justify-content: center;
    font-size: .82rem; cursor: pointer; transition: all var(--transition); font-weight: 500;
}
.page-btn:hover { border-color: var(--primary); color: var(--primary); }
.page-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* === ALERTS === */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); font-size: .875rem; margin-bottom: 16px; display: flex; align-items: center; gap: 10px; }
.alert-success { background: #ECFDF5; color: #065F46; border: 1px solid #A7F3D0; }
.alert-error   { background: #FEF2F2; color: #991B1B; border: 1px solid #FECACA; }

/* === SECTION HEADER === */
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.section-title { font-size: 1rem; font-weight: 700; }
.section-subtitle { font-size: .8rem; color: var(--text-muted); margin-top: 2px; }

/* === EMPTY STATE === */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 16px; opacity: .4; }
.empty-state p { font-size: .9rem; }

/* === LOGIN PAGE === */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #0F172A 0%, #1E293B 50%, #0F172A 100%); }
.login-card { background: #fff; border-radius: var(--radius-lg); padding: 48px 44px; width: 100%; max-width: 420px; box-shadow: var(--shadow-lg); }
.login-logo { text-align: center; margin-bottom: 32px; }
.login-logo .logo-icon { width: 52px; height: 52px; margin: 0 auto 12px; font-size: 22px; border-radius: 14px; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; }
.login-logo h1 { font-size: 1.4rem; font-weight: 800; }
.login-logo p { font-size: .85rem; color: var(--text-muted); margin-top: 4px; }
.login-form .form-group { margin-bottom: 18px; }
.login-form .form-control { width: 100%; }
.login-form .btn { width: 100%; padding: 12px; font-size: 1rem; border-radius: var(--radius-sm); justify-content: center; margin-top: 4px; }

/* === DETAIL GRID === */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.detail-item label { font-size: .72rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; display: block; margin-bottom: 4px; }
.detail-value { font-size: .92rem; font-weight: 500; }

/* === FOLLOW-UP HIGHLIGHT === */
.follow-up-pending { border-left: 3px solid var(--warning) !important; }

/* === MOBILE OVERLAY === */
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 99; }

/* ===== RESPONSIVE ===== */
@media (max-width: 1200px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay.open { display: block; }
    .main-content { margin-left: 0; }
    .mobile-menu-btn { display: flex; }
    .content-area { padding: 20px 16px; }
    .form-grid { grid-template-columns: 1fr; }
    .detail-grid { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .search-filter-bar { flex-direction: column; align-items: stretch; }
}
@media (max-width: 400px) {
    .stats-grid { grid-template-columns: 1fr; }
    .login-card { padding: 32px 24px; }
}
