/* ============================================
   SALES COCKPIT DASHBOARD v2.0.5
   Vector Contour Ltd. - Clean Modern Design
   ============================================ */

/* CSS Variables */
:root {
    --primary-color: #0078c1;
    --primary-dark: #005a9c;
    --primary-light: #e6f3fb;
    --text-primary: #333333;
    --text-secondary: #666666;
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --border-color: #e0e0e0;
    --success-color: #28a745;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --spacing-xs: 8px;
    --spacing-sm: 12px;
    --spacing-md: 20px;
    --spacing-lg: 30px;
    --spacing-xl: 40px;
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
}

/* Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #e8ecf0 100%);
    color: var(--text-primary);
    line-height: 1.6;
    padding: var(--spacing-lg);
    min-height: 100vh;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.loading-overlay.hidden {
    display: none;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 6px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-overlay p {
    margin-top: var(--spacing-md);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-secondary);
}

/* Header */
.header {
    background: var(--bg-primary);
    padding: var(--spacing-lg) var(--spacing-xl);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    margin-bottom: var(--spacing-lg);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--spacing-md);
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 15px;
}

.logo {
    width: 80px;
    height: 80px;
    background: white;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.08);
}

.logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.company-info h1 {
    font-size: 2rem;
    color: #0078c1;
    font-weight: 300;
    margin-bottom: 5px;
}

.company-info p {
    color: #7F7F7F;
    font-size: 0.9rem;
    font-style: italic;
}

.header-actions {
    display: flex;
    gap: var(--spacing-sm);
    align-items: center;
    flex-wrap: wrap;
}

.version-badge {
    background: var(--primary-color);
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.last-update {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.btn {
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-normal);
    text-decoration: none;
    display: inline-block;
    white-space: nowrap;
    min-width: fit-content;
    text-align: center;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* Time Filter Buttons */
.time-filter-container {
    display: flex;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-lg);
    flex-wrap: wrap;
}

.time-filter-btn {
    padding: 12px 24px;
    border: 2px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.time-filter-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.time-filter-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* KPI Cards Grid */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

.kpi-card {
    background: var(--bg-primary);
    border-radius: var(--radius-md);
    padding: var(--spacing-lg);
    box-shadow: var(--shadow-sm);
    border-left: 4px solid var(--primary-color);
    transition: all var(--transition-normal);
}

.kpi-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
}

.kpi-header h3 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-sm);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.kpi-value {
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: var(--spacing-xs);
}

.kpi-subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Charts Grid */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

.chart-card {
    background: var(--bg-primary);
    border-radius: var(--radius-md);
    padding: var(--spacing-lg);
    box-shadow: var(--shadow-sm);
    border-left: 4px solid var(--primary-color);
}

.chart-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-md);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.chart-container {
    position: relative;
    height: 300px;
}

/* Top Deals Section */
.top-deals-section {
    background: var(--bg-primary);
    border-radius: var(--radius-md);
    padding: var(--spacing-lg);
    box-shadow: var(--shadow-sm);
    margin-bottom: var(--spacing-lg);
    border-left: 4px solid var(--primary-color);
}

/* All Deals Section */
.all-deals-section {
    background: var(--bg-primary);
    border-radius: var(--radius-md);
    padding: var(--spacing-lg);
    box-shadow: var(--shadow-sm);
    margin-bottom: var(--spacing-lg);
    border-left: 4px solid var(--primary-dark);
}

.deals-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-md);
    flex-wrap: wrap;
    gap: var(--spacing-sm);
}

.deals-title {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.deals-title h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.deal-count {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: normal;
}

.help-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    background: var(--primary-light);
    color: var(--primary-color);
    border-radius: 50%;
    font-size: 0.8rem;
    font-weight: bold;
    cursor: help;
    transition: all var(--transition-fast);
}

.help-icon:hover {
    background: var(--primary-color);
    color: white;
    transform: scale(1.1);
}

.deals-controls {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}

.deals-controls label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.sort-select {
    padding: 8px 12px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    cursor: pointer;
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: border-color var(--transition-fast);
}

.sort-select:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Table */
.table-container {
    overflow-x: auto;
}

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

.deals-table thead {
    background: var(--bg-secondary);
}

.deals-table th {
    padding: 12px;
    text-align: left;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--border-color);
}

.deals-table td {
    padding: 15px 12px;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.95rem;
}

.deals-table tbody tr {
    transition: background-color var(--transition-fast);
}

.deals-table tbody tr:hover {
    background: var(--primary-light);
}

.deals-table .empty-state {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
    font-style: italic;
}

.chance-score {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 0.9rem;
}

.chance-score.high {
    background: #d4edda;
    color: #155724;
}

.chance-score.medium {
    background: #fff3cd;
    color: #856404;
}

.chance-score.low {
    background: #f8d7da;
    color: #721c24;
}

/* ⚠️ OVERDUE badge for past close dates */
.chance-score.overdue {
    background: #dc3545;
    color: #ffffff;
    font-weight: 700;
    animation: pulse-red 2s ease-in-out infinite;
}

/* ⚠️ OVERDUE ROW - Highlight entire row for overdue deals */
.deals-table tr.overdue-row {
    background-color: #fff5f5 !important;
    border-left: 4px solid #dc3545;
}

.deals-table tr.overdue-row:hover {
    background-color: #ffe5e5 !important;
}

@keyframes pulse-red {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

.deal-amount {
    font-weight: 600;
    color: var(--primary-color);
}

/* Footer */
.footer {
    background: var(--bg-primary);
    padding: var(--spacing-lg);
    border-radius: var(--radius-md);
    text-align: center;
    box-shadow: var(--shadow-sm);
    margin-top: var(--spacing-lg);
}

.footer p {
    margin: 5px 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.footer .slogan {
    color: var(--primary-color);
    font-style: italic;
    font-weight: 600;
    margin-top: 10px;
}

/* Responsive Design */
@media (max-width: 768px) {
    body {
        padding: var(--spacing-sm);
    }

    .header {
        padding: var(--spacing-md);
    }

    .logo {
        width: 50px;
        height: 50px;
    }

    .company-info h1 {
        font-size: 1.5rem;
    }

    .kpi-grid {
        grid-template-columns: 1fr;
    }

    .charts-grid {
        grid-template-columns: 1fr;
    }

    .deals-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .time-filter-container {
        justify-content: center;
    }

    .time-filter-btn {
        flex: 1;
        min-width: 120px;
    }
}

@media (max-width: 480px) {
    .kpi-value {
        font-size: 1.8rem;
    }

    .deals-table {
        font-size: 0.85rem;
    }

    .deals-table th,
    .deals-table td {
        padding: 10px 8px;
    }
}
