/* ============================================================================
   STYLES GLOBAUX
   ============================================================================ */

:root {
    --primary: #4F46E5;
    --primary-dark: #4338CA;
    --primary-light: #6366F1;
    --secondary: #8B5CF6;
    --success: #10B981;
    --danger: #EF4444;
    --warning: #F59E0B;
    --info: #3B82F6;
    --gray-50: #F9FAFB;
    --gray-100: #F3F4F6;
    --gray-200: #E5E7EB;
    --gray-300: #D1D5DB;
    --gray-400: #9CA3AF;
    --gray-500: #6B7280;
    --gray-600: #4B5563;
    --gray-700: #374151;
    --gray-800: #1F2937;
    --gray-900: #111827;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--gray-50);
    color: var(--gray-700);
    line-height: 1.6;
}

/* ============================================================================
   NAVBAR
   ============================================================================ */

.navbar {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    padding: 1rem 0;
    box-shadow: var(--shadow-lg);
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.navbar-title {
    font-size: 1.5rem;
    font-weight: 600;
}

.navbar-right {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.user-info {
    font-size: 0.9rem;
    opacity: 0.95;
}

.btn-logout {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.btn-logout:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ============================================================================
   MAIN CONTENT
   ============================================================================ */

.main-content {
    max-width: 1400px;
    margin: 2rem auto;
    padding: 0 2rem;
}

/* ============================================================================
   FOOTER
   ============================================================================ */

.footer {
    background: var(--gray-800);
    color: var(--gray-400);
    text-align: center;
    padding: 2rem;
    margin-top: 4rem;
    font-size: 0.875rem;
}

/* ============================================================================
   LOGIN PAGE
   ============================================================================ */

.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
}

.login-card {
    background: white;
    padding: 3rem;
    border-radius: 1rem;
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 400px;
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-header h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.login-header p {
    color: var(--gray-500);
    font-size: 0.9rem;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--gray-700);
    font-size: 0.9rem;
}

.form-group input {
    padding: 0.75rem;
    border: 1px solid var(--gray-300);
    border-radius: 0.375rem;
    font-size: 1rem;
    transition: all 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.btn-lg {
    padding: 0.875rem;
    font-size: 1rem;
}

.login-footer {
    text-align: center;
    margin-top: 2rem;
    color: var(--gray-500);
    font-size: 0.875rem;
}

.alert {
    padding: 1rem;
    border-radius: 0.375rem;
    margin-bottom: 1rem;
}

.alert-danger {
    background: #FEE2E2;
    color: #991B1B;
    border: 1px solid #FECACA;
}

/* ============================================================================
   BUTTONS
   ============================================================================ */

.btn-primary,
.btn-secondary,
.btn-success,
.btn-danger,
.btn-info {
    padding: 0.75rem 1.25rem;
    border: none;
    border-radius: 0.375rem;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--gray-200);
    color: var(--gray-700);
}

.btn-secondary:hover {
    background: var(--gray-300);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: #059669;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #DC2626;
}

.btn-info {
    background: var(--info);
    color: white;
}

.btn-info:hover {
    background: #2563EB;
}

/* ============================================================================
   DASHBOARD
   ============================================================================ */

.dashboard-container {
    display: flex;
    flex-direction: column;
    gap: 3rem;
}

.dashboard-header {
    text-align: center;
}

.dashboard-header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.dashboard-header p {
    color: var(--gray-500);
    font-size: 1.1rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.stat-card {
    background: white;
    padding: 2rem;
    border-radius: 1rem;
    box-shadow: var(--shadow-md);
    display: flex;
    gap: 1.5rem;
    border-left: 4px solid var(--primary);
    transition: all 0.3s;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.stat-icon {
    font-size: 3rem;
    min-width: 4rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-content h3 {
    font-size: 1rem;
    color: var(--gray-600);
    margin-bottom: 0.5rem;
}

.stat-number {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-subtitle {
    color: var(--gray-500);
    font-size: 0.85rem;
}

/* Actions */

.actions-container {
    margin: 2rem 0;
}

.actions-container h2 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    color: var(--gray-800);
}

.actions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.action-card {
    background: white;
    padding: 2rem;
    border-radius: 1rem;
    box-shadow: var(--shadow-md);
    text-decoration: none;
    color: inherit;
    border: 2px solid transparent;
    transition: all 0.3s;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    position: relative;
    overflow: hidden;
}

.action-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--primary);
}

.action-card.action-secondary::before {
    background: var(--secondary);
}

.action-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary);
}

.action-icon {
    font-size: 2.5rem;
}

.action-card h3 {
    font-size: 1.25rem;
    color: var(--gray-800);
}

.action-card p {
    color: var(--gray-500);
    font-size: 0.9rem;
}

.action-count {
    background: var(--primary-light);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 9999px;
    display: inline-block;
    font-size: 0.85rem;
    font-weight: 600;
    width: fit-content;
    margin-top: auto;
}

.action-button {
    color: var(--primary);
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

/* Details Section */

.details-section {
    background: white;
    padding: 2rem;
    border-radius: 1rem;
    box-shadow: var(--shadow-md);
}

.details-section h2 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    color: var(--gray-800);
}

.tabs {
    display: flex;
    flex-direction: column;
}

.tab-buttons {
    display: flex;
    gap: 1rem;
    border-bottom: 2px solid var(--gray-200);
    margin-bottom: 2rem;
}

.tab-btn {
    background: none;
    border: none;
    padding: 1rem;
    cursor: pointer;
    color: var(--gray-500);
    font-weight: 600;
    border-bottom: 3px solid transparent;
    transition: all 0.2s;
}

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tab-btn:hover {
    color: var(--primary);
}

.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
}

.progress-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
}

.progress-item {
    background: var(--gray-50);
    padding: 1.5rem;
    border-radius: 0.75rem;
}

.progress-label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.75rem;
    font-weight: 600;
    color: var(--gray-700);
    font-size: 0.9rem;
}

.progress-value {
    color: var(--primary);
    font-weight: 700;
}

.progress-bar {
    height: 8px;
    background: var(--gray-200);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    transition: width 0.3s ease;
    border-radius: 4px;
}

.progress-fill.pending {
    background: var(--gray-400);
}

.progress-fill.success {
    background: var(--success);
}

.progress-fill.info {
    background: var(--info);
}

.progress-fill.danger {
    background: var(--danger);
}

/* Export Section */

.export-section {
    background: white;
    padding: 2rem;
    border-radius: 1rem;
    box-shadow: var(--shadow-md);
}

.export-section h2 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    color: var(--gray-800);
}

.export-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}

/* ============================================================================
   EMAILS PAGE
   ============================================================================ */

.emails-container {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.emails-header {
    text-align: left;
}

.emails-header h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    color: var(--gray-800);
}

.emails-header p {
    color: var(--gray-500);
}

.controls-bar {
    background: white;
    padding: 1.5rem;
    border-radius: 1rem;
    box-shadow: var(--shadow-md);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.filter-group label {
    font-weight: 600;
    color: var(--gray-700);
    font-size: 0.9rem;
}

.filter-btn {
    background: var(--gray-200);
    border: 2px solid transparent;
    padding: 0.5rem 1rem;
    border-radius: 9999px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.filter-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.filter-btn:hover {
    border-color: var(--primary);
}

.count {
    font-weight: 700;
    font-size: 0.85rem;
    background: rgba(255, 255, 255, 0.2);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

.action-group {
    display: flex;
    gap: 1rem;
}

.emails-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.email-item {
    background: white;
    padding: 1.5rem;
    border-radius: 0.75rem;
    box-shadow: var(--shadow-sm);
    border-left: 4px solid var(--gray-300);
    cursor: pointer;
    transition: all 0.2s;
}

.email-item:hover {
    box-shadow: var(--shadow-md);
    transform: translateX(4px);
}

.email-item-status-ok {
    border-left-color: var(--success);
    background: rgba(16, 185, 129, 0.05);
}

.email-item-status-transmettre {
    border-left-color: var(--info);
    background: rgba(59, 130, 246, 0.05);
}

.email-item-status-non-ok {
    border-left-color: var(--danger);
    background: rgba(239, 68, 68, 0.05);
}

.email-item-header {
    margin-bottom: 0.75rem;
}

.email-item-subject {
    font-weight: 600;
    color: var(--gray-800);
    font-size: 1.05rem;
}

.email-item-from {
    color: var(--gray-500);
    font-size: 0.9rem;
    margin-top: 0.25rem;
}

.email-item-meta {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
    align-items: center;
}

.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.8rem;
    font-weight: 600;
}

.badge-id {
    background: var(--gray-200);
    color: var(--gray-700);
}

.badge-status {
    background: var(--primary-light);
    color: white;
}

.email-item-date {
    color: var(--gray-500);
    font-size: 0.85rem;
    margin-left: auto;
}

.email-item-context {
    color: var(--gray-600);
    font-size: 0.9rem;
    font-style: italic;
    opacity: 0.85;
}

.loading,
.empty-state,
.error {
    text-align: center;
    padding: 3rem;
    color: var(--gray-500);
    font-size: 1.1rem;
}

.error {
    color: var(--danger);
}

/* Pagination */

.pagination {
    text-align: center;
    margin-top: 2rem;
}

.pagination-buttons {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    flex-wrap: wrap;
}

.pagination-buttons button {
    padding: 0.5rem 1rem;
    border: 1px solid var(--gray-300);
    background: white;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: all 0.2s;
}

.pagination-buttons button:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.pagination-buttons button.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* ============================================================================
   MODAL
   ============================================================================ */

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: white;
    padding: 2rem;
    border-radius: 1rem;
    box-shadow: var(--shadow-xl);
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    width: 90%;
}

.modal-large {
    max-width: 800px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--gray-200);
    padding-bottom: 1rem;
}

.modal-header h2 {
    font-size: 1.5rem;
    color: var(--gray-800);
}

.modal-close {
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: var(--gray-500);
    transition: color 0.2s;
}

.modal-close:hover {
    color: var(--gray-800);
}

.modal-body {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.email-details {
    background: var(--gray-50);
    padding: 1.5rem;
    border-radius: 0.75rem;
}

.detail-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.detail-row:last-child {
    margin-bottom: 0;
}

.detail-label {
    font-weight: 600;
    color: var(--gray-700);
    min-width: 100px;
}

.detail-value {
    color: var(--gray-600);
    word-break: break-all;
}

.email-body {
    margin: 1rem 0;
}

.email-body h3 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    color: var(--gray-800);
}

.email-content {
    background: var(--gray-50);
    padding: 1rem;
    border-radius: 0.375rem;
    font-family: monospace;
    white-space: pre-wrap;
    word-wrap: break-word;
    font-size: 0.85rem;
    max-height: 300px;
    overflow-y: auto;
}

.email-actions {
    margin-top: 1rem;
}

.email-actions h3 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    color: var(--gray-800);
}

.decision-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.decision-buttons button {
    padding: 0.75rem;
    width: 100%;
    text-align: left;
}

.notes-section {
    margin-top: 1.5rem;
}

.notes-section label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--gray-700);
}

.notes-section textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--gray-300);
    border-radius: 0.375rem;
    font-family: inherit;
    resize: vertical;
    min-height: 80px;
}

/* ============================================================================
   RESPONSIVE
   ============================================================================ */

@media (max-width: 768px) {
    .main-content {
        margin: 1rem auto;
        padding: 0 1rem;
    }
    
    .navbar-container {
        padding: 0 1rem;
        flex-direction: column;
        gap: 1rem;
    }
    
    .navbar-title {
        font-size: 1.2rem;
    }
    
    .dashboard-header h1 {
        font-size: 1.75rem;
    }
    
    .login-card {
        padding: 2rem;
    }
    
    .controls-bar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .filter-group {
        flex-direction: column;
    }
    
    .action-group {
        flex-direction: column;
    }
    
    .action-group button {
        width: 100%;
    }
    
    .modal-content {
        width: 95%;
        padding: 1.5rem;
    }
}
