/* --- 1. CORE VARIABLES --- */
:root {
    /* Layout Dimensions */
    --sb-expanded: 260px;
    --sb-collapsed: 80px;
    --current-sb-w: var(--sb-expanded);
    
    /* Phone Dimensions (Added these!) */
    --phone-w: 400px;
    --phone-w-wide: 700px;

    /* Colors */
    --c-primary: #4f46e5; 
    --c-success: #10b981; 
    --c-danger: #ef4444; 
    --c-warning: #f59e0b;
    --c-purple: #8b5cf6;
    --c-bg: #f3f4f6; 
    --c-text: #111827;
    --c-dark: #0f172a;
    --c-border: #e5e7eb; /* Added missing border var */
}

body { 
    background: var(--c-bg); 
    font-family: 'Inter', sans-serif; 
    overflow: hidden; 
    margin: 0; 
    color: var(--c-text); 
}

/* --- 2. DYNAMIC LAYOUT --- */

/* Main Wrapper Adjusts to Sidebar & Phone */
.main-wrapper {
    margin-left: var(--current-sb-w); 
    padding: 30px; 
    height: 100vh; 
    overflow-y: auto;
    background-color: #f8fafc; /* Consolidated from bottom */
    transition: margin-left 0.3s ease, margin-right 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* Phone Pinned States */
body.is-pinned .main-wrapper { margin-right: var(--phone-w); }
body.is-pinned.is-wide .main-wrapper { margin-right: var(--phone-w-wide); }

/* Sidebar Collapsed State Logic */
body.sb-collapsed { --current-sb-w: var(--sb-collapsed); }

/* --- 3. SIDEBAR --- */
.sidebar { 
    width: var(--current-sb-w); 
    height: 100vh; 
    background: var(--c-dark); 
    position: fixed; left: 0; top: 0; z-index: 1000; 
    display: flex; flex-direction: column; 
    transition: width 0.3s ease;
    overflow: hidden;
    border-right: 1px solid rgba(255,255,255,0.05);
}

/* Header & Logo */
.sb-header { 
    height: 80px; 
    display: flex; align-items: center; 
    padding-left: 28px; 
    white-space: nowrap; 
    overflow: hidden; 
    transition: all 0.3s ease;
}

/* Logo Logic (Fixed Selector Mismatch) */
.logo-full { display: block; }
.logo-mini { display: none; }

body.sb-collapsed .logo-full { display: none; }
body.sb-collapsed .logo-mini { display: block; margin: 0 auto; }
body.sb-collapsed .sb-header { padding-left: 0; justify-content: center; }

/* Navigation */
.sb-nav { flex: 1; padding: 20px 15px; display: flex; flex-direction: column; gap: 8px; }
.nav-item { 
    display: flex; align-items: center; 
    padding: 12px 14px; 
    border-radius: 12px; 
    color: #94a3b8; 
    cursor: pointer; 
    transition: 0.2s; 
    white-space: nowrap;
    height: 50px;
}
.nav-item:hover { background: rgba(255,255,255,0.05); color: white; }
.nav-item.active { background: #03a5ef; color: white; box-shadow: 0 4px 15px rgba(3, 165, 239, 0.4); }

.nav-icon { font-size: 20px; min-width: 24px; display: flex; justify-content: center; }
.nav-label { margin-left: 15px; font-weight: 500; font-size: 14px; opacity: 1; transition: opacity 0.2s; }

/* Collapse Toggle */
.sb-footer { padding: 20px; border-top: 1px solid rgba(255,255,255,0.1); }
.toggle-sb-btn { 
    width: 100%; height: 40px; border-radius: 8px; border: 1px solid rgba(255,255,255,0.1); 
    background: transparent; color: #64748b; cursor: pointer; transition: 0.2s;
    display: flex; align-items: center; justify-content: center;
}
.toggle-sb-btn:hover { background: rgba(255,255,255,0.05); color: white; }

/* Collapsed Body Overrides */
body.sb-collapsed .nav-label { opacity: 0; pointer-events: none; display: none; }
body.sb-collapsed .nav-item { justify-content: center; padding: 0; width: 50px; margin: 0 auto; }
body.sb-collapsed .nav-icon { margin: 0; }
body.sb-collapsed .toggle-sb-btn i { transform: rotate(180deg); }

/* --- 4. LEADS KANBAN --- */
.kanban-container { display: flex; gap: 25px; min-width: 1000px; padding-bottom: 120px; }
.kanban-col { flex: 1; background: #e5e7eb; border-radius: 16px; padding: 16px; min-height: 80vh; display: flex; flex-direction: column; gap: 12px; }

.lead-card {
    background: white; border-radius: 12px; padding: 16px; 
    border-left: 4px solid #ccc; box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    cursor: grab; transition: all 0.2s ease; position: relative;
}
.lead-card:hover { transform: translateY(-3px); box-shadow: 0 10px 25px rgba(0,0,0,0.1); z-index: 10; }

.lc-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.lc-source { font-size: 10px; font-weight: 800; text-transform: uppercase; padding: 4px 8px; border-radius: 6px; display: flex; align-items: center; gap: 5px; }
.lc-time { font-size: 11px; color: #6b7280; font-weight: 500; }
.lc-body h5 { font-size: 15px; font-weight: 700; margin: 0 0 4px 0; color: #111; }
.lc-body p { font-size: 12px; color: #6b7280; margin: 0; line-height: 1.4; }
.lc-footer { margin-top: 12px; padding-top: 10px; border-top: 1px solid #f3f4f6; display: flex; justify-content: space-between; align-items: center; }
.lc-tag { font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 4px; }
.lc-tag.urgent { background: #fef2f2; color: #ef4444; }
.lc-tag.normal { background: #f0f9ff; color: #0ea5e9; }

.l-phone { border-left-color: var(--c-success); } .l-phone .lc-source { background: #ecfdf5; color: var(--c-success); }
.l-yelp { border-left-color: var(--c-danger); } .l-yelp .lc-source { background: #fef2f2; color: var(--c-danger); }
.l-thumbtack { border-left-color: var(--c-primary); } .l-thumbtack .lc-source { background: #eef2ff; color: var(--c-primary); }

/* --- 5. PHONE WIDGET --- */
#caesarPhone {
    position: fixed; z-index: 2100; /* Increased to stay above standard drawers */
    background: #fff;
    display: flex; flex-direction: column;
    box-shadow: -15px 0 60px rgba(0,0,0,0.15); border: 1px solid #d1d5db;
    transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    overflow: hidden; display: none;
}
#caesarPhone.floating { top: 60px; right: 30px; width: 420px; height: 850px; border-radius: 20px; }
#caesarPhone.pinned { top: 0 !important; right: 0 !important; bottom: 0 !important; height: 100vh !important; width: var(--phone-w); border-radius: 0; border: none; border-left: 1px solid #ccc; }
#caesarPhone.pinned.wide { width: var(--phone-w-wide); }

.cp-header { padding: 12px 16px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid #f1f5f9; background: #fff; user-select: none; }
.cp-btn-group { display: flex; gap: 8px; }
.cp-btn { width: 34px; height: 34px; border-radius: 8px; background: #f3f4f6; color: #6b7280; border: none; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: 0.2s; }
.cp-btn:hover { background: #e5e7eb; color: var(--c-primary); }
.cp-btn.active { background: #e0e7ff; color: var(--c-primary); border: 1px solid #c7d2fe; }
.cp-btn.close { background: #fef2f2; color: var(--c-danger); }

#btnResize { display: none; }
#caesarPhone.pinned #btnResize { display: flex; }

.cp-metrics { padding: 12px 16px; border-bottom: 1px solid #f1f5f9; background: white; }
.cp-meta { display: flex; justify-content: space-between; font-size: 10px; font-weight: 800; color: #9ca3af; text-transform: uppercase; margin-bottom: 4px; }
.cp-track-gradient { height: 6px; border-radius: 3px; background: linear-gradient(90deg, #ef4444 0%, #4f46e5 50%, #10b981 100%); position: relative; margin-bottom: 10px; }
.cp-marker { position: absolute; top: -2px; bottom: -2px; width: 2px; background: #111; left: 65%; }
.cp-track-green { height: 4px; background: #e5e7eb; border-radius: 2px; overflow: hidden; }
.cp-fill-green { height: 100%; width: 90%; background: #10b981; }

.cp-stack { padding: 10px 16px 0; display: flex; flex-direction: column; gap: 8px; }
.call-card { padding: 10px 14px; border-radius: 8px; display: flex; justify-content: space-between; align-items: center; box-shadow: 0 1px 2px rgba(0,0,0,0.03); }
.cc-spam { background: #fef2f2; border-left: 4px solid #ef4444; }
.cc-support { background: #fffbeb; border-left: 4px solid #f59e0b; }

.cp-chat { flex: 1; padding: 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; background: white; }
.bubble { padding: 10px 14px; border-radius: 12px; font-size: 13px; max-width: 85%; }
.b-them { background: white; border: 1px solid #e5e7eb; align-self: flex-start; }
.b-me { background: var(--c-primary); color: white; align-self: flex-end; }
.ai-hint-box { border: 1px dashed var(--c-purple); background: #f5f3ff; border-radius: 10px; padding: 10px 14px; cursor: pointer; position: relative; }
.ai-label { color: var(--c-purple); font-weight: 800; font-size: 10px; text-transform: uppercase; display: flex; align-items: center; gap: 4px; margin-bottom: 4px; }

.cp-footer { padding: 16px 20px; background: #fff; border-top: 1px solid #f1f5f9; display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; justify-items: center; }
.foot-btn { width: 48px; height: 48px; border-radius: 50%; background: #f3f4f6; color: #4b5563; border: none; font-size: 18px; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: 0.2s; }
.foot-btn:hover { background: #e5e7eb; }
.foot-btn.hangup { background: #fee2e2; color: #ef4444; width: 56px; height: 56px; font-size: 22px; }

/* --- 6. DRAWERS (Tasks & Leads) --- */
.lead-drawer, .task-drawer { 
    position: fixed; top: 0; right: -650px; 
    width: 600px; height: 100vh; 
    background: white; box-shadow: -10px 0 60px rgba(0,0,0,0.15); 
    z-index: 1900; /* Must be lower than phone when phone is floating */
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1); 
    display: flex; flex-direction: column; 
}

.lead-drawer.open, .task-drawer.open { right: 0; }

/* Logic to push drawers left if phone is pinned */
body.is-pinned .lead-drawer.open, 
body.is-pinned .task-drawer.open { right: var(--phone-w); }

body.is-pinned.is-wide .lead-drawer.open, 
body.is-pinned.is-wide .task-drawer.open { right: var(--phone-w-wide); }

/* --- 7. MODALS --- */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 3000; display: none; align-items: center; justify-content: center; backdrop-filter: blur(4px); }
.modal-box { background: white; width: 500px; padding: 30px; border-radius: 16px; text-align: center; box-shadow: 0 25px 60px rgba(0,0,0,0.3); }

/* Win/Lost Logic Styles */
.wl-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin: 20px 0; }
.wl-btn { padding: 25px; border: 2px solid #e5e7eb; border-radius: 12px; cursor: pointer; transition: 0.2s; }
.wl-btn:hover { border-color: var(--c-primary); }
.wl-btn.win.sel { border-color: #10b981; background: #ecfdf5; }
.wl-btn.lost.sel { border-color: #ef4444; background: #fef2f2; }

.ai-result-area { display: none; margin-top: 20px; border-top: 1px solid #f1f5f9; padding-top: 20px; text-align: left; animation: slideDown 0.3s ease; }
@keyframes slideDown { from{opacity:0; transform:translateY(-10px);} to{opacity:1; transform:translateY(0);} }

.ai-rec-box { background: #ecfdf5; border: 1px solid #10b981; border-radius: 8px; padding: 12px; display: flex; gap: 10px; align-items: start; margin-bottom: 15px; }
.tags-wrap { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 20px; }
.tag-chk { padding: 8px 14px; border: 1px solid #e5e7eb; border-radius: 20px; font-size: 12px; cursor: pointer; display: flex; align-items: center; gap: 6px; }
.tag-chk.active { background: #eff6ff; border-color: var(--c-primary); color: var(--c-primary); font-weight: 700; }

/* --- 8. TASK LIST STYLES --- */
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 30px; }
.task-group-title { font-size: 12px; font-weight: 800; color: #9ca3af; text-transform: uppercase; margin-bottom: 15px; display: flex; align-items: center; gap: 10px; }
.task-group-title::after { content: ''; flex: 1; height: 1px; background: #e5e7eb; }

.task-item { 
    background: white; border-radius: 12px; padding: 16px 20px; margin-bottom: 10px; 
    display: flex; align-items: center; gap: 20px; 
    box-shadow: 0 1px 2px rgba(0,0,0,0.03); 
    transition: 0.2s; cursor: pointer; border: 1px solid transparent;
}
.task-item:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.08); z-index: 5; border-color: var(--c-primary); }

.custom-check { width: 24px; height: 24px; border: 2px solid #d1d5db; border-radius: 6px; display: flex; align-items: center; justify-content: center; color: transparent; transition: 0.2s; }
.custom-check:hover { border-color: var(--c-primary); }
.custom-check.checked { background: var(--c-success); border-color: var(--c-success); color: white; }

.t-title { font-weight: 600; font-size: 15px; margin-bottom: 4px; color: #1f2937; }
.t-sub { font-size: 12px; color: #6b7280; display: flex; gap: 15px; align-items: center; }

.tag-prio { font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 4px; text-transform: uppercase; }
.prio-high { background: #fef2f2; color: var(--c-danger); }
.prio-med { background: #fffbeb; color: var(--c-warning); }
.prio-low { background: #f0f9ff; color: #0ea5e9; }

.user-av { width: 30px; height: 30px; border-radius: 50%; border: 2px solid white; margin-left: -10px; background: #e0e7ff; color: var(--c-primary); display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 700; }

/* --- 9. TASK DRAWER INTERNALS --- */
.td-header { padding: 20px 25px; border-bottom: 1px solid var(--c-border); display: flex; justify-content: space-between; align-items: flex-start; }
.td-body { flex: 1; overflow-y: auto; padding: 25px; }
.td-footer { padding: 20px; border-top: 1px solid var(--c-border); background: #f9fafb; }

.desc-label { font-size: 11px; font-weight: 800; color: #9ca3af; text-transform: uppercase; margin-bottom: 8px; }
.desc-text { font-size: 14px; line-height: 1.6; color: #374151; margin-bottom: 25px; }

.sub-item { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid #f3f4f6; }
.sub-input { border: none; outline: none; flex: 1; font-size: 14px; color: #4b5563; }

.attach-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 30px; }
.file-card { border: 1px solid var(--c-border); border-radius: 8px; padding: 10px; display: flex; flex-direction: column; align-items: center; text-align: center; cursor: pointer; transition: 0.2s; }
.file-card:hover { border-color: var(--c-primary); background: #f5f3ff; }
.f-icon { font-size: 24px; margin-bottom: 5px; color: #6b7280; }
.f-name { font-size: 11px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; width: 100%; }

.c-msg { display: flex; gap: 12px; margin-bottom: 15px; }
.c-av { width: 32px; height: 32px; border-radius: 50%; background: #e5e7eb; flex-shrink: 0; display:flex; align-items:center; justify-content:center; font-size:10px; font-weight:bold; }
.c-bubble { background: #f3f4f6; padding: 10px 14px; border-radius: 0 12px 12px 12px; }
.c-name { font-size: 11px; font-weight: 700; color: #111; margin-bottom: 2px; }
.c-text { font-size: 13px; line-height: 1.4; color: #374151; }

.chat-input-box { display: flex; gap: 10px; background: white; border: 1px solid var(--c-border); padding: 8px; border-radius: 25px; box-shadow: 0 2px 5px rgba(0,0,0,0.05); }
.chat-input { border: none; outline: none; flex: 1; padding: 5px 10px; font-size: 14px; }
.chat-btn { width: 32px; height: 32px; border-radius: 50%; background: var(--c-primary); border: none; color: white; display: flex; align-items: center; justify-content: center; cursor: pointer; }