/* =============================================================================
   STAFFINGFLOW DASHBOARD - Professional Admin Panel
   Design: Clean, Modern, Trust-Building
   ============================================================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    /* Brand Colors */
    --brand-blue: #2563EB;
    --brand-blue-light: #3B82F6;
    --brand-teal: #10B981;
    --brand-teal-light: #34D399;
    --brand-gradient: linear-gradient(135deg, #2563EB 0%, #0EA5E9 50%, #10B981 100%);

    /* Backgrounds - Light theme */
    --bg-primary: #F8FAFC;
    --bg-secondary: #FFFFFF;
    --bg-elevated: #FFFFFF;
    --bg-hover: #F1F5F9;

    /* Text */
    --text-primary: #0F172A;
    --text-secondary: #475569;
    --text-muted: #94A3B8;

    /* Status Colors */
    --success: #22C55E;
    --success-light: #4ADE80;
    --success-bg: rgba(34, 197, 94, 0.1);
    --danger: #EF4444;
    --danger-light: #F87171;
    --danger-bg: rgba(239, 68, 68, 0.1);
    --warning: #F59E0B;
    --warning-light: #FBBF24;
    --warning-bg: rgba(245, 158, 11, 0.1);
    --info: #3B82F6;
    --info-bg: rgba(59, 130, 246, 0.1);

    /* Borders */
    --border: #E2E8F0;
    --border-light: #F1F5F9;

    /* Other */
    --overlay-bg: rgba(15, 23, 42, 0.5);
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    line-height: 1.5;
    overflow-x: hidden;
}

.app {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px;
    min-height: 100vh;
    overflow-x: hidden;
}

/* =============================================================================
   HEADER
   ============================================================================= */

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding: 20px 24px;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}

.header-left {
    display: flex;
    align-items: center;
}

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

.logo-icon {
    width: 44px;
    height: 44px;
    background: var(--brand-gradient);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.logo-img {
    height: 85px;
    width: auto;
    object-fit: contain;
}

.logo-text h1 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    background: var(--brand-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.agency-name {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
    background: var(--bg-primary);
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--text-muted);
    transition: all 0.3s;
}

.status-dot.connected {
    background-color: var(--success);
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.5);
    animation: pulse-green 2s infinite;
}

@keyframes pulse-green {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* =============================================================================
   KPI ZONE
   ============================================================================= */

.kpi-zone {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.kpi-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: all 0.2s;
    cursor: pointer;
}

.kpi-card:hover {
    border-color: var(--brand-blue);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.kpi-icon {
    width: 48px;
    height: 48px;
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.kpi-content {
    display: flex;
    flex-direction: column;
}

.kpi-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.kpi-label {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* KPI Color Variants */
.kpi-success .kpi-icon {
    background: var(--success-bg);
}

.kpi-success .kpi-value {
    color: var(--success);
}

.kpi-danger .kpi-icon {
    background: var(--danger-bg);
}

.kpi-danger .kpi-value {
    color: var(--danger);
}

.kpi-warning .kpi-icon {
    background: var(--warning-bg);
}

.kpi-warning .kpi-value {
    color: var(--warning);
}

.kpi-info .kpi-icon {
    background: var(--info-bg);
}

.kpi-info .kpi-value {
    color: var(--info);
}

/* =============================================================================
   BUTTONS
   ============================================================================= */

.btn-primary {
    background: var(--brand-gradient);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.35);
}

.btn-secondary {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    border-color: var(--brand-blue);
    color: var(--brand-blue);
}

.btn-action {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-width: 80px;
    width: 80px;
}

.btn-action:hover {
    border-color: var(--brand-blue);
    color: var(--brand-blue);
    background: var(--info-bg);
}

.btn-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 24px;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

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

/* =============================================================================
   TAB NAVIGATION
   ============================================================================= */

.tabs-nav {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    padding: 6px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    width: fit-content;
}

.tab-btn {
    background: transparent;
    border: none;
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tab-btn:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.tab-btn.active {
    background: var(--brand-gradient);
    color: white;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
}

/* =============================================================================
   FILTERS
   ============================================================================= */

.filters {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    align-items: flex-end;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

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

.filter-search {
    flex: 1;
    min-width: 200px;
}

select,
input[type="text"] {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    min-width: 160px;
    transition: border-color 0.2s;
}

select:focus,
input[type="text"]:focus {
    outline: none;
    border-color: var(--brand-blue);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

input[type="text"] {
    width: 100%;
}

/* =============================================================================
   TABLE
   ============================================================================= */

.table-container {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow-x: hidden;
    box-shadow: var(--shadow-sm);
}

.candidates-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    table-layout: fixed;
}

/* Fixed widths for Statut and Actions columns - ensures alignment */
.candidates-table th:nth-last-child(2),
.candidates-table td:nth-last-child(2) {
    width: 100px;
    min-width: 100px;
}

.candidates-table th:last-child,
.candidates-table td:last-child {
    width: 100px;
    min-width: 100px;
}

.candidates-table th {
    padding: 14px 20px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border);
    font-weight: 600;
}

.candidates-table td {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
    font-size: 14px;
    vertical-align: middle;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.candidates-table tr:last-child td {
    border-bottom: none;
}

.candidates-table tbody tr {
    transition: background 0.15s;
}

.candidates-table tbody tr:hover {
    background: var(--bg-hover);
}

/* Candidate Name Cell */
.candidate-name {
    font-weight: 600;
    color: var(--text-primary);
}

.candidate-name-link {
    color: var(--text-primary);
    cursor: pointer;
    transition: color 0.2s;
}

.candidate-name-link:hover {
    color: var(--brand-blue);
}

.candidate-phone {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Activity Cell */
.activity-label {
    font-size: 13px;
    color: var(--text-secondary);
}

.activity-time {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Status Badges */
.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid transparent;
    min-width: 85px;
    text-align: center;
}

.badge-available {
    background: var(--success-bg);
    color: var(--success);
    border-color: rgba(34, 197, 94, 0.2);
}

.badge-unavailable {
    background: var(--danger-bg);
    color: var(--danger);
    border-color: rgba(239, 68, 68, 0.2);
}

.badge-unknown {
    background: var(--warning-bg);
    color: var(--warning);
    border-color: rgba(245, 158, 11, 0.2);
}

.badge-reserved {
    background: var(--info-bg);
    color: var(--info);
    border-color: rgba(59, 130, 246, 0.2);
}

.badge-stale {
    background: rgba(249, 115, 22, 0.1);
    color: #EA580C;
    border-color: rgba(249, 115, 22, 0.2);
}

/* Status Badge variants */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    border: 1px solid transparent;
}

.status-available {
    background: var(--success-bg);
    color: var(--success);
    border-color: rgba(34, 197, 94, 0.2);
}

.status-unavailable {
    background: var(--danger-bg);
    color: var(--danger);
    border-color: rgba(239, 68, 68, 0.2);
}

.status-reserved {
    background: var(--info-bg);
    color: var(--info);
    border-color: rgba(59, 130, 246, 0.2);
}

.status-unknown {
    background: var(--warning-bg);
    color: var(--warning);
    border-color: rgba(245, 158, 11, 0.2);
}

.status-noshow {
    background: rgba(220, 38, 38, 0.15);
    color: #DC2626;
    border-color: rgba(220, 38, 38, 0.3);
    font-weight: 700;
}

.status-blacklist {
    background: rgba(127, 29, 29, 0.15);
    color: #991B1B;
    border-color: rgba(127, 29, 29, 0.3);
    font-weight: 700;
}

/* Actions Cell */
.actions-cell {
    display: flex;
    gap: 6px;
    align-items: center;
    justify-content: flex-start;
    height: 100%;
    min-height: inherit;
}

.actions-cell > .btn-action,
.actions-cell > .status-dropdown {
    flex: 0 0 auto;
}

/* Ensure actions td has same vertical alignment */
.candidates-table td[data-label="Actions"] {
    vertical-align: middle;
}

/* Ensure actions column has consistent width and left alignment */
.candidates-table th:last-child,
.candidates-table td:last-child {
    text-align: left;
    width: 100px;
}

.candidates-table td:last-child {
    white-space: nowrap;
}

/* Ensure buttons in actions cell align left */
.candidates-table td:last-child .actions-cell,
.candidates-table td[data-label="Actions"] {
    justify-content: flex-start;
}

/* Status Dropdown */
.status-dropdown {
    position: relative;
    display: flex;
}

.status-dropdown .btn-action {
    width: 100% !important;
}

.status-menu {
    position: absolute;
    bottom: 100%;
    right: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    z-index: 100;
    min-width: 140px;
    display: none;
    overflow: hidden;
    margin-bottom: 4px;
}

.status-menu.active {
    display: block;
    animation: fadeInUp 0.15s ease-out;
}

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

.status-menu button {
    display: block;
    width: 100%;
    padding: 8px 12px;
    text-align: left;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 12px;
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
}

.status-menu button:hover {
    background: var(--bg-hover);
}

.menu-divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 2px 0;
}

.menu-danger {
    color: var(--danger) !important;
}

.menu-danger:hover {
    background: var(--danger-bg) !important;
}

/* =============================================================================
   MODAL
   ============================================================================= */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--overlay-bg);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
    animation: fadeIn 0.2s ease-out;
}

.modal {
    background: var(--bg-secondary);
    width: 100%;
    max-width: 500px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-xl);
    animation: slideUp 0.3s ease-out;
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
    max-height: calc(100vh - 250px);
    overflow-y: auto;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    background: var(--bg-primary);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* Form Elements */
.form-row {
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group.half {
    flex: 1;
    margin-bottom: 0;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.form-input {
    width: 100%;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: var(--brand-blue);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

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

.mission-preview {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
    margin-top: 16px;
    border: 1px solid var(--border);
}

.preview-label {
    font-size: 13px;
    color: var(--text-secondary);
}

.preview-count {
    font-size: 13px;
    font-weight: 600;
    color: var(--success);
}

.date-reserved {
    font-weight: 600;
    color: var(--warning);
    background: var(--warning-bg);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 13px;
}

.reliability-badge {
    margin-left: 8px;
    font-size: 11px;
    cursor: help;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.reliability-score {
    margin-left: 2px;
    font-size: 10px;
    color: var(--text-muted);
    font-weight: 500;
}

/* =============================================================================
   EMPTY STATE
   ============================================================================= */

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-icon {
    font-size: 48px;
    display: block;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 14px;
    max-width: 320px;
    margin: 0 auto;
    color: var(--text-muted);
}

/* =============================================================================
   LOADING
   ============================================================================= */

.loading-row td {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-secondary);
}

.loading-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid var(--border);
    border-top-color: var(--brand-blue);
    border-radius: 50%;
    margin: 0 auto 12px;
    animation: spin 0.8s linear infinite;
}

/* =============================================================================
   TOAST NOTIFICATIONS
   ============================================================================= */

.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 100;
}

.toast {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease-out;
    min-width: 280px;
}

.toast-icon {
    font-size: 18px;
}

.toast-content {
    flex: 1;
}

.toast-title {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
}

.toast-message {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.toast-success {
    border-left: 4px solid var(--success);
}

.toast-error {
    border-left: 4px solid var(--danger);
}

.toast-info {
    border-left: 4px solid var(--brand-blue);
}

/* =============================================================================
   ANIMATIONS
   ============================================================================= */

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

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

/* =============================================================================
   PROFILE MODAL
   ============================================================================= */

.profile-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.profile-section {
    background: var(--bg-primary);
    padding: 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.profile-section.full-width {
    grid-column: 1 / -1;
}

.profile-section h3 {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.profile-section p {
    font-size: 14px;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.profile-section p:last-child {
    margin-bottom: 0;
}

.profile-section strong {
    color: var(--text-secondary);
    font-weight: 500;
}

.message-bubble {
    background: var(--bg-secondary);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-style: italic;
    color: var(--text-primary);
    border-left: 3px solid var(--brand-blue);
    margin-top: 8px;
}

.profile-section .timestamp {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 8px;
}

/* Conversation History */
.conversation-history {
    max-height: 200px;
    overflow-y: auto;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    padding: 12px;
    border: 1px solid var(--border);
}

.history-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

.history-item:last-child {
    border-bottom: none;
}

.history-icon {
    font-size: 16px;
    flex-shrink: 0;
}

.history-content {
    flex: 1;
    min-width: 0;
}

.history-type {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
    text-transform: capitalize;
}

.history-message {
    display: block;
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-date {
    font-size: 11px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.no-history,
.history-loading,
.history-error {
    text-align: center;
    padding: 20px;
    color: var(--text-secondary);
    font-size: 13px;
}

.history-error {
    color: var(--danger);
}

/* Certifications */
.candidate-certifications {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.cert-badge {
    display: inline-block;
    padding: 4px 8px;
    background: var(--brand-gradient);
    color: white;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}

/* Mission Status Badges */
.badge-proposed {
    background: var(--info-bg);
    color: var(--info);
    border-color: rgba(59, 130, 246, 0.2);
}

.badge-accepted {
    background: var(--success-bg);
    color: var(--success);
    border-color: rgba(34, 197, 94, 0.2);
}

.badge-refused {
    background: var(--danger-bg);
    color: var(--danger);
    border-color: rgba(239, 68, 68, 0.2);
}

.badge-completed {
    background: rgba(139, 92, 246, 0.1);
    color: #8B5CF6;
    border-color: rgba(139, 92, 246, 0.2);
}

.badge-cancelled {
    background: rgba(107, 114, 128, 0.1);
    color: #6B7280;
    border-color: rgba(107, 114, 128, 0.2);
}

/* =============================================================================
   RESPONSIVE
   ============================================================================= */

@media (max-width: 1200px) {
    .kpi-zone {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 1024px) {

    /* Candidates: Hide columns 5,7 (Disponible jusqu'au, Dernière activité) */
    #candidatesTable th:nth-child(5),
    #candidatesTable td:nth-child(5),
    #candidatesTable th:nth-child(7),
    #candidatesTable td:nth-child(7) {
        display: none;
    }

    /* Missions: Hide columns 5,7 (Taux horaire, Créée le) */
    #missionsTable th:nth-child(5),
    #missionsTable td:nth-child(5),
    #missionsTable th:nth-child(7),
    #missionsTable td:nth-child(7) {
        display: none;
    }

    .candidates-table th,
    .candidates-table td {
        padding: 12px 14px;
        font-size: 13px;
    }
}

@media (max-width: 900px) {
    /* Candidates table: Hide columns 5,6,7 (Disponible jusqu'au, En mission jusqu'au, Dernière activité) */
    #candidatesTable th:nth-child(5),
    #candidatesTable td:nth-child(5),
    #candidatesTable th:nth-child(6),
    #candidatesTable td:nth-child(6),
    #candidatesTable th:nth-child(7),
    #candidatesTable td:nth-child(7) {
        display: none;
    }

    /* Missions table: Hide columns 3,5,7 (Lieu, Taux horaire, Créée le) */
    #missionsTable th:nth-child(3),
    #missionsTable td:nth-child(3),
    #missionsTable th:nth-child(5),
    #missionsTable td:nth-child(5),
    #missionsTable th:nth-child(7),
    #missionsTable td:nth-child(7) {
        display: none;
    }

    .candidates-table th,
    .candidates-table td {
        padding: 10px 12px;
        font-size: 12px;
    }

    .btn-action {
        padding: 6px 10px;
        font-size: 11px;
        min-width: 70px;
    }

    .actions-cell {
        gap: 4px;
    }
}

@media (max-width: 800px) {
    .app {
        padding: 12px;
    }

    .header {
        flex-direction: column;
        gap: 12px;
        align-items: stretch;
        padding: 12px;
    }

    .header-left {
        justify-content: center;
    }

    .header-right {
        flex-direction: row;
        justify-content: center;
        gap: 8px;
    }

    .connection-status {
        font-size: 11px;
        padding: 6px 10px;
    }

    .btn-primary {
        padding: 8px 12px;
        font-size: 12px;
    }

    /* KPIs - keep table layout, just smaller */
    .kpi-zone {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }

    .kpi-card {
        padding: 10px;
        gap: 8px;
    }

    .kpi-icon {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }

    .kpi-value {
        font-size: 18px;
    }

    .kpi-label {
        font-size: 9px;
    }

    /* Filters - horizontal compact */
    .filters {
        gap: 8px;
        padding: 10px;
    }

    .filter-group label {
        font-size: 9px;
    }

    select,
    input[type="text"] {
        min-width: 100px;
        padding: 8px;
        font-size: 11px;
    }

    /* Candidates table: Hide columns 3,5,6,7 (Localisation, Disponible jusqu'au, En mission, Dernière activité) */
    #candidatesTable th:nth-child(3),
    #candidatesTable td:nth-child(3),
    #candidatesTable th:nth-child(5),
    #candidatesTable td:nth-child(5),
    #candidatesTable th:nth-child(6),
    #candidatesTable td:nth-child(6),
    #candidatesTable th:nth-child(7),
    #candidatesTable td:nth-child(7) {
        display: none;
    }

    /* Fixed column widths for candidates table at 800px - visible: 1(Candidat), 2(Métier), 4(Statut), 8(Actions) */
    #candidatesTable th:nth-child(1),
    #candidatesTable td:nth-child(1) {
        width: 25%;
    }

    #candidatesTable th:nth-child(2),
    #candidatesTable td:nth-child(2) {
        width: 20%;
    }

    #candidatesTable th:nth-child(4),
    #candidatesTable td:nth-child(4) {
        width: 20%;
        text-align: center;
    }

    #candidatesTable th:nth-child(8),
    #candidatesTable td:nth-child(8) {
        width: 35%;
        min-width: 160px;
        text-align: center;
    }

    #candidatesTable .actions-cell {
        justify-content: center;
        flex-wrap: nowrap;
    }

    /* Missions table: Hide columns 3,5,7 (Lieu, Taux horaire, Créée le) */
    #missionsTable th:nth-child(3),
    #missionsTable td:nth-child(3),
    #missionsTable th:nth-child(5),
    #missionsTable td:nth-child(5),
    #missionsTable th:nth-child(7),
    #missionsTable td:nth-child(7) {
        display: none;
    }

    /* Fixed column widths for missions table at 800px */
    #missionsTable th:nth-child(1),
    #missionsTable td:nth-child(1) {
        width: 20%;
    }

    #missionsTable th:nth-child(2),
    #missionsTable td:nth-child(2) {
        width: 18%;
    }

    #missionsTable th:nth-child(4),
    #missionsTable td:nth-child(4) {
        width: 28%;
    }

    #missionsTable th:nth-child(6),
    #missionsTable td:nth-child(6) {
        width: 100px;
        min-width: 100px;
        max-width: 100px;
    }

    #missionsTable th:nth-child(8),
    #missionsTable td:nth-child(8) {
        width: 90px;
        min-width: 90px;
        max-width: 90px;
        text-align: left;
    }

    #missionsTable td:nth-child(8) {
        padding-left: 8px;
    }

    .candidates-table th,
    .candidates-table td {
        padding: 12px 6px;
        font-size: 11px;
        vertical-align: middle;
        height: 48px;
        box-sizing: border-box;
    }

    /* Ensure actions cell aligns with other cells */
    .candidates-table td:last-child {
        padding: 12px 6px;
    }

    .candidate-name {
        font-size: 12px;
    }

    .candidate-phone {
        font-size: 9px;
    }

    .badge,
    .status-badge {
        padding: 3px 6px;
        font-size: 9px;
    }

    .reliability-badge {
        display: none;
    }

    /* Actions compact but visible */
    .actions-cell {
        gap: 4px;
    }

    .btn-action {
        padding: 4px 6px;
        font-size: 9px;
        min-width: 55px;
    }

    /* Tabs nav */
    .tabs-nav {
        width: 100%;
        padding: 4px;
    }

    .tab-btn {
        flex: 1;
        justify-content: center;
        padding: 8px;
        font-size: 11px;
    }

    /* Toast notifications */
    .toast-container {
        left: 12px;
        right: 12px;
        bottom: 12px;
    }

    .toast {
        min-width: unset;
    }

    /* Modal responsive */
    .modal {
        margin: 16px;
        max-width: calc(100% - 32px);
        max-height: calc(100vh - 32px);
        overflow-y: auto;
    }

    .modal-header {
        padding: 16px;
    }

    .modal-body {
        padding: 16px;
    }

    .modal-footer {
        padding: 12px 16px;
        flex-direction: column;
    }

    .modal-footer button {
        width: 100%;
    }

    .form-row {
        flex-direction: column;
        gap: 12px;
    }

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

@media (max-width: 480px) {
    .app {
        padding: 6px;
    }

    .kpi-zone {
        grid-template-columns: repeat(2, 1fr);
    }

    .logo-text h1 {
        font-size: 13px;
    }

    .agency-name {
        font-size: 9px;
    }

    .btn-primary {
        padding: 5px 8px;
        font-size: 10px;
    }

    /* Candidates: Show only Candidat, Statut, Actions */
    #candidatesTable th:nth-child(2),
    #candidatesTable td:nth-child(2),
    #candidatesTable th:nth-child(3),
    #candidatesTable td:nth-child(3),
    #candidatesTable th:nth-child(5),
    #candidatesTable td:nth-child(5),
    #candidatesTable th:nth-child(6),
    #candidatesTable td:nth-child(6),
    #candidatesTable th:nth-child(7),
    #candidatesTable td:nth-child(7) {
        display: none;
    }

    /* Missions: Show only Candidat, Dates, Statut, Actions */
    #missionsTable th:nth-child(2),
    #missionsTable td:nth-child(2),
    #missionsTable th:nth-child(3),
    #missionsTable td:nth-child(3),
    #missionsTable th:nth-child(5),
    #missionsTable td:nth-child(5),
    #missionsTable th:nth-child(7),
    #missionsTable td:nth-child(7) {
        display: none;
    }

    .candidates-table th,
    .candidates-table td {
        padding: 5px 3px;
        font-size: 9px;
    }

    .btn-action {
        padding: 3px 4px;
        font-size: 7px;
        min-width: 40px;
    }
}

/* =============================================================================
   IFRAME / EMBEDDED CONTEXT RESPONSIVE
   Pour affichage dans iframes de petite taille (ex: demo sur site vitrine)
   Garde le format tableau professionnel
   ============================================================================= */

@media (max-width: 650px) {
    .app {
        padding: 8px;
    }

    /* Header ultra compact */
    .header {
        padding: 10px;
        margin-bottom: 12px;
    }

    .logo-text h1 {
        font-size: 14px;
    }

    .agency-name {
        font-size: 10px;
    }

    .connection-status {
        font-size: 10px;
        padding: 4px 8px;
    }

    .btn-primary {
        padding: 6px 10px;
        font-size: 11px;
    }

    /* KPIs mini */
    .kpi-zone {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
        margin-bottom: 12px;
    }

    .kpi-card {
        padding: 8px;
        gap: 6px;
    }

    .kpi-icon {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }

    .kpi-value {
        font-size: 16px;
    }

    .kpi-label {
        font-size: 8px;
    }

    /* Tabs mini */
    .tabs-nav {
        margin-bottom: 12px;
        padding: 3px;
    }

    .tab-btn {
        padding: 6px 8px;
        font-size: 10px;
    }

    /* Filters mini */
    .filters {
        padding: 8px;
        gap: 6px;
        margin-bottom: 10px;
    }

    .filter-group label {
        font-size: 8px;
    }

    select,
    input[type="text"] {
        padding: 6px 8px;
        font-size: 10px;
        min-width: 80px;
    }

    /* Candidates: Show only Candidat, Statut, Actions */
    #candidatesTable th:nth-child(2),
    #candidatesTable td:nth-child(2),
    #candidatesTable th:nth-child(3),
    #candidatesTable td:nth-child(3),
    #candidatesTable th:nth-child(5),
    #candidatesTable td:nth-child(5),
    #candidatesTable th:nth-child(6),
    #candidatesTable td:nth-child(6),
    #candidatesTable th:nth-child(7),
    #candidatesTable td:nth-child(7) {
        display: none;
    }

    /* Missions: Show only Candidat, Dates, Statut, Actions */
    #missionsTable th:nth-child(2),
    #missionsTable td:nth-child(2),
    #missionsTable th:nth-child(3),
    #missionsTable td:nth-child(3),
    #missionsTable th:nth-child(5),
    #missionsTable td:nth-child(5),
    #missionsTable th:nth-child(7),
    #missionsTable td:nth-child(7) {
        display: none;
    }

    /* Fixed column widths for missions table - visible: 1(Candidat), 4(Dates), 6(Statut), 8(Actions) */
    #missionsTable th:nth-child(1),
    #missionsTable td:nth-child(1) {
        width: 18%;
    }

    #missionsTable th:nth-child(4),
    #missionsTable td:nth-child(4) {
        width: 40%;
    }

    #missionsTable th:nth-child(6),
    #missionsTable td:nth-child(6) {
        width: 22%;
        text-align: center;
    }

    #missionsTable th:nth-child(8),
    #missionsTable td:nth-child(8) {
        width: 20%;
        text-align: center;
    }

    /* Force alignment for all action buttons */
    #missionsTable td:nth-child(8) {
        text-align: center !important;
    }

    #missionsTable .actions-cell,
    #missionsTable td[data-label="Actions"] {
        justify-content: center;
        width: 100%;
    }

    /* Fixed column widths for candidates table - visible: 1(Candidat), 4(Statut), 8(Actions) */
    #candidatesTable th:nth-child(1),
    #candidatesTable td:nth-child(1) {
        width: 35%;
    }

    #candidatesTable th:nth-child(4),
    #candidatesTable td:nth-child(4) {
        width: 25%;
        text-align: center;
    }

    #candidatesTable th:nth-child(8),
    #candidatesTable td:nth-child(8) {
        width: 40%;
        text-align: center;
    }

    #candidatesTable .actions-cell {
        justify-content: center;
        width: 100%;
        flex-wrap: nowrap;
    }

    .candidates-table th,
    .candidates-table td {
        padding: 6px 4px;
        font-size: 10px;
    }

    .candidate-name {
        font-size: 11px;
    }

    .candidate-phone {
        font-size: 8px;
    }

    .badge,
    .status-badge {
        padding: 2px 5px;
        font-size: 8px;
    }

    .reliability-badge {
        display: none;
    }

    /* Actions mini */
    .actions-cell {
        gap: 3px;
        justify-content: center;
    }

    .btn-action {
        padding: 4px 8px;
        font-size: 10px;
        min-width: auto;
        width: auto;
        white-space: nowrap;
    }

    /* Toast mini */
    .toast-container {
        bottom: 6px;
        right: 6px;
        left: 6px;
    }

    .toast {
        min-width: unset;
        padding: 8px 10px;
    }

    .toast-title {
        font-size: 11px;
    }

    .toast-message {
        font-size: 10px;
    }
}
