/* SAV MegaLife - Design MegaLife Theme */

:root {
    /* MegaLife Primary Colors */
    --sap-blue: #cc1336;
    --sap-blue-dark: #a80f2c;
    --sap-blue-light: #e01940;
    --sap-shell: #f4f4f4;
    --sap-shell-dark: #e8e8e8;

    /* Status Colors */
    --success: #107e3e;
    --warning: #df6e0c;
    --error: #bb0000;
    --info: #cc1336;

    /* Neutral Colors */
    --background: #f8f7f7;
    --surface: #ffffff;
    --border: #d9d9d9;
    --text-primary: #32363a;
    --text-secondary: #6a6d70;
    --text-light: #89919a;

    /* Priority Colors */
    --priority-critical: #bb0000;
    --priority-high: #e9730c;
    --priority-medium: #cc1336;
    --priority-low: #107e3e;

    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;

    /* Border Radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.12);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.15);
}

/* Reset */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: '72', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
    background-color: var(--background);
    min-height: 100vh;
}

/* ========== SHELL HEADER ========== */
.shell-header {
    background: linear-gradient(135deg, var(--sap-shell) 0%, var(--sap-shell-dark) 100%);
    color: var(--text-primary);
    padding: var(--spacing-sm) var(--spacing-lg);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: var(--shadow-md);
    gap: var(--spacing-lg);
    border-bottom: 3px solid var(--sap-blue);
}

.shell-left,
.shell-right {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.shell-center {
    flex: 1;
    max-width: 400px;
}

.shell-logo {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    font-size: 1.2rem;
    font-weight: 600;
    white-space: nowrap;
    color: var(--sap-blue);
}

.shell-logo svg {
    width: 32px;
    height: 32px;
}

/* Search Global */
.search-global {
    width: 100%;
}

.search-input {
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 0.875rem;
    background: white;
    color: var(--text-primary);
    transition: all 0.2s ease;
}

.search-input::placeholder {
    color: var(--text-light);
}

.search-input:focus {
    outline: none;
    border-color: var(--sap-blue);
    box-shadow: 0 0 0 2px rgba(204, 19, 54, 0.15);
}

/* Shell Date */
.shell-date {
    font-size: 0.8rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

/* Shell Notification */
.shell-notification {
    position: relative;
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    padding: var(--spacing-xs);
}

.notification-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background: var(--sap-blue);
    color: white;
    font-size: 0.65rem;
    font-weight: 600;
    padding: 2px 5px;
    border-radius: 10px;
    min-width: 16px;
    text-align: center;
}

/* User Avatar */
.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--sap-blue);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1rem;
}

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

.shell-user-info {
    text-align: right;
}

.shell-user-name {
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--text-primary);
}

.shell-user-role {
    font-size: 0.7rem;
    color: var(--text-secondary);
}

.btn-icon {
    background: none;
    border: none;
    color: var(--sap-blue);
    font-size: 1.1rem;
    cursor: pointer;
    padding: var(--spacing-xs);
    transition: color 0.2s ease;
}

.btn-icon:hover {
    color: var(--sap-blue-dark);
}

/* ========== MAIN CONTENT ========== */
.main-content {
    padding: var(--spacing-lg);
    max-width: 1400px;
    margin: 0 auto;
}

/* ========== PAGE HEADER ========== */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-lg);
}

.page-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.page-subtitle {
    color: var(--text-secondary);
    margin-top: var(--spacing-xs);
}

/* ========== CARDS ========== */
.card {
    background: var(--surface);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    overflow: hidden;
}

.card-header {
    padding: var(--spacing-md) var(--spacing-lg);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
}

.card-body {
    padding: var(--spacing-lg);
}

/* ========== STATS GRID ========== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

.stat-card {
    background: var(--surface);
    border-radius: var(--radius-md);
    padding: var(--spacing-lg);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.stat-icon.blue {
    background: rgba(10, 110, 209, 0.1);
    color: var(--sap-blue);
}

.stat-icon.green {
    background: rgba(16, 126, 62, 0.1);
    color: var(--success);
}

.stat-icon.orange {
    background: rgba(223, 110, 12, 0.1);
    color: var(--warning);
}

.stat-icon.red {
    background: rgba(187, 0, 0, 0.1);
    color: var(--error);
}

.stat-content {
    flex: 1;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

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

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

.data-table th,
.data-table td {
    padding: var(--spacing-md);
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.data-table th {
    background: var(--background);
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.data-table tbody tr:hover {
    background: rgba(10, 110, 209, 0.03);
}

.data-table tbody tr {
    cursor: pointer;
    transition: background 0.15s ease;
}

/* ========== BADGES / STATUS ========== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-success {
    background: rgba(16, 126, 62, 0.1);
    color: var(--success);
}

.badge-warning {
    background: rgba(223, 110, 12, 0.1);
    color: var(--warning);
}

.badge-error {
    background: rgba(187, 0, 0, 0.1);
    color: var(--error);
}

.badge-info {
    background: rgba(10, 110, 209, 0.1);
    color: var(--info);
}

.badge-neutral {
    background: var(--background);
    color: var(--text-secondary);
}

/* Priority badges */
.priority-critical {
    background: var(--priority-critical);
    color: white;
}

.priority-high {
    background: var(--priority-high);
    color: white;
}

.priority-medium {
    background: var(--priority-medium);
    color: white;
}

.priority-low {
    background: var(--priority-low);
    color: white;
}

/* ========== BUTTONS ========== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
    text-decoration: none;
}

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

.btn-primary:hover {
    background: var(--sap-blue-dark);
}

.btn-secondary {
    background: var(--surface);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--background);
}

.btn-danger {
    background: var(--error);
    color: white;
}

.btn-danger:hover {
    background: #990000;
}

.btn-sm {
    padding: var(--spacing-xs) var(--spacing-sm);
    font-size: 0.75rem;
}

.btn-lg {
    padding: var(--spacing-md) var(--spacing-xl);
    font-size: 1rem;
}

/* ========== FORMS ========== */
.form-group {
    margin-bottom: var(--spacing-md);
}

.form-label {
    display: block;
    margin-bottom: var(--spacing-xs);
    font-weight: 500;
    color: var(--text-secondary);
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--sap-blue);
    box-shadow: 0 0 0 3px rgba(10, 110, 209, 0.1);
}

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

/* ========== LOGIN PAGE ========== */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #cc1336 0%, #a80f2c 100%);
}

.login-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: var(--spacing-xl);
    width: 100%;
    max-width: 400px;
}

.login-logo {
    text-align: center;
    margin-bottom: var(--spacing-xl);
}

.login-logo h1 {
    color: var(--sap-blue);
    font-size: 1.5rem;
    margin-top: var(--spacing-sm);
}

.login-logo svg {
    width: 64px;
    height: 64px;
    color: var(--sap-blue);
}

.login-error {
    background: rgba(187, 0, 0, 0.1);
    color: var(--error);
    padding: var(--spacing-md);
    border-radius: var(--radius-sm);
    margin-bottom: var(--spacing-md);
    display: none;
}

.login-error.show {
    display: block;
}

.login-success {
    background: rgba(16, 126, 62, 0.1);
    color: var(--success);
    padding: var(--spacing-md);
    border-radius: var(--radius-sm);
    margin-bottom: var(--spacing-md);
    display: none;
}

/* ========== TIMELINE ========== */
.timeline {
    position: relative;
    padding-left: var(--spacing-xl);
}

.timeline::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border);
}

.timeline-item {
    position: relative;
    padding-bottom: var(--spacing-lg);
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: calc(-1 * var(--spacing-xl) + 4px);
    top: 4px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--border);
    border: 2px solid var(--surface);
}

.timeline-item.completed::before {
    background: var(--success);
}

.timeline-item.in-progress::before {
    background: var(--sap-blue);
    box-shadow: 0 0 0 4px rgba(10, 110, 209, 0.2);
}

.timeline-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: var(--spacing-xs);
}

.timeline-title {
    font-weight: 600;
}

.timeline-date {
    font-size: 0.75rem;
    color: var(--text-light);
}

.timeline-content {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* ========== WORKFLOW STEPS ========== */
.workflow-steps {
    display: flex;
    gap: var(--spacing-xs);
    padding: var(--spacing-md) 0;
    overflow-x: auto;
}

.workflow-step {
    flex: 1;
    min-width: 120px;
    text-align: center;
    padding: var(--spacing-sm);
    background: var(--background);
    border-radius: var(--radius-sm);
    position: relative;
}

.workflow-step.completed {
    background: rgba(16, 126, 62, 0.1);
}

.workflow-step.current {
    background: rgba(10, 110, 209, 0.1);
    border: 2px solid var(--sap-blue);
}

.workflow-step-icon {
    width: 32px;
    height: 32px;
    margin: 0 auto var(--spacing-xs);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--border);
    color: var(--text-secondary);
}

.workflow-step.completed .workflow-step-icon {
    background: var(--success);
    color: white;
}

.workflow-step.current .workflow-step-icon {
    background: var(--sap-blue);
    color: white;
}

.workflow-step-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* ========== SAISIE AVEC SUGGESTIONS (App.attachSuggestions, App.enhanceSelectSearch) ========== */
.suggest-wrap,
.select-search {
    position: relative;
}

.suggest-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 2100;
    max-height: 260px;
    margin-top: 2px;
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
}

.suggest-list[hidden] {
    display: none;
}

.suggest-item {
    padding: 4px 8px;
    cursor: pointer;
    font-size: 12px;
    line-height: 1.3;
}

.suggest-item small {
    display: block;
    color: var(--text-secondary);
    font-size: 11px;
}

.suggest-item.active,
.suggest-item:hover {
    background: var(--win-hover, #fdf2f4);
}

.suggest-empty {
    padding: 6px 8px;
    color: var(--text-light);
    font-size: 12px;
}

/* ========== MODALS ========== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
}

.modal-overlay.show {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow: auto;
    transform: translateY(-20px);
    transition: transform 0.2s ease;
}

.modal-overlay.show .modal {
    transform: translateY(0);
}

.modal-overlay.page-mode {
    align-items: flex-start;
    justify-content: flex-start;
    background: var(--bg-primary);
    padding: var(--spacing-md);
}

.modal-overlay.page-mode .modal {
    width: calc(100vw - (var(--spacing-md) * 2)) !important;
    max-width: none !important;
    height: calc(100vh - (var(--spacing-md) * 2)) !important;
    max-height: none !important;
    transform: none;
    border-radius: 0;
    box-shadow: none;
}

.modal-overlay.page-mode .modal-header {
    position: sticky;
    top: 0;
    background: var(--surface);
    z-index: 3;
}

.modal-overlay.page-mode .modal-close {
    display: none;
}

.modal-back {
    white-space: nowrap;
}

.modal-overlay.page-mode .modal-body {
    padding: var(--spacing-lg) var(--spacing-xl);
}

.modal-overlay.page-mode .modal form {
    max-width: none;
}

.modal-overlay.page-mode .modal .form-input,
.modal-overlay.page-mode .modal .form-select,
.modal-overlay.page-mode .modal .form-textarea {
    font-size: 1rem;
}

.modal-overlay.page-mode .modal .form-textarea {
    min-height: 160px;
}

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

.modal-title {
    font-size: 1.25rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-light);
    padding: 0;
    line-height: 1;
}

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

.modal-body {
    padding: var(--spacing-lg);
}

.modal-footer {
    padding: var(--spacing-lg);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: var(--spacing-sm);
}

/* ========== IMAGE GALLERY ========== */
.image-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: var(--spacing-md);
}

.image-item {
    aspect-ratio: 1;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: transform 0.2s ease;
}

.image-item:hover {
    transform: scale(1.02);
}

.image-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ========== ALERTS ========== */
.alert {
    padding: var(--spacing-md);
    border-radius: var(--radius-sm);
    margin-bottom: var(--spacing-md);
    display: flex;
    align-items: flex-start;
    gap: var(--spacing-sm);
}

.alert-success {
    background: rgba(16, 126, 62, 0.1);
    color: var(--success);
    border: 1px solid rgba(16, 126, 62, 0.2);
}

.alert-error {
    background: rgba(187, 0, 0, 0.1);
    color: var(--error);
    border: 1px solid rgba(187, 0, 0, 0.2);
}

.alert-warning {
    background: rgba(223, 110, 12, 0.1);
    color: var(--warning);
    border: 1px solid rgba(223, 110, 12, 0.2);
}

.alert-info {
    background: rgba(10, 110, 209, 0.1);
    color: var(--info);
    border: 1px solid rgba(10, 110, 209, 0.2);
}

/* ========== LOADING ========== */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-xl);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--sap-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.spinner-sm {
    width: 14px;
    height: 14px;
    border-width: 2px;
    vertical-align: middle;
    display: inline-block;
    margin-right: 6px;
}

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

/* ========== API / AI REQUEST FEEDBACK ========== */
.app-toast-stack {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: min(420px, calc(100vw - 32px));
    pointer-events: none;
}

.app-toast {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border-radius: var(--radius-md);
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    color: var(--text-primary);
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    pointer-events: auto;
}

.app-toast.show {
    opacity: 1;
    transform: translateY(0);
}

.app-toast-icon {
    width: 22px;
    height: 22px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    font-weight: 700;
}

.app-toast-text {
    line-height: 1.4;
    font-size: 0.9rem;
}

.app-toast-success {
    border-color: rgba(16, 126, 62, 0.35);
}

.app-toast-success .app-toast-icon {
    background: rgba(16, 126, 62, 0.12);
    color: var(--success);
}

.app-toast-error {
    border-color: rgba(187, 0, 0, 0.35);
}

.app-toast-error .app-toast-icon {
    background: rgba(187, 0, 0, 0.12);
    color: var(--error);
}

.app-toast-warning .app-toast-icon {
    background: rgba(223, 110, 12, 0.12);
    color: var(--warning);
}

.app-toast-info .app-toast-icon {
    background: rgba(10, 110, 209, 0.12);
    color: var(--info);
}

.ai-loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 2500;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.28);
    backdrop-filter: blur(2px);
}

.ai-loading-overlay.show {
    display: flex;
}

.ai-loading-card {
    min-width: min(360px, calc(100vw - 32px));
    max-width: 460px;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}

.ai-loading-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border);
    border-top-color: var(--sap-blue);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    flex: 0 0 auto;
}

.ai-loading-title {
    font-weight: 700;
    color: var(--text-primary);
}

.ai-loading-message {
    margin-top: 3px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.35;
}

.ai-debug-overlay {
    position: fixed;
    inset: 0;
    z-index: 2600;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
    background: rgba(15, 23, 42, 0.62);
}

.ai-debug-overlay.show {
    display: flex;
}

.ai-debug-dialog {
    width: min(1100px, 96vw);
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.ai-debug-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
}

.ai-debug-header h3 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.ai-debug-header p {
    margin: 0.25rem 0 0;
    color: var(--text-secondary);
    font-size: 0.88rem;
}

.ai-debug-close {
    border: 0;
    background: transparent;
    font-size: 1.8rem;
    line-height: 1;
    color: var(--text-secondary);
    cursor: pointer;
}

.ai-debug-body {
    overflow: auto;
    padding: 1rem 1.25rem 1.25rem;
}

.ai-debug-section {
    margin: 0 0 1rem;
}

.ai-debug-section h4 {
    margin: 0 0 0.4rem;
    font-size: 0.88rem;
    color: var(--text-primary);
}

.ai-debug-section pre {
    margin: 0;
    max-height: 320px;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
    background: #0f172a;
    color: #e2e8f0;
    border-radius: 6px;
    padding: 0.85rem;
    font-size: 0.78rem;
    line-height: 1.5;
}

/* ========== EMPTY STATE ========== */
.empty-state {
    text-align: center;
    padding: var(--spacing-xl);
    color: var(--text-secondary);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: var(--spacing-md);
    opacity: 0.5;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.tab {
    background: transparent;
    border: none;
    padding: 0.5rem 0.75rem;
    color: var(--text-secondary);
    font-weight: 600;
    cursor: pointer;
    border-bottom: 2px solid transparent;
}

.tab.active {
    color: var(--sap-blue);
    border-bottom-color: var(--sap-blue);
}

.tab-panel {
    display: none;
    margin-top: var(--spacing-md);
}

.tab-panel.active {
    display: block;
}

.header-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.tag-list {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.tag {
    background: #eef2f7;
    color: #2b3a55;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 12px;
    border: 1px solid #d6dde6;
}

.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: 8px;
}

.image-thumb {
    display: block;
    position: relative;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
}

.image-thumb img {
    display: block;
    width: 100%;
    height: 90px;
    object-fit: cover;
}

.view-toggle {
    display: inline-flex;
    gap: 6px;
}

.parts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}

.parts-grid-compact {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
}

.part-card {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.part-card .image-thumb img {
    height: 140px;
}

.part-card.compact {
    padding: 10px;
    border-radius: 10px;
}

.parts-grid-compact .part-card .image-thumb img {
    height: 110px;
}

.part-card-placeholder {
    height: 140px;
    border: 1px dashed var(--border);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #8a97a6;
    font-size: 12px;
}

.part-card-title {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.part-card-sku {
    font-weight: 600;
}

.part-card-name {
    color: #5b6673;
    font-size: 13px;
}

.part-card-actions {
    display: flex;
    gap: 6px;
    margin-top: auto;
}

.email-domain-group {
    margin-bottom: 0.75rem;
}

.email-domain-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    color: #2c3a4a;
    background: #f4f7fb;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.4rem 0.6rem;
    margin: 0.5rem 0;
}

.email-group-caret {
    font-size: 0.85rem;
    opacity: 0.8;
}

.email-group-body {
    overflow: hidden;
    max-height: 2000px;
    opacity: 1;
    transition: max-height 0.2s ease, opacity 0.2s ease;
}

.email-domain-group.collapsed .email-group-body {
    max-height: 0;
    opacity: 0;
}

.case-row.email-today {
    background: #e8f4ff;
    border-left: 3px solid #3b82f6;
}

.badge-today {
    background: #3b82f6;
    color: #fff;
}

.image-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    border: none;
    background: rgba(0,0,0,0.6);
    color: #fff;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    cursor: pointer;
    line-height: 18px;
    font-size: 14px;
}

.search-results {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    margin-top: 6px;
    max-height: 220px;
    overflow: auto;
}

.search-item {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
}

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

.search-item:hover {
    background: var(--background);
}

.part-item {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px dashed var(--border);
}

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

.part-item-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}

.modal.modal-lg {
    max-width: 720px;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 768px) {
    .modal-overlay.page-mode {
        padding: 0;
    }

    .modal-overlay.page-mode .modal {
        width: 100vw !important;
        max-width: 100vw !important;
        height: 100vh !important;
        border-radius: 0;
    }

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

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

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--spacing-md);
    }

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

    .data-table th,
    .data-table td {
        padding: var(--spacing-sm);
        font-size: 0.8rem;
    }
}

/* ========== UTILITIES ========== */
.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.text-muted {
    color: var(--text-secondary);
}

.text-sm {
    font-size: 0.875rem;
}

.text-xs {
    font-size: 0.75rem;
}

.font-bold {
    font-weight: 600;
}

.mt-md {
    margin-top: var(--spacing-md);
}

.mb-md {
    margin-bottom: var(--spacing-md);
}

.hidden {
    display: none !important;
}

.flex {
    display: flex;
}

.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.gap-sm {
    gap: var(--spacing-sm);
}

.gap-md {
    gap: var(--spacing-md);
}

/* ========== ACTION BUTTONS GROUP ========== */
.action-buttons {
    display: flex;
    gap: var(--spacing-sm);
    flex-wrap: wrap;
}

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

.btn-success:hover {
    background: #0d6b34;
}

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

.btn-warning:hover {
    background: #c85f0a;
}

.btn-info {
    background: var(--sap-blue);
    color: white;
}

.btn-outline {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-outline:hover {
    background: var(--background);
}

.btn-pink {
    background: #e91e63;
    color: white;
}

.btn-pink:hover {
    background: #c2185b;
}

/* ========== FILTRES REPLIABLES ========== */
/* Zone de filtres en tête d'une liste :
   <details class="card filters-panel" data-filters-panel="CLÉ" open>
       <summary class="filters-panel-toggle">Filtres<span class="filters-panel-count"></span></summary> …
   Le titre est une petite barre cliquable sur tous les écrans (▸ fermé, ▾ ouvert) ; fermée, seule la barre reste.
   App.initFilterPanels() (app.js) retient l'état par page et écrit le nombre de filtres appliqués dans .filters-panel-count.
   Même principe que le panneau de cases.php (.cases-filters-toggle dans cases.css). */
.filters-panel-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    list-style: none;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    user-select: none;
}

.filters-panel-toggle::-webkit-details-marker {
    display: none;
}

.filters-panel-toggle::before {
    content: '▸';
    display: inline-block;
    width: 12px;
    color: var(--text-secondary);
}

.filters-panel[open] > .filters-panel-toggle::before {
    content: '▾';
}

.filters-panel-toggle:hover {
    background: var(--background);
}

.filters-panel[open] > .filters-panel-toggle {
    border-bottom: 1px solid var(--border);
}

/* Nombre de filtres appliqués : gris discret à côté du titre (vide : rien d'affiché). */
.filters-panel-count {
    font-size: 11.5px;
    font-weight: 400;
    color: var(--text-light);
}

.filters-panel-count:empty {
    display: none;
}

/* Variante sans cadre (emails.php) : la barre reste alignée sur les filtres, sans trait ni survol. */
.filters-panel-flat > .filters-panel-toggle,
.filters-panel-flat[open] > .filters-panel-toggle {
    padding-left: 0;
    padding-right: 0;
    border-bottom: 0;
}

.filters-panel-flat > .filters-panel-toggle:hover {
    background: transparent;
}

/* emails.php : la zone de filtres occupe la place qu'avaient les filtres à côté des onglets ; repliée, elle ne garde que sa barre. */
.email-tools > .filters-panel {
    flex: 1;
    min-width: min(100%, 620px);
}

.email-tools > .filters-panel:not([open]) {
    flex: 0 1 auto;
    min-width: 0;
}

/* ========== ENHANCED TABLE ========== */
.case-row {
    display: flex;
    flex-direction: column;
    padding: var(--spacing-md);
    border-bottom: 1px solid var(--border);
    transition: background 0.15s ease;
}

.case-row:hover {
    background: rgba(10, 110, 209, 0.03);
}

.case-row-main {
    display: grid;
    grid-template-columns: 1fr 1.5fr 1fr 1.5fr 2fr auto;
    gap: var(--spacing-md);
    align-items: start;
}

.case-badges {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.badge-small {
    font-size: 0.65rem;
    padding: 2px 6px;
}

.badge-contract {
    background: #e3f2fd;
    color: #1565c0;
    border: 1px solid #bbdefb;
}

.badge-type {
    background: #fff3e0;
    color: #e65100;
    border: 1px solid #ffe0b2;
}

/* Client Info */
.client-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.client-name {
    font-weight: 600;
    color: var(--text-primary);
}

.client-phone {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.client-address {
    font-size: 0.75rem;
    color: var(--text-light);
}

/* Status with Timer */
.status-cell {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.status-timer {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.7rem;
    color: var(--text-light);
}

.timer-icon {
    font-size: 0.8rem;
}

.timer-danger {
    color: var(--error);
    font-weight: 600;
}

.timer-warning {
    color: var(--warning);
    font-weight: 600;
}

/* Product Info */
.product-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.product-name {
    font-weight: 500;
}

.product-code {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.product-serial {
    font-size: 0.7rem;
    color: var(--text-light);
}

/* Quick Actions */
.quick-actions {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
    min-width: 150px;
}

.btn-action {
    font-size: 0.7rem;
    padding: 4px 8px;
    white-space: nowrap;
}

.btn-action-orange {
    background: #ff9800;
    color: white;
}

.btn-action-orange:hover {
    background: #f57c00;
}

.btn-action-blue {
    background: var(--sap-blue);
    color: white;
}

.btn-action-blue:hover {
    background: var(--sap-blue-dark);
}

.btn-action-yellow {
    background: #ffc107;
    color: #333;
}

.btn-action-yellow:hover {
    background: #ffa000;
}

/* Row Meta (shown below main row) */
.case-row-meta {
    display: flex;
    align-items: center;
    gap: var(--spacing-lg);
    padding-top: var(--spacing-sm);
    margin-top: var(--spacing-sm);
    font-size: 0.75rem;
    color: var(--text-light);
    border-top: 1px dashed var(--border);
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ========== PAGINATION ========== */
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-md);
    border-top: 1px solid var(--border);
}

.pagination-info {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.pagination-buttons {
    display: flex;
    gap: var(--spacing-xs);
}

.page-btn {
    min-width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-primary);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.page-btn:hover {
    background: var(--background);
}

.page-btn.active {
    background: var(--sap-blue);
    color: white;
    border-color: var(--sap-blue);
}

/* ========== RESPONSIVE ADJUSTMENTS ========== */
@media (max-width: 1024px) {
    .case-row-main {
        grid-template-columns: 1fr;
        gap: var(--spacing-sm);
    }

    .quick-actions {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .shell-center {
        display: none;
    }

    .shell-date {
        display: none;
    }
}

@media (max-width: 768px) {
    .action-buttons {
        width: 100%;
        justify-content: stretch;
    }

    .action-buttons .btn {
        flex: 1;
        justify-content: center;
    }
}

/* ========== INLINE STYLE REPLACEMENTS ========== */
.shell-logo-img {
    height: 24px;
    width: auto;
}

.form-select-sm {
    max-width: 160px;
}

/* ========== SAP B1 COMPACT FORM GRID ========== */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 5px 12px;
}

.form-grid-2 { grid-template-columns: repeat(2, 1fr); }
.form-grid-3 { grid-template-columns: repeat(3, 1fr); }
.form-grid-4 { grid-template-columns: repeat(4, 1fr); }

.form-inline {
    display: flex;
    align-items: center;
    gap: 6px;
}

.form-inline .form-label {
    white-space: nowrap;
    margin-bottom: 0;
    min-width: fit-content;
}

.form-inline .form-input,
.form-inline .form-select {
    flex: 1;
}

.fieldset {
    border: 1px solid #c8c8c8;
    border-radius: 2px;
    padding: 6px 10px 10px;
    margin-bottom: 8px;
}

.fieldset legend {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    padding: 0 4px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.toolbar {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background: #f0f0f0;
    border: 1px solid var(--border);
    border-bottom: none;
}

.toolbar-separator {
    width: 1px;
    height: 18px;
    background: #c0c0c0;
    margin: 0 2px;
}

.data-table tbody tr.selected {
    background: #c0d9f0 !important;
}

.data-table td.actions-col {
    white-space: nowrap;
    width: 1%;
}

.data-table .badge {
    font-size: 10px;
    padding: 1px 4px;
}

.table-container::-webkit-scrollbar { height: 8px; width: 8px; }
.table-container::-webkit-scrollbar-track { background: #f0f0f0; }
.table-container::-webkit-scrollbar-thumb { background: #c0c0c0; border-radius: 2px; }
.table-container::-webkit-scrollbar-thumb:hover { background: #a0a0a0; }

/* ========== EN-TÊTE COMMUN SUR MOBILE ========== */
/* Un nom long poussait l'en-tête au-delà de l'écran (413 px pour 390) : tronqué, puis masqué. */
@media (max-width: 768px) {
    .shell-user-name,
    .shell-user-role {
        max-width: 140px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}

@media (max-width: 480px) {
    .shell-user-info {
        display: none;
    }
}
