/* ==============================================
Lead Management Portal - Main Stylesheet
==============================================

Table of Contents:
1.  :root Variables
2.  Global Styles (body, *, etc.)
3.  Layout: Header
4.  Layout: Sidebar
5.  Layout: Content Wrapper & Page Header
6.  Layout: Responsive (Mobile)
7.  Component: Login Page
8.  Component: Dashboard Cards
9.  Component: Forms & Buttons
10. Component: Tabs (for Upload)
11. Component: Responsive Table
12. Component: Lead Details Page
13. Component: History Timeline
14. Component: Status Badges
15. Component: Assessment Cards
16. Utility Classes

==============================================
*/

/* 1. :root Variables
---------------------------------------------- */
:root {
    --color-primary: #8e44ad; /* Main Purple */
    --color-primary-dark: #7b2c9f;
    --color-primary-light: #f4eef7;
    --color-secondary: #9b59b6; /* Lighter Purple */
    
    --color-text-primary: #343a40;
    --color-text-secondary: #5a6268;
    --color-text-light: #ffffff;
    --color-border: #dee2e6;
    --color-bg-light: #f8f9fa; /* Main page background */
    --color-bg-white: #ffffff;
    
    --color-green: #2ecc71;
    --color-orange: #f39c12;
    --color-red: #e74c3c;
    --color-blue: #3498db;
    --color-grey: #7f8c8d;

    --font-family-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 10px rgba(0,0,0,0.1);
    --border-radius: 8px;
    --sidebar-width: 260px;
    --header-height: 60px;
}

/* 2. Global Styles
---------------------------------------------- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    width: 100%;
    height: 100%;
}

body {
    font-family: var(--font-family-sans);
    background-color: var(--color-bg-light);
    color: var(--color-text-primary);
    font-size: 16px;
    line-height: 1.6;
    padding-top: var(--header-height); /* Space for fixed header */
    padding-left: var(--sidebar-width); /* Space for fixed sidebar */
    transition: padding-left 0.3s ease;
}

h1, h2, h3, h4, h5, h6 {
    color: var(--color-text-primary);
    margin-bottom: 0.75rem;
    font-weight: 600;
}

a {
    color: var(--color-primary);
    text-decoration: none;
    transition: color 0.2s ease;
}
a:hover {
    color: var(--color-primary-dark);
    text-decoration: underline;
}

hr.nav-divider {
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    margin: 0.5rem 1.5rem;
}

/* 3. Layout: Header
---------------------------------------------- */
.header {
    position: fixed;
    top: 0;
    left: var(--sidebar-width); /* Aligned with sidebar */
    width: calc(100% - var(--sidebar-width)); /* Full width minus sidebar */
    height: var(--header-height);
    background: var(--color-bg-white);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    z-index: 1000;
    transition: left 0.3s ease, width 0.3s ease, background-color 0.3s, color 0.3s, padding-top 0.3s, height 0.3s;
}

.header-user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-user-info .user-name {
    font-weight: 600;
    color: var(--color-text-secondary);
    transition: color 0.3s;
}

/* === NEW LOGOUT BUTTON STYLE === */
.header-user-info .logout-btn {
    display: inline-block;
    padding: 0.25rem 0.75rem; /* Small padding */
    font-size: 0.85rem; /* Small text */
    font-weight: 700; /* Bold text */
    color: var(--color-red); /* Red text */
    background-color: var(--color-bg-white); /* White background */
    border: 1px solid var(--color-border);
    border-radius: 6px;
    text-decoration: none;
    transition: all 0.2s ease; /* Animation */
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}
.header-user-info .logout-btn:hover {
    transform: scale(1.05); /* Animated "pop" */
    text-decoration: none;
    color: var(--color-red);
    box-shadow: var(--shadow-sm);
}
.header-user-info .logout-btn i {
    margin-right: 0.25rem;
}
/* === END NEW STYLE === */

.menu-toggle {
    display: none; /* Hidden on desktop */
    font-size: 1.5rem;
    color: var(--color-text-secondary);
    background: none;
    border: none;
    cursor: pointer;
    transition: color 0.3s;
}

/* 4. Layout: Sidebar
---------------------------------------------- */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    
    /* Purple Gradient Theme */
    background: linear-gradient(145deg, var(--color-primary), var(--color-secondary));
    
    color: var(--color-text-light);
    padding: 1.5rem 0;
    z-index: 1100;
    transition: left 0.3s ease;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 0 1.5rem 1rem 1.5rem;
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-header h2 {
    color: var(--color-text-light);
    font-size: 1.4rem;
    margin: 0;
}
.sidebar-header h2 i {
    margin-right: 0.5rem;
}

.sidebar-nav {
    flex-grow: 1;
    overflow-y: auto;
    margin-top: 1rem;
}

.nav-menu {
    list-style: none;
}

.nav-item a {
    display: flex;
    align-items: center;
    padding: 0.9rem 1.5rem;
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    font-weight: 500;
    border-left: 4px solid transparent;
}
.nav-item a i {
    width: 30px;
    font-size: 1.1rem;
    margin-right: 0.75rem;
    text-align: center;
}

.nav-item a:hover {
    background-color: rgba(0,0,0,0.1);
    color: var(--color-text-light);
}

.nav-item.active a {
    background-color: rgba(0,0,0,0.2);
    color: var(--color-text-light);
    border-left-color: var(--color-text-light);
    font-weight: 600;
}

/* 5. Layout: Content Wrapper & Page Header
---------------------------------------------- */
.content-wrapper {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem;
}

.page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--color-border);
}
.page-header h1 {
    margin: 0;
    font-size: 1.8rem;
}

/* 6. Layout: Responsive (Mobile)
---------------------------------------------- */
@media (max-width: 992px) {
    body {
        padding-left: 0; /* No sidebar space on mobile */
        /* Adjusted padding-top is handled by the inline <style> in header.php */
    }

    .sidebar {
        left: calc(var(--sidebar-width) * -1); /* Off-screen */
        box-shadow: var(--shadow-md);
    }
    .sidebar.is-open {
        left: 0;
    }

    .header {
        left: 0;
        width: 100%;
    }

    .menu-toggle {
        display: block; /* Show hamburger icon */
    }
    
    .overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0,0,0,0.4);
        z-index: 1050;
    }
    .overlay.is-open {
        display: block;
    }

    .content-wrapper {
        padding: 1rem;
    }
    .page-header h1 {
        font-size: 1.5rem;
    }

    /* Make logout button white on mobile purple header */
    .header-user-info .logout-btn {
        color: var(--color-red);
        background: #ffffff;
    }
    .header-user-info .logout-btn:hover {
        color: var(--color-red);
        background: #f0f0f0;
    }
}


/* 7. Component: Login Page
---------------------------------------------- */
.login-body {
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(145deg, var(--color-primary), var(--color-secondary));
}

.login-container {
    width: 100%;
    max-width: 400px;
    background: var(--color-bg-white);
    padding: 2.5rem 2rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    margin: 1rem;
}

.login-container h2 {
    text-align: center;
    color: var(--color-primary);
    margin-bottom: 2rem;
    font-size: 1.6rem;
}

.login-error, .login-success {
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    border-radius: 4px;
    font-size: 0.9rem;
    border: 1px solid transparent;
}
.login-error {
    background-color: #f8d7da;
    color: #721c24;
    border-color: #f5c6cb;
}
.login-success {
    background-color: #d4edda;
    color: #155724;
    border-color: #c3e6cb;
}

/* 8. Component: Dashboard Cards
---------------------------------------------- */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.dash-card {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    background: var(--color-bg-white);
    padding: 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease-in-out;
}
.dash-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-md);
}

.dash-card-icon {
    font-size: 2.2rem;
    padding: 0.5rem;
    border-radius: 6px;
    color: var(--color-primary);
}

.dash-card-body {
    flex: 1;
}
.dash-card-body .value {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--color-text-primary);
    line-height: 1;
}
.dash-card-body .label {
    font-size: 0.95rem;
    color: var(--color-text-secondary);
    margin-top: 0.25rem;
}

.dash-card-link {
    display: block;
    margin-top: 1rem;
    font-weight: 600;
    color: var(--color-primary);
    font-size: 0.9rem;
}
.dash-card-link i {
    margin-left: 0.25rem;
}

/* Card-specific colors */
.dash-card.green .dash-card-icon { color: var(--color-green); }
.dash-card.green .dash-card-link { color: var(--color-green); }

.dash-card.orange .dash-card-icon { color: var(--color-orange); }
.dash-card.orange .dash-card-link { color: var(--color-orange); }

.dash-card.red .dash-card-icon { color: var(--color-red); }
.dash-card.red .dash-card-link { color: var(--color-red); }

.dash-card.blue .dash-card-icon { color: var(--color-blue); }
.dash-card.blue .dash-card-link { color: var(--color-blue); }

.dash-card.grey .dash-card-icon { color: var(--color-grey); }
.dash-card.grey .dash-card-link { color: var(--color-grey); }


/* 9. Component: Forms & Buttons
---------------------------------------------- */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--color-text-primary);
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="date"],
.form-group input[type="time"],
.form-group input[type="file"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    background-color: var(--color-bg-white);
    color: var(--color-text-primary);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-light);
}

.form-group textarea {
    min-height: 100px;
    resize: vertical;
}

/* Buttons */
.btn-primary,
button[type="submit"] {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    background: var(--color-primary);
    color: var(--color-text-light);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    text-align: center;
    transition: background-color 0.2s;
}
.btn-primary:hover,
button[type="submit"]:hover {
    background: var(--color-primary-dark);
    color: var(--color-text-light);
    text-decoration: none;
}
.btn-primary-full,
button[type="submit"].btn-primary-full {
    width: 100%;
}
.btn-primary i,
button[type="submit"] i {
    margin-right: 0.5rem;
}

.btn-secondary {
    display: inline-block;
    padding: 0.5rem 1rem;
    background: var(--color-bg-light);
    color: var(--color-text-secondary);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    text-align: center;
    transition: all 0.2s;
}
.btn-secondary:hover {
    background-color: #e9ecef;
    border-color: #adb5bd;
    color: var(--color-text-primary);
    text-decoration: none;
}
.btn-secondary i {
    margin-right: 0.35rem;
}

/* Form Messages */
.form-error, .form-success {
    padding: 1rem;
    margin-bottom: 1.5rem;
    border-radius: 6px;
    font-size: 0.95rem;
    border: 1px solid transparent;
}
.form-error {
    background-color: #f8d7da;
    color: #721c24;
    border-color: #f5c6cb;
}
.form-success {
    background-color: #d4edda;
    color: #155724;
    border-color: #c3e6cb;
}
.form-note {
    font-size: 0.85rem;
    color: var(--color-text-secondary);
    margin-top: -0.75rem;
    margin-bottom: 1.25rem;
}

/* 10. Component: Tabs (for Upload)
---------------------------------------------- */
.card-form {
    background: var(--color-bg-white);
    padding: 2rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    max-width: 700px;
    margin: 0 auto;
}

.tab-navigation {
    display: flex;
    border-bottom: 1px solid var(--color-border);
    margin-bottom: 1.5rem;
}

.tab-btn {
    padding: 0.75rem 1.25rem;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--color-text-secondary);
    border-bottom: 3px solid transparent;
    transition: all 0.2s;
}
.tab-btn i {
    margin-right: 0.5rem;
}

.tab-btn:hover {
    color: var(--color-text-primary);
}

.tab-btn.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
    font-weight: 600;
}

.tab-content {
    display: none;
}
.tab-content.active {
    display: block;
}

/* 11. Component: Responsive Table
---------------------------------------------- */
.card-table {
    background: var(--color-bg-white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

table thead {
    background-color: var(--color-bg-light);
}

table th {
    padding: 1rem 1.25rem;
    text-align: left;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

table tr {
    border-bottom: 1px solid var(--color-border);
}
table tr:last-child {
    border-bottom: none;
}

table td {
    padding: 1rem 1.25rem;
    vertical-align: middle;
}

table td .remark-cell {
    max-width: 250px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block; /* Added for mobile */
}

/* Mobile Responsive Table */
@media (max-width: 768px) {
    table thead {
        display: none; /* Hide desktop headers */
    }

    table tr {
        display: block;
        margin-bottom: 1rem;
        border: 1px solid var(--color-border);
        border-radius: var(--border-radius);
        overflow: hidden;
        box-shadow: var(--shadow-sm);
    }
    table tr:last-child {
        margin-bottom: 0;
    }

    table td {
        display: block;
        text-align: right;
        padding: 0.75rem 1rem;
        border-bottom: 1px solid var(--color-border);
        position: relative;
    }
    table td:last-child {
        border-bottom: none;
    }
    
    table td[data-label] {
        padding-left: 40%; /* Make space for label */
    }

    table td[data-label]::before {
        content: attr(data-label);
        position: absolute;
        left: 1rem;
        width: calc(40% - 1.5rem); /* Label width */
        text-align: left;
        font-weight: 600;
        font-size: 0.9rem;
        color: var(--color-text-primary);
    }

    table td .remark-cell {
        max-width: none;
        white-space: normal;
        text-align: right;
    }
}


/* 12. Component: Lead Details Page
---------------------------------------------- */
.btn-back {
    display: inline-block;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-text-secondary);
    margin-bottom: 1rem;
}
.btn-back:hover {
    color: var(--color-text-primary);
    text-decoration: none;
}
.btn-back i {
    margin-right: 0.35rem;
}

.details-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

/* Two-column layout for desktop */
@media (min-width: 992px) {
    .details-layout {
        grid-template-columns: 1fr 1fr;
    }
}

.details-card-form,
.details-card-info {
    background: var(--color-bg-white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    padding: 2rem;
}

@media (max-width: 768px) {
    .details-card-form,
    .details-card-info {
        padding: 1.5rem;
    }
}


.details-card-info h2 {
    font-size: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--color-border);
}
.details-card-info h2 i {
    margin-right: 0.5rem;
    color: var(--color-primary);
}

.info-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.75rem 1rem;
    font-size: 0.95rem;
}
.info-grid strong {
    color: var(--color-text-secondary);
    font-weight: 600;
}


/* 13. Component: History Timeline
---------------------------------------------- */
.history-timeline {
    margin-top: 1.5rem;
    position: relative;
    padding-left: 1.5rem;
}
.history-timeline::before {
    content: '';
    position: absolute;
    top: 5px;
    left: 4px;
    width: 2px;
    height: 100%;
    background: var(--color-border);
}

.history-item {
    position: relative;
    margin-bottom: 1.5rem;
}
.history-item:last-child {
    margin-bottom: 0;
}

.history-dot {
    position: absolute;
    top: 5px;
    left: -1.8rem;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--color-secondary);
    border: 2px solid var(--color-bg-white);
    box-shadow: 0 0 0 3px var(--color-secondary);
}

.history-content {
    font-size: 0.9rem;
}
.history-note {
    font-weight: 500;
    color: var(--color-text-primary);
    margin-bottom: 0.25rem;
    word-break: break-word; /* Fix long words */
}
.history-meta {
    font-size: 0.85rem;
    color: var(--color-text-secondary);
}
.history-date {
    font-size: 0.8rem;
    color: var(--color-text-secondary);
    font-weight: 600;
    margin-top: 0.35rem;
}
.callback-flag {
    display: inline-block;
    font-size: 0.8rem;
    color: var(--color-orange);
    background: #fff8eb;
    padding: 2px 8px;
    border-radius: 4px;
    margin-left: 0.5rem;
    font-weight: 600;
}
.callback-flag i {
    margin-right: 0.25rem;
}

/* 14. Component: Status Badges
---------------------------------------------- */
.status-badge {
    display: inline-block;
    padding: 0.25em 0.6em;
    font-size: 0.8rem;
    font-weight: 700;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
    vertical-align: baseline;
    border-radius: 1rem;
    color: var(--color-text-light);
}

.status-New, .status-badge.status-New {
    background-color: var(--color-blue);
}
.status-Interested, .status-badge.status-Interested {
    background-color: var(--color-green);
}
.status-Call-Back, .status-badge.status-Call-Back {
    background-color: var(--color-orange);
    color: #333;
}
.status-Not-Interested, .status-badge.status-Not-Interested {
    background-color: var(--color-red);
}
.status-Not-Contactable, .status-badge.status-Not-Contactable {
    background-color: var(--color-grey);
}

/* 15. Component: Assessment Cards
---------------------------------------------- */
.assessment-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

@media (min-width: 768px) {
    .assessment-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.assessment-card {
    background: var(--color-bg-white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
}

.assessment-card h3 {
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
}

.assessment-card .info-grid {
    gap: 0.5rem 1rem; /* Tighter grid for cards */
    margin-bottom: 1rem;
}

.assessment-summary {
    display: block;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--color-primary);
    background: var(--color-primary-light);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
}

.assessment-card .btn-primary {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}


/* 16. Utility Classes
---------------------------------------------- */
.text-center {
    text-align: center;
}
.text-muted {
    color: var(--color-text-secondary);
}
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 1rem; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 1rem; }

