/* CONFIGURATION GLOBALE */
:root {
    --bg-app: #08090d;
    --bg-card: rgba(18, 20, 29, 0.65);
    --bg-card-solid: #11141e;
    --border-color: rgba(255, 255, 255, 0.07);
    --text-main: #f3f4f6;
    --text-muted: #8e98a8;
    
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --primary-glow: rgba(59, 130, 246, 0.3);
    
    --success: #10b981;
    --success-glow: rgba(16, 185, 129, 0.15);
    
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --danger-glow: rgba(239, 68, 68, 0.15);
    
    --security: #f59e0b;
    --security-glow: rgba(245, 158, 11, 0.15);
    
    --transition-speed: 0.2s;
}

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

body {
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-app);
    color: var(--text-main);
    line-height: 1.5;
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(59, 130, 246, 0.05) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(16, 185, 129, 0.03) 0%, transparent 40%);
    background-attachment: fixed;
    min-height: 100vh;
    padding-bottom: 3rem;
}

/* CONTAINER PRINCIPAL */
.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem;
}

/* HEADER */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--border-color);
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--primary), #4f46e5);
    border-radius: 12px;
    color: white;
    box-shadow: 0 4px 12px var(--primary-glow);
}

.logo-text h1 {
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    background: linear-gradient(to right, #ffffff, #d1d5db);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.75rem;
    color: var(--success);
    font-weight: 500;
}

.pulse-dot {
    width: 6px;
    height: 6px;
    background-color: var(--success);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--success);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.env-badge {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    padding: 0.35rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
}

/* ALERT BANNER NOUVELLE CLÉ */
.alert-banner {
    display: flex;
    gap: 1rem;
    background: rgba(245, 158, 11, 0.08);
    border: 1px dashed var(--security);
    border-radius: 16px;
    padding: 1.25rem;
    margin-bottom: 2rem;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.alert-icon {
    color: var(--security);
    flex-shrink: 0;
}

.alert-content h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 0.25rem;
}

.alert-content p {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.key-display-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(0, 0, 0, 0.3);
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    width: fit-content;
}

.key-display-wrapper code {
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.95rem;
    color: #f59e0b;
    font-weight: 600;
}

/* BOUTONS */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: all var(--transition-speed) ease;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
    box-shadow: 0 4px 12px var(--primary-glow);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background-color: rgba(255, 255, 255, 0.08);
}

.btn-copy {
    background: rgba(245, 158, 11, 0.15);
    color: var(--security);
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.btn-copy:hover {
    background: rgba(245, 158, 11, 0.25);
}

.btn-action {
    padding: 0.35rem;
    border-radius: 6px;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
}

.btn-action:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.07);
}

.btn-deactivate:hover {
    color: var(--danger);
    border-color: rgba(239, 68, 68, 0.2);
    background: rgba(239, 68, 68, 0.05);
}

.btn-activate:hover {
    color: var(--success);
    border-color: rgba(16, 185, 129, 0.2);
    background: rgba(16, 185, 129, 0.05);
}

.btn-edit:hover {
    color: var(--primary);
    border-color: rgba(59, 130, 246, 0.2);
    background: rgba(59, 130, 246, 0.05);
}

/* STATS GRID */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.25rem;
    backdrop-filter: blur(10px);
}

.stat-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    border-radius: 12px;
    flex-shrink: 0;
}

.cost-icon { background: rgba(59, 130, 246, 0.1); color: var(--primary); }
.requests-icon { background: rgba(16, 185, 129, 0.1); color: var(--success); }
.latency-icon { background: rgba(139, 92, 246, 0.1); color: #8b5cf6; }
.tokens-icon { background: rgba(236, 72, 153, 0.1); color: #ec4899; }
.security-icon { background: rgba(245, 158, 11, 0.1); color: var(--security); }

.stat-data {
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
}

.stat-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.01em;
}

/* MAIN LAYOUT */
.main-layout {
    display: grid;
    grid-template-columns: 2.2fr 1fr;
    gap: 1.5rem;
}

@media (max-width: 1024px) {
    .main-layout {
        grid-template-columns: 1fr;
    }
}

.layout-main-panel {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* CARTES DASHBOARD */
.dashboard-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    backdrop-filter: blur(10px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.card-header {
    padding: 1.25rem;
    border-bottom: 1px solid var(--border-color);
}

.card-header h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-main);
}

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

.chart-card-wrapper {
    height: 350px;
}

.chart-container {
    padding: 1.25rem;
    position: relative;
    flex-grow: 1;
    min-height: 0; /* Important pour Chart.js dans flexbox */
}

/* TABLEAU DES CLÉS */
.table-responsive {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.85rem;
}

.data-table th, .data-table td {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
}

.data-table th {
    font-weight: 600;
    color: var(--text-muted);
    background-color: rgba(255, 255, 255, 0.01);
}

.key-name-cell {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.key-display-name {
    font-weight: 600;
    color: var(--text-main);
}

.key-hash-preview {
    font-family: monospace;
    color: var(--text-muted);
    font-size: 0.75rem;
}

/* BADGES */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.15rem 0.5rem;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
}

.badge-success { background: var(--success-glow); color: var(--success); }
.badge-danger { background: var(--danger-glow); color: var(--danger); }
.badge-security { background: var(--security-glow); color: var(--security); }

/* PROGRESS BAR */
.budget-usage-wrapper {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-width: 120px;
}

.budget-values {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    font-weight: 600;
}

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

.progress-bar-container {
    width: 100%;
    height: 6px;
    background-color: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s ease;
}

.progress-green { background: linear-gradient(to right, #10b981, #059669); }
.progress-orange { background: linear-gradient(to right, #f59e0b, #d97706); }
.progress-red { background: linear-gradient(to right, #ef4444, #dc2626); }

.action-buttons {
    display: flex;
    gap: 0.35rem;
}

/* LOGS D'AUDIT */
.side-logs-card {
    height: 100%;
    max-height: 700px;
}

.logs-list {
    overflow-y: auto;
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.log-item {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 0.75rem;
    cursor: pointer;
    transition: all var(--transition-speed) ease;
}

.log-item:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.12);
    transform: translateX(2px);
}

.log-error {
    border-left: 3px solid var(--danger);
}

.log-top {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
}

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

.log-model {
    color: var(--text-main);
    font-weight: 600;
}

.log-middle {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 0.35rem;
}

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

.log-cost {
    color: var(--success);
}

.log-bottom {
    display: flex;
    gap: 0.25rem;
}

/* SYSTEME MODAL */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 1000;
}

.modal-active {
    opacity: 1;
    pointer-events: auto;
}

.modal-card {
    background-color: var(--bg-card-solid);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    width: 100%;
    max-width: 480px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    transform: translateY(-20px);
    transition: transform 0.3s ease;
    overflow: hidden;
}

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

.modal-active .modal-card {
    transform: translateY(0);
}

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

.modal-header h2 {
    font-size: 1rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
}

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

.modal-body {
    padding: 1.25rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 1.25rem;
    border-top: 1px solid var(--border-color);
    background-color: rgba(0, 0, 0, 0.15);
}

/* FORMULAIRES */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-bottom: 1rem;
}

.form-group label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
}

.form-group input {
    background-color: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 0.55rem 0.75rem;
    border-radius: 8px;
    font-size: 0.85rem;
    font-family: inherit;
    transition: all var(--transition-speed) ease;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

/* BLOCS D'AUDIT DANS LE MODAL */
.audit-flex {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

@media (max-width: 768px) {
    .audit-flex {
        grid-template-columns: 1fr;
    }
}

.audit-block {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.audit-block h3, .audit-error-wrapper h3 {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
}

.audit-block pre, .audit-error-wrapper pre {
    background: rgba(0,0,0,0.3);
    border: 1px solid var(--border-color);
    padding: 0.75rem;
    border-radius: 8px;
    font-family: monospace;
    font-size: 0.8rem;
    white-space: pre-wrap;
    word-break: break-all;
    height: 250px;
    overflow-y: auto;
    color: #cbd5e1;
}

.audit-error-wrapper {
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.audit-error-wrapper pre {
    height: auto;
    max-height: 120px;
}

/* SYSTEME D'ONGLETS (TABS) */
.tab-navigation {
    display: flex;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    padding: 0.25rem;
    border-radius: 10px;
    margin-left: 2rem;
}

.tab-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all var(--transition-speed) ease;
}

.tab-btn:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.03);
}

.tab-btn.active {
    color: white;
    background: var(--primary);
    box-shadow: 0 2px 8px var(--primary-glow);
}

.tab-pane {
    display: none;
    animation: fadeIn var(--transition-speed) ease-in-out;
}

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

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

/* FORM SELECTS */
.form-select {
    background-color: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 0.55rem 0.75rem;
    border-radius: 8px;
    font-size: 0.85rem;
    font-family: inherit;
    transition: all var(--transition-speed) ease;
    cursor: pointer;
}

.form-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.form-select option {
    background-color: var(--bg-card-solid);
    color: var(--text-main);
}

/* LABELS DE ROUTAGE */
.provider-model-badge {
    display: inline-flex;
    border-radius: 6px;
    overflow: hidden;
    font-size: 0.75rem;
    border: 1px solid var(--border-color);
}

.provider-label {
    background: rgba(255, 255, 255, 0.07);
    color: var(--text-main);
    padding: 0.2rem 0.5rem;
    font-weight: 700;
    text-transform: uppercase;
}

.model-label {
    background: rgba(59, 130, 246, 0.15);
    color: #93c5fd;
    padding: 0.2rem 0.5rem;
    font-weight: 600;
}

.fallback-route-label {
    background: rgba(245, 158, 11, 0.12);
    color: #fcd34d;
    border: 1px solid rgba(245, 158, 11, 0.2);
    padding: 0.2rem 0.5rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* DROPDOWN MENU CONFIGURATION */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 100;
    min-width: 200px;
    padding: 0.5rem 0;
    margin-top: 0.25rem;
    background-color: var(--bg-card-solid);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    animation: fadeIn var(--transition-speed) ease;
}

.dropdown-menu::before {
    content: '';
    position: absolute;
    top: -0.3rem; /* Légèrement plus grand que margin-top pour assurer le chevauchement */
    left: 0;
    right: 0;
    height: 0.35rem;
    background: transparent;
}

.dropdown:hover .dropdown-menu,
.dropdown.show .dropdown-menu {
    display: block;
}

.dropdown:hover .dropdown-arrow,
.dropdown.show .dropdown-arrow {
    transform: rotate(180deg);
}

.dropdown-item {
    display: block;
    width: 100%;
    padding: 0.6rem 1rem;
    font-size: 0.8rem;
    font-weight: 600;
    text-align: left;
    color: var(--text-muted);
    background: none;
    border: none;
    cursor: pointer;
    transition: all var(--transition-speed) ease;
}

.dropdown-item:hover {
    color: var(--text-main);
    background-color: rgba(255, 255, 255, 0.05);
}

.dropdown-item.active {
    color: white;
    background-color: var(--primary);
}

/* BOUTON RELOAD */
.btn-reload {
    background: none;
    border: 1px solid transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.4rem;
    border-radius: 8px;
    transition: all var(--transition-speed);
}

.btn-reload:hover {
    color: var(--text-main);
    background-color: rgba(255, 255, 255, 0.05);
    border-color: var(--border-color);
}

.btn-reload svg {
    transition: transform 0.4s ease;
}

.btn-reload:hover svg {
    transform: rotate(180deg);
}



