/**
 * API KEYS MANAGER CSS
 * Styles pour l'interface de gestion des clés API
 * Version: 1.0.0
 */

/* ====================================================================
   CONTENEUR PRINCIPAL
   ==================================================================== */
.apikeys-container {
    max-width: 1400px;
    margin: 0 auto;
}

/* ====================================================================
   HEADER
   ==================================================================== */
.apikeys-header {
    margin-bottom: 30px;
}

.apikeys-title {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.apikeys-title h1 {
    font-size: 24px;
    font-weight: 600;
    color: #111827;
    margin: 0;
    font-family: var(--font-title, 'Outfit', sans-serif);
}

.apikeys-title svg {
    width: 28px;
    height: 28px;
    color: #009FE3;
}

.apikeys-subtitle {
    font-size: 14px;
    color: #6b7280;
    margin: 0;
}

/* ====================================================================
   STATS CARDS
   ==================================================================== */
.apikeys-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 30px;
}

@media (max-width: 1024px) {
    .apikeys-stats {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 600px) {
    .apikeys-stats {
        grid-template-columns: 1fr;
    }
}

.apikeys-stats .stat-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    border: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: all 0.2s ease;
}

.apikeys-stats .stat-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transform: translateY(-2px);
}

.apikeys-stats .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.apikeys-stats .stat-icon svg {
    width: 24px;
    height: 24px;
}

.apikeys-stats .stat-icon.blue { background: #eff6ff; color: #2563eb; }
.apikeys-stats .stat-icon.green { background: #f0fdf4; color: #16a34a; }
.apikeys-stats .stat-icon.purple { background: #faf5ff; color: #9333ea; }
.apikeys-stats .stat-icon.orange { background: #fff7ed; color: #ea580c; }

.apikeys-stats .stat-info { flex: 1; }

.apikeys-stats .stat-value {
    font-size: 28px;
    font-weight: 700;
    color: #111827;
    line-height: 1;
    margin-bottom: 4px;
    font-family: var(--font-title, 'Outfit', sans-serif);
}

.apikeys-stats .stat-label {
    font-size: 13px;
    color: #6b7280;
}

/* ====================================================================
   TOOLBAR
   ==================================================================== */
.apikeys-toolbar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 20px;
}

.apikeys-btn-create {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: #009FE3;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: var(--font-body, 'Zalando Sans', sans-serif);
}

.apikeys-btn-create:hover {
    background: #0088c7;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 159, 227, 0.3);
}

.apikeys-btn-create svg {
    width: 18px;
    height: 18px;
}

/* ====================================================================
   TABLE DES CLÉS
   ==================================================================== */
.apikeys-table-wrapper {
    background: white;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    overflow: hidden;
}

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

.apikeys-table thead th {
    text-align: left;
    padding: 14px 16px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6b7280;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
}

.apikeys-table tbody td {
    padding: 14px 16px;
    font-size: 14px;
    color: #374151;
    border-bottom: 1px solid #f3f4f6;
    vertical-align: middle;
}

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

.apikeys-table tbody tr:hover {
    background: #f9fafb;
}

.apikeys-key-prefix {
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Mono', monospace;
    font-size: 13px;
    color: #6b7280;
    background: #f3f4f6;
    padding: 2px 8px;
    border-radius: 4px;
}

.apikeys-name {
    font-weight: 500;
    color: #111827;
}

/* ====================================================================
   SCOPE BADGES
   ==================================================================== */
.apikeys-scopes {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.apikeys-scope-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 500;
    border-radius: 9999px;
    white-space: nowrap;
}

.apikeys-scope-badge.read { background: #dbeafe; color: #1d4ed8; }
.apikeys-scope-badge.write { background: #fef3c7; color: #92400e; }

/* ====================================================================
   STATUS BADGES
   ==================================================================== */
.apikeys-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 500;
}

.apikeys-status.active {
    background: #f0fdf4;
    color: #15803d;
}

.apikeys-status.revoked {
    background: #fef2f2;
    color: #b91c1c;
}

.apikeys-status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.apikeys-status.active .apikeys-status-dot { background: #22c55e; }
.apikeys-status.revoked .apikeys-status-dot { background: #ef4444; }

/* ====================================================================
   ACTIONS
   ==================================================================== */
.apikeys-actions {
    display: flex;
    gap: 8px;
}

.apikeys-btn-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    background: white;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.15s ease;
}

.apikeys-btn-action:hover {
    background: #f3f4f6;
    color: #111827;
}

.apikeys-btn-action.danger:hover {
    background: #fef2f2;
    color: #dc2626;
    border-color: #fecaca;
}

.apikeys-btn-action svg {
    width: 16px;
    height: 16px;
}

/* ====================================================================
   MODAL
   ==================================================================== */
.apikeys-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    animation: apikeys-fadeIn 0.2s ease forwards;
}

@keyframes apikeys-fadeIn {
    to { opacity: 1; }
}

.apikeys-modal {
    background: white;
    border-radius: 16px;
    width: 90%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}

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

.apikeys-modal-header h2 {
    font-size: 18px;
    font-weight: 600;
    color: #111827;
    margin: 0;
    font-family: var(--font-title, 'Outfit', sans-serif);
}

.apikeys-modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: none;
    color: #6b7280;
    cursor: pointer;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.apikeys-modal-close:hover {
    background: #f3f4f6;
    color: #111827;
}

.apikeys-modal-body {
    padding: 24px;
}

.apikeys-modal-footer {
    padding: 16px 24px;
    border-top: 1px solid #e5e7eb;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* ====================================================================
   FORM
   ==================================================================== */
.apikeys-form-group {
    margin-bottom: 20px;
}

.apikeys-form-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: #374151;
    margin-bottom: 6px;
}

.apikeys-form-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    color: #111827;
    transition: border-color 0.15s ease;
    box-sizing: border-box;
    font-family: var(--font-body, 'Zalando Sans', sans-serif);
}

.apikeys-form-input:focus {
    outline: none;
    border-color: #009FE3;
    box-shadow: 0 0 0 3px rgba(0, 159, 227, 0.1);
}

.apikeys-form-hint {
    font-size: 12px;
    color: #9ca3af;
    margin-top: 4px;
}

/* Scopes checkboxes */
.apikeys-scopes-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.apikeys-scope-check {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
    font-size: 13px;
    color: #374151;
}

.apikeys-scope-check:hover {
    border-color: #009FE3;
    background: #f0f9ff;
}

.apikeys-scope-check.selected {
    border-color: #009FE3;
    background: #eff6ff;
    color: #1d4ed8;
}

.apikeys-scope-check input[type="checkbox"] {
    accent-color: #009FE3;
}

/* ====================================================================
   KEY DISPLAY (affichage unique)
   ==================================================================== */
.apikeys-key-display {
    background: #111827;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
}

.apikeys-key-value {
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Mono', monospace;
    font-size: 13px;
    color: #10b981;
    word-break: break-all;
    line-height: 1.6;
    user-select: all;
}

.apikeys-key-warning {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 16px;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 8px;
    margin-bottom: 16px;
}

.apikeys-key-warning svg {
    width: 20px;
    height: 20px;
    color: #d97706;
    flex-shrink: 0;
    margin-top: 1px;
}

.apikeys-key-warning p {
    font-size: 13px;
    color: #92400e;
    margin: 0;
    line-height: 1.5;
}

.apikeys-btn-copy {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: #10b981;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: var(--font-body, 'Zalando Sans', sans-serif);
}

.apikeys-btn-copy:hover {
    background: #059669;
}

.apikeys-btn-copy svg {
    width: 16px;
    height: 16px;
}

/* ====================================================================
   BOUTONS MODAL
   ==================================================================== */
.apikeys-btn-cancel {
    padding: 8px 16px;
    background: white;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    color: #374151;
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: var(--font-body, 'Zalando Sans', sans-serif);
}

.apikeys-btn-cancel:hover {
    background: #f3f4f6;
}

.apikeys-btn-submit {
    padding: 8px 20px;
    background: #009FE3;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: var(--font-body, 'Zalando Sans', sans-serif);
}

.apikeys-btn-submit:hover {
    background: #0088c7;
}

.apikeys-btn-submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ====================================================================
   EMPTY STATE
   ==================================================================== */
.apikeys-empty {
    text-align: center;
    padding: 60px 20px;
}

.apikeys-empty svg {
    width: 48px;
    height: 48px;
    color: #d1d5db;
    margin-bottom: 16px;
}

.apikeys-empty h3 {
    font-size: 16px;
    font-weight: 600;
    color: #374151;
    margin: 0 0 8px 0;
    font-family: var(--font-title, 'Outfit', sans-serif);
}

.apikeys-empty p {
    font-size: 14px;
    color: #6b7280;
    margin: 0;
}

/* ====================================================================
   LOADING
   ==================================================================== */
.apikeys-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: #6b7280;
}

.apikeys-loading svg {
    width: 32px;
    height: 32px;
    animation: spin 1s linear infinite;
    margin-bottom: 12px;
}

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

/* ====================================================================
   USAGE INFO
   ==================================================================== */
.apikeys-usage {
    font-size: 12px;
    color: #9ca3af;
}

.apikeys-usage strong {
    color: #374151;
    font-weight: 600;
}

/* ====================================================================
   RESPONSIVE
   ==================================================================== */
@media (max-width: 768px) {
    .apikeys-table thead {
        display: none;
    }

    .apikeys-table tbody td {
        display: block;
        padding: 8px 16px;
        text-align: right;
    }

    .apikeys-table tbody td::before {
        content: attr(data-label);
        float: left;
        font-weight: 600;
        font-size: 12px;
        text-transform: uppercase;
        color: #6b7280;
    }

    .apikeys-table tbody tr {
        border-bottom: 2px solid #e5e7eb;
        padding: 8px 0;
    }

    .apikeys-scopes-grid {
        grid-template-columns: 1fr;
    }
}
