/* css/lead.css */
/* Unified "Tally-inspired" Compact Theme for Lead Management */

/* --- 1. Root Variables & Global Reset --- */
:root {
    --color-primary: #007bff;
    --color-primary-dark: #0056b3;
    --color-danger: #dc3545;       /* Red - Pending/Hot */
    --color-warning: #ffc107;      /* Yellow - Moderate */
    --color-success: #28a745;      /* Green - Converted */
    --color-info: #17a2b8;         /* Cyan - Active/New */
    --color-secondary: #6c757d;    /* Gray - Cold/Lost */
    
    --color-bg-light: #f8f9fa;
    --color-bg-dark: #e9ecef;
    --color-border: #ced4da;
    --color-text-dark: #212529;
    --color-text-light: #495057;
    --color-text-white: #ffffff;
    
    --font-family-sans: 'Arial', sans-serif;
    --shadow-light: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-card: 0 2px 5px rgba(0,0,0,0.05);
}

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

html, body {
    height: 100%;
    width: 100%;
}

body {
    font-family: var(--font-family-sans);
    font-size: 13px; /* Compact base size */
    line-height: 1.4;
    background-color: var(--color-bg-dark);
    color: var(--color-text-dark);
    display: flex;
    flex-direction: column;
}

/* --- 2. Header (Standard) --- */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 15px;
    background-color: var(--color-text-white);
    border-bottom: 2px solid var(--color-primary);
    box-shadow: var(--shadow-light);
    position: sticky;
    top: 0;
    z-index: 100;
}

.app-header h1 {
    font-size: 1.2rem;
    color: var(--color-primary);
    font-weight: bold;
}

.user-display {
    font-size: 0.8rem;
    color: var(--color-text-light);
    margin-left: 10px;
}

.header-actions {
    display: flex;
    gap: 6px;
}

/* Base button style */
button, .header-button, .action-btn {
    font-family: var(--font-family-sans);
    font-size: 12px;
    padding: 6px 12px;
    border: 1px solid var(--color-border);
    border-radius: 3px;
    background-color: var(--color-bg-light);
    color: var(--color-text-dark);
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

button:hover, .header-button:hover {
    background-color: #dee2e6;
    border-color: #adb5bd;
}

.action-btn.primary {
    background-color: var(--color-primary);
    border-color: var(--color-primary);
    color: white;
    font-weight: bold;
}
.action-btn.primary:hover {
    background-color: var(--color-primary-dark);
}

/* --- 3. KPI Infographics Container --- */
.kpi-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    padding: 15px;
    background-color: var(--color-bg-light);
    border-bottom: 1px solid var(--color-border);
}

.kpi-card {
    background: white;
    border-radius: 4px;
    padding: 15px;
    display: flex;
    align-items: center;
    box-shadow: var(--shadow-card);
    border-left: 4px solid transparent; /* Colored accent */
}

.kpi-icon {
    font-size: 2rem;
    margin-right: 15px;
    opacity: 0.8;
}

.kpi-data h3 {
    font-size: 1.5rem;
    font-weight: bold;
    margin: 0;
}

.kpi-data p {
    font-size: 0.85rem;
    color: var(--color-text-light);
    margin: 0;
}

/* KPI Colors */
.kpi-card.danger { border-left-color: var(--color-danger); color: var(--color-danger); }
.kpi-card.warning { border-left-color: var(--color-warning); color: #d39e00; }
.kpi-card.success { border-left-color: var(--color-success); color: var(--color-success); }
.kpi-card.info { border-left-color: var(--color-info); color: var(--color-info); }


/* --- 4. Main Dashboard Layout (Split View) --- */
.lead-dashboard {
    flex-grow: 1;
    display: grid;
    grid-template-columns: 350px 1fr; /* Left panel fixed width, right fills */
    gap: 15px;
    padding: 15px;
    overflow: hidden; /* Prevent double scrollbars */
}

/* Common Panel Styles */
.action-panel, .directory-panel {
    background: white;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-card);
    overflow: hidden; /* For internal scrolling */
}

.panel-header {
    padding: 10px 15px;
    background-color: var(--color-bg-light);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.panel-header h2 {
    font-size: 1rem;
    font-weight: bold;
    color: var(--color-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* --- 5. Left Column: Action List --- */
.badge-count {
    background-color: var(--color-danger);
    color: white;
    font-size: 0.75rem;
    font-weight: bold;
    padding: 2px 8px;
    border-radius: 10px;
}

.action-list-wrapper {
    flex-grow: 1;
    overflow-y: auto;
    padding: 10px;
    background-color: #fff;
}

.action-card {
    background: #fff;
    border: 1px solid var(--color-border);
    border-left: 3px solid var(--color-danger); /* Default urgent */
    border-radius: 3px;
    padding: 10px;
    margin-bottom: 10px;
    transition: transform 0.1s;
}

.action-card:hover {
    transform: translateX(2px);
    box-shadow: var(--shadow-light);
}

.action-card-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
}

.action-name {
    font-weight: bold;
    font-size: 0.95rem;
}

.action-date {
    font-size: 0.8rem;
    color: var(--color-danger);
    font-weight: bold;
}

.action-details {
    font-size: 0.85rem;
    color: var(--color-text-light);
    margin-bottom: 8px;
}

.action-buttons {
    display: flex;
    gap: 5px;
}

.btn-icon-small {
    padding: 4px 8px;
    font-size: 11px;
}


/* --- 6. Right Column: Lead Directory --- */
.search-bar {
    display: flex;
    gap: 5px;
}

.search-bar input {
    padding: 4px 8px;
    border: 1px solid var(--color-border);
    border-radius: 3px;
    width: 200px;
}
.search-bar select {
    padding: 4px;
    border: 1px solid var(--color-border);
    border-radius: 3px;
}

.directory-table-wrapper {
    flex-grow: 1;
    overflow: auto;
}

.directory-table {
    width: 100%;
    border-collapse: collapse;
}

.directory-table th, .directory-table td {
    padding: 8px 10px;
    border-bottom: 1px solid #eee;
    text-align: left;
    font-size: 13px;
    vertical-align: middle;
}

.directory-table th {
    background-color: var(--color-bg-light);
    font-weight: bold;
    position: sticky;
    top: 0;
    z-index: 5;
    border-bottom: 1px solid var(--color-border);
}

.directory-table tr:hover {
    background-color: #f1f8ff;
}

/* Status Tags */
.status-tag {
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: bold;
    text-transform: uppercase;
    display: inline-block;
}

.status-New { background-color: #e2e3e5; color: #383d41; }
.status-Hot { background-color: #f8d7da; color: #721c24; }
.status-Moderate { background-color: #fff3cd; color: #856404; }
.status-Cold { background-color: #d6d8d9; color: #1b1e21; }
.status-Converted { background-color: #d4edda; color: #155724; }
.status-Lost { background-color: #f5c6cb; color: #721c24; text-decoration: line-through; }

/* Table Actions */
.col-action {
    white-space: nowrap;
    width: 100px;
}

.icon-btn {
    border: none;
    background: none;
    cursor: pointer;
    font-size: 14px;
    margin-right: 5px;
    color: var(--color-text-light);
    padding: 2px;
}
.icon-btn:hover { color: var(--color-primary); transform: scale(1.1); }
.icon-btn.whatsapp { color: #25D366; }
.icon-btn.edit { color: var(--color-primary); }


/* --- 7. Modals --- */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(2px);
}

.modal-content, .modal-content-small {
    background-color: white;
    border-radius: 4px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    width: 90%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.modal-content { max-width: 700px; }
.modal-content-small { max-width: 400px; }

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background-color: var(--color-bg-light);
    border-bottom: 1px solid var(--color-border);
}

.modal-close {
    font-size: 1.5rem;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-text-light);
}

.modal-body {
    padding: 15px;
    overflow-y: auto;
}

.modal-footer {
    padding: 10px 15px;
    background-color: var(--color-bg-light);
    border-top: 1px solid var(--color-border);
    text-align: right;
}

/* Forms */
.form-grid {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.form-group {
    margin-bottom: 10px;
    display: flex;
    flex-direction: column;
}

.form-group label {
    font-size: 12px;
    font-weight: bold;
    margin-bottom: 4px;
    color: var(--color-text-light);
}

input, select, textarea {
    padding: 8px;
    border: 1px solid var(--color-border);
    border-radius: 3px;
    font-family: inherit;
    font-size: 13px;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--color-primary);
    outline: none;
    box-shadow: 0 0 0 2px rgba(0,123,255,0.1);
}

/* Highlight Section (Dual Lead) */
.highlight-section {
    background-color: #e7f1ff; /* Light blue tint */
    border: 1px dashed var(--color-primary);
    padding: 10px;
    border-radius: 4px;
}

.checkbox-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 5px;
}
.checkbox-wrapper input {
    width: auto;
}

.small-text {
    font-size: 0.75rem;
    color: var(--color-text-light);
    margin-bottom: 10px;
    font-style: italic;
}

/* Report Buttons */
.report-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.report-nav-btn {
    width: 100%;
    justify-content: flex-start;
    padding: 10px;
    font-size: 14px;
}
.report-nav-btn.disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background-color: #e9ecef;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(255,255,255,0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}
.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--color-primary);
    border-radius: 50%;
    width: 30px; height: 30px;
    animation: spin 1s linear infinite;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .lead-dashboard {
        grid-template-columns: 1fr; /* Stack vertically */
        overflow-y: auto;
    }
    .action-panel {
        max-height: 400px; /* Limit height on mobile */
    }
    .search-bar {
        flex-direction: column;
    }
    .search-bar input {
        width: 100%;
    }
}
/* FIX: Modal Overflow Bug */

/* 1. Make the form fill the modal and act as a flex container */
.modal-content form, 
#newLeadForm {
    display: flex;
    flex-direction: column;
    flex-grow: 1;           /* Take up remaining space below header */
    overflow: hidden;       /* specific to Firefox/flex containers */
    min-height: 0;          /* Allow shrinking */
}

/* 2. Force the body to scroll when content overflows */
.modal-body {
    flex-grow: 1;           /* Push footer to bottom */
    overflow-y: auto;       /* Enable scrollbar inside this area only */
    max-height: none;       /* Remove any specific limits, rely on parent */
}

/* 3. Ensure footer stays visible at the bottom */
.modal-footer {
    flex-shrink: 0;         /* Prevent footer from collapsing */
    background-color: var(--color-bg-light);
    border-top: 1px solid var(--color-border);
    z-index: 10;
}
/* ADDITIONS to css/lead.css */

.task-card {
    border-left: 4px solid #ffc107 !important; /* Yellow warning color */
    background-color: #fff9e6; /* Light yellow tint */
}

.badge-task {
    background-color: #ffc107;
    color: #000;
    font-size: 10px;
    padding: 2px 5px;
    border-radius: 4px;
    font-weight: bold;
}

.action-card.overdue {
    border-left-color: #dc3545; /* Red for overdue calls */
}

.warning-header {
    background-color: #fff3cd !important; /* Yellow header for tasks */
    color: #856404 !important;
}

.btn-icon-small.success {
    background-color: #28a745;
    color: white;
    border-color: #28a745;
}
.btn-icon-small.success:hover {
    background-color: #218838;
}