/* Driver Coaching Dashboard - Enhanced Styles */

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

:root {
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --success-gradient: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    --warning-gradient: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --dark-bg: #1a1a2e;
    --card-bg: #ffffff;
    --text-primary: #2c3e50;
    --text-secondary: #7f8c8d;
    --border-color: #e1e8ed;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.12);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.15);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    background-attachment: fixed;
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 1900px;
    margin: 0 auto;
    padding: 24px;
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
    background: var(--card-bg);
    padding: 28px 32px;
    border-radius: 16px;
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
}

header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--primary-gradient);
}

h1 {
    color: var(--text-primary);
    font-size: 32px;
    font-weight: 700;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

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

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn:hover::before {
    width: 300px;
    height: 300px;
}

.btn-primary {
    background: var(--primary-gradient);
    color: white;
}

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

.btn-secondary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

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

.btn-danger {
    background: linear-gradient(135deg, #ff4757 0%, #c23616 100%);
    color: white;
    font-weight: 700;
    animation: pulse 2s infinite;
}

.btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(255, 71, 87, 0.4);
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(255, 71, 87, 0.7);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(255, 71, 87, 0);
    }
}

.btn-warning {
    background: linear-gradient(135deg, #f39c12 0%, #e67e22 100%);
    color: white;
    font-weight: 600;
}

.btn-warning:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(243, 156, 18, 0.4);
}

/* Stats Dashboard */
.stats-dashboard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--card-bg);
    padding: 24px;
    border-radius: 16px;
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    gap: 20px;
    transition: all 0.3s ease;
}

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

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    box-shadow: var(--shadow-sm);
}

.stat-info {
    flex: 1;
}

.stat-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Filters */
.filters {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
    background: var(--card-bg);
    padding: 20px;
    border-radius: 16px;
    box-shadow: var(--shadow-md);
    flex-wrap: wrap;
}

.search-input,
.filter-select {
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.3s ease;
    background: white;
}

.search-input:focus,
.filter-select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.search-input {
    flex: 1;
    min-width: 250px;
}

.filter-select {
    min-width: 140px;
    cursor: pointer;
}

.date-range-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.date-range-group label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Loading */
.loading {
    text-align: center;
    padding: 60px;
    background: var(--card-bg);
    border-radius: 16px;
    color: var(--text-secondary);
    font-size: 18px;
}

/* Table Container */
.table-container {
    background: var(--card-bg);
    border-radius: 16px;
    box-shadow: var(--shadow-md);
    overflow-x: auto;
    overflow-y: visible;
    position: relative;
}

/* Table */
table {
    width: 100%;
    border-collapse: collapse;
    table-layout: auto;
}

thead {
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    color: white;
}

th {
    padding: 18px 12px;
    text-align: left;
    font-weight: 600;
    font-size: 12px;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    position: sticky;
    top: 0;
    z-index: 10;
    transition: background 0.2s ease;
    min-width: 80px;
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
}

th:first-child {
    position: sticky;
    left: 0;
    z-index: 20;
    min-width: 180px;
    width: 180px;
}

th[title] {
    cursor: help;
}

th[title]:hover::before {
    content: attr(title);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #2c3e50;
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    white-space: normal;
    width: 200px;
    text-align: center;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    margin-bottom: 8px;
    font-weight: 400;
    line-height: 1.4;
}

th[title]:hover::after {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: #2c3e50;
    z-index: 1001;
    margin-bottom: 2px;
}

th:hover {
    background: rgba(255, 255, 255, 0.1);
}

th.sortable::after {
    content: ' ⇅';
    opacity: 0.5;
    font-size: 12px;
}

th.sorted-asc::after {
    content: ' ▲';
    opacity: 1;
}

th.sorted-desc::after {
    content: ' ▼';
    opacity: 1;
}

tbody tr {
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.2s ease;
}

tbody tr:hover {
    background: linear-gradient(90deg, rgba(102, 126, 234, 0.05) 0%, rgba(118, 75, 162, 0.05) 100%);
    transform: scale(1.001);
}

tbody tr:active {
    transform: scale(0.999);
}

td {
    padding: 14px 12px;
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Focus Areas column - allow wrapping with ellipsis after 2 lines */
td.focus-areas {
    white-space: normal;
    max-width: 200px;
    line-height: 1.4;
    max-height: 2.8em; /* 2 lines at 1.4 line-height */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

td:first-child {
    position: sticky;
    left: 0;
    background: white;
    font-weight: 600;
    min-width: 180px;
    width: 180px;
    z-index: 5;
    border-right: 2px solid var(--border-color);
    box-shadow: 2px 0 4px rgba(0,0,0,0.05);
}

tbody tr:hover td:first-child {
    background: linear-gradient(90deg, rgba(102, 126, 234, 0.08) 0%, rgba(118, 75, 162, 0.08) 100%);
}

/* Status Badges */
.status-badge {
    display: inline-block;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-pending {
    background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
    color: #856404;
}

.status-in_progress {
    background: linear-gradient(135deg, #cce5ff 0%, #a6d0ff 100%);
    color: #004085;
}

.status-completed {
    background: linear-gradient(135deg, #d4edda 0%, #a8e6cf 100%);
    color: #155724;
}

/* Trend Indicators */
.trend-up {
    color: #27ae60;
    font-weight: bold;
    font-size: 18px;
}

.trend-down {
    color: #e74c3c;
    font-weight: bold;
    font-size: 18px;
}

.trend-stable {
    color: #95a5a6;
    font-size: 18px;
}

/* Action Badges */
.action-badge {
    display: inline-block;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.action-self_coaching {
    background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
    color: #2e7d32;
}

.action-guided_coaching {
    background: linear-gradient(135deg, #fff3e0 0%, #ffe0b2 100%);
    color: #e65100;
}

.action-in_person_coaching {
    background: linear-gradient(135deg, #fff9c4 0%, #fff59d 100%);
    color: #f57f17;
}

.action-final_warning {
    background: linear-gradient(135deg, #ffebee 0%, #ffcdd2 100%);
    color: #c62828;
    animation: pulse 2s ease-in-out infinite;
}

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

/* Coaching Need Indicator */
.needs-coaching-critical td:first-child {
    border-left: 4px solid #e74c3c;
}

.needs-coaching-warning td:first-child {
    border-left: 4px solid #f39c12;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background-color: var(--card-bg);
    margin: 40px auto;
    padding: 40px;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 900px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.close {
    color: var(--text-secondary);
    float: right;
    font-size: 32px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.2s ease;
}

.close:hover {
    color: var(--text-primary);
}

.modal-content h2 {
    margin-bottom: 28px;
    color: var(--text-primary);
    font-size: 28px;
}

/* Form Styles */
.form-group {
    margin-bottom: 24px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-primary);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    transition: all 0.3s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

.suggestions {
    position: relative;
    background: white;
    border: 2px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 8px 8px;
    max-height: 200px;
    overflow-y: auto;
    display: none;
    box-shadow: var(--shadow-sm);
}

.suggestion-item {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.2s ease;
}

.suggestion-item:hover {
    background: linear-gradient(90deg, rgba(102, 126, 234, 0.05) 0%, rgba(118, 75, 162, 0.05) 100%);
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 32px;
    padding-top: 24px;
    border-top: 2px solid var(--border-color);
}

/* Metric Cells */
td.metric {
    text-align: center;
    font-weight: 600;
    position: relative;
}

td.metric.good {
    color: #27ae60;
}

td.metric.warning {
    color: #f39c12;
}

td.metric.poor {
    color: #e74c3c;
}

/* Metric Progress Bars */
.metric-bar-container {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
}

.metric-bar {
    height: 6px;
    border-radius: 3px;
    background: #e1e8ed;
    flex: 0 0 60px;
    position: relative;
    overflow: hidden;
}

.metric-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.5s ease;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
}

.metric-bar-fill.good {
    background: linear-gradient(90deg, #11998e 0%, #38ef7d 100%);
}

.metric-bar-fill.warning {
    background: linear-gradient(90deg, #f093fb 0%, #f5576c 100%);
}

.metric-bar-fill.poor {
    background: linear-gradient(90deg, #ff6b6b 0%, #ee5a6f 100%);
}

/* Responsive Design */
@media (max-width: 1400px) {
    .form-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 16px;
    }

    header {
        flex-direction: column;
        align-items: flex-start;
        padding: 20px;
    }

    h1 {
        font-size: 24px;
    }

    .header-actions {
        margin-top: 16px;
        width: 100%;
        flex-direction: column;
    }

    .header-actions button {
        width: 100%;
    }

    .filters {
        flex-direction: column;
    }

    .search-input,
    .filter-select {
        width: 100%;
        min-width: auto;
    }

    table {
        font-size: 11px;
    }

    th, td {
        padding: 10px 6px;
    }

    .modal-content {
        padding: 24px;
        margin: 20px auto;
    }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
}

/* Loading Animation */
.loading::after {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(102, 126, 234, 0.3);
    border-radius: 50%;
    border-top-color: #667eea;
    animation: spin 1s ease-in-out infinite;
    margin-left: 10px;
}

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