/* TBM CRM Styles - Clean Professional Design */
:root {
    --primary: #00a651;
    --primary-dark: #008a43;
    --primary-light: #e8f5ec;
    --secondary: #1a1a1a;
    --text: #333;
    --text-light: #666;
    --bg: #f5f7fa;
    --white: #fff;
    --border: #e0e0e0;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.12);

    /* Pipeline colors */
    --cold: #3498db;
    --warm: #f39c12;
    --hot: #e74c3c;
    --closed: #00a651;
    --lost: #95a5a6;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg);
    color: var(--text);
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 240px;
    background: var(--secondary);
    color: var(--white);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sidebar-header h1 {
    font-size: 1.5rem;
    color: var(--primary);
}

.sidebar-header span {
    font-size: 1.25rem;
    font-weight: 300;
}

.nav-links {
    list-style: none;
    padding: 1rem 0;
    flex: 1;
}

.nav-links a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1.5rem;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    transition: all 0.2s ease;
}

.nav-links a:hover {
    background: rgba(255,255,255,0.1);
    color: var(--white);
}

.nav-links a.active {
    background: var(--primary);
    color: var(--white);
}

.nav-links .icon {
    font-size: 1.1rem;
}

.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid rgba(255,255,255,0.1);
    font-size: 0.75rem;
    color: rgba(255,255,255,0.5);
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 240px;
    padding: 2rem;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.page-header h2 {
    font-size: 1.75rem;
    font-weight: 600;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.date {
    color: var(--text-light);
}

.btn-refresh {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: background 0.2s ease;
}

.btn-refresh:hover {
    background: var(--primary-dark);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--white);
    border-radius: 12px;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.stat-icon {
    font-size: 2rem;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
}

.total-leads .stat-icon { background: var(--primary-light); }
.emails-sent .stat-icon { background: #e3f2fd; }
.opens .stat-icon { background: #fff3e0; }
.replies .stat-icon { background: #fce4ec; }

.stat-content h3 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--secondary);
}

.stat-content p {
    color: var(--text-light);
    font-size: 0.875rem;
}

/* Cards */
.card {
    background: var(--white);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.card h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--secondary);
}

.dashboard-row {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

/* Pipeline Funnel */
.pipeline-funnel {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1.5rem 0;
}

.funnel-stage {
    text-align: center;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    min-width: 80px;
}

.funnel-stage.cold { background: rgba(52, 152, 219, 0.1); border: 2px solid var(--cold); }
.funnel-stage.warm { background: rgba(243, 156, 18, 0.1); border: 2px solid var(--warm); }
.funnel-stage.hot { background: rgba(231, 76, 60, 0.1); border: 2px solid var(--hot); }
.funnel-stage.closed { background: rgba(0, 166, 81, 0.1); border: 2px solid var(--closed); }

.funnel-stage .count {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
}

.funnel-stage .label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-light);
}

.funnel-stage.cold .count { color: var(--cold); }
.funnel-stage.warm .count { color: var(--warm); }
.funnel-stage.hot .count { color: var(--hot); }
.funnel-stage.closed .count { color: var(--closed); }

.funnel-arrow {
    color: var(--text-light);
    font-size: 1.5rem;
}

.btn-view-all {
    display: inline-block;
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
    margin-top: 1rem;
    transition: color 0.2s ease;
}

.btn-view-all:hover {
    color: var(--primary-dark);
}

/* Campaign Count */
.campaign-count {
    text-align: center;
    padding: 2rem 0;
}

.campaign-count span {
    display: block;
    font-size: 3rem;
    font-weight: 700;
    color: var(--primary);
}

.campaign-count small {
    color: var(--text-light);
}

/* Charts */
.chart-card {
    min-height: 300px;
}

/* Activity List */
.activity-list {
    max-height: 300px;
    overflow-y: auto;
}

.activity-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.875rem 0;
    border-bottom: 1px solid var(--border);
}

.activity-item:last-child {
    border-bottom: none;
}

.activity-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.activity-icon.email { background: #e3f2fd; }
.activity-icon.stage { background: var(--primary-light); }
.activity-icon.reply { background: #fce4ec; }

.activity-content {
    flex: 1;
}

.activity-content p {
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
}

.activity-content small {
    color: var(--text-light);
    font-size: 0.75rem;
}

.loading {
    text-align: center;
    color: var(--text-light);
    padding: 2rem;
}

/* Pipeline Page */
.pipeline-board {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 1rem;
    padding: 1rem 0;
}

.pipeline-column {
    background: var(--bg);
    border-radius: 8px;
    padding: 1rem;
    min-height: 500px;
}

.pipeline-column h4 {
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid;
}

.pipeline-column.cold h4 { border-color: var(--cold); color: var(--cold); }
.pipeline-column.warm h4 { border-color: var(--warm); color: var(--warm); }
.pipeline-column.hot h4 { border-color: var(--hot); color: var(--hot); }
.pipeline-column.closed h4 { border-color: var(--closed); color: var(--closed); }
.pipeline-column.lost h4 { border-color: var(--lost); color: var(--lost); }

.lead-card {
    background: var(--white);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 0.75rem;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: transform 0.2s ease;
}

.lead-card:hover {
    transform: translateX(4px);
}

.lead-card h5 {
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
}

.lead-card p {
    font-size: 0.8rem;
    color: var(--text-light);
}

.lead-card .score {
    display: inline-block;
    background: var(--primary-light);
    color: var(--primary);
    padding: 0.125rem 0.5rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    margin-top: 0.5rem;
}

/* Contacts Page */
.contacts-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.search-box {
    display: flex;
    gap: 0.5rem;
}

.search-box input {
    padding: 0.625rem 1rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    width: 300px;
    font-size: 0.9rem;
}

.search-box button {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.625rem 1.25rem;
    border-radius: 6px;
    cursor: pointer;
}

.filters {
    display: flex;
    gap: 0.75rem;
}

.filters select {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: white;
    font-size: 0.875rem;
}

.contacts-table {
    width: 100%;
    border-collapse: collapse;
}

.contacts-table th,
.contacts-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.contacts-table th {
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-light);
}

.contacts-table tr:hover {
    background: var(--bg);
}

.stage-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.stage-badge.cold { background: rgba(52, 152, 219, 0.1); color: var(--cold); }
.stage-badge.warm { background: rgba(243, 156, 18, 0.1); color: var(--warm); }
.stage-badge.hot { background: rgba(231, 76, 60, 0.1); color: var(--hot); }
.stage-badge.closed { background: rgba(0, 166, 81, 0.1); color: var(--closed); }
.stage-badge.lost { background: rgba(149, 165, 166, 0.1); color: var(--lost); }

/* Campaigns Page */
.campaigns-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.campaign-card {
    background: var(--white);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--primary);
}

.campaign-card.paused {
    border-left-color: var(--lost);
    opacity: 0.7;
}

.campaign-card h4 {
    font-size: 1rem;
    margin-bottom: 0.5rem;
}

.campaign-card .flow-number {
    font-size: 0.75rem;
    color: var(--text-light);
    margin-bottom: 1rem;
}

.campaign-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    margin: 1rem 0;
    padding: 1rem 0;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.campaign-stat {
    text-align: center;
}

.campaign-stat span {
    display: block;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
}

.campaign-stat small {
    font-size: 0.7rem;
    color: var(--text-light);
    text-transform: uppercase;
}

.campaign-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

.btn-small {
    padding: 0.375rem 0.75rem;
    border-radius: 4px;
    border: none;
    font-size: 0.8rem;
    cursor: pointer;
}

.btn-small.pause {
    background: #f39c12;
    color: white;
}

.btn-small.resume {
    background: var(--primary);
    color: white;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 2rem;
}

.pagination button {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    background: var(--white);
    border-radius: 6px;
    cursor: pointer;
}

.pagination button.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Responsive */
@media (max-width: 1024px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .dashboard-row {
        grid-template-columns: 1fr;
    }

    .pipeline-board {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .sidebar {
        width: 60px;
    }

    .sidebar-header h1 {
        display: none;
    }

    .sidebar-header span {
        display: none;
    }

    .nav-links a span:not(.icon) {
        display: none;
    }

    .nav-links a {
        justify-content: center;
        padding: 1rem;
    }

    .sidebar-footer {
        display: none;
    }

    .main-content {
        margin-left: 60px;
        padding: 1rem;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .pipeline-board {
        grid-template-columns: 1fr;
    }
}
