/**
 * auth.css — Styles page login AdminAuth plugin.
 *
 * Reprend les variables CSS du CRM principal (--primary, --border, etc.)
 * avec fallbacks pour fonctionner en standalone.
 */

/* ─── Body & Container ─── */

.auth-body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg, #f8f9fa);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    color: var(--text, #1a1a2e);
}

.auth-container {
    width: 100%;
    max-width: 420px;
    padding: 24px;
}

.auth-card {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
    padding: 32px;
    border: 1px solid var(--border, #e5e7eb);
}

/* ─── Logo ─── */

.auth-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 28px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border, #e5e7eb);
}

.auth-logo-img {
    width: 40px;
    height: 40px;
    border-radius: 10px;
}

.auth-logo strong {
    display: block;
    font-size: 15px;
    line-height: 1.2;
}

.auth-logo small {
    font-size: 11px;
    color: var(--muted, #6b7280);
}

/* ─── Tabs ─── */

.auth-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 24px;
    background: var(--bg, #f3f4f6);
    border-radius: 10px;
    padding: 3px;
}

.auth-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 12px;
    border: none;
    background: transparent;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--muted, #6b7280);
    cursor: pointer;
    transition: all 0.15s;
}

.auth-tab.active {
    background: #fff;
    color: var(--text, #1a1a2e);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.auth-tab svg {
    flex-shrink: 0;
}

/* ─── Form fields ─── */

.auth-field {
    margin-bottom: 16px;
}

.auth-field label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted, #6b7280);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.auth-field input,
.auth-field select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border, #d1d5db);
    border-radius: 10px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s;
    box-sizing: border-box;
    font-family: inherit;
}

/* Dans .auth-phone-row, pas de width: 100% — flex gere */
.auth-phone-row .auth-country-select,
.auth-phone-row input[type="tel"] {
    width: auto;
}

.auth-field input:focus,
.auth-field select:focus {
    border-color: var(--primary, #3b82f6);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.auth-field input[inputmode="numeric"] {
    font-size: 24px;
    letter-spacing: 8px;
    text-align: center;
    font-weight: 600;
}

/* ─── Phone row (indicatif + numero, colles) ─── */

.auth-phone-row {
    display: flex;
}

.auth-country-select {
    width: 90px;
    flex-shrink: 0;
    padding: 10px 8px;
    border: 1px solid var(--border, #d1d5db);
    border-right: none;
    border-radius: 10px 0 0 10px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s;
    box-sizing: border-box;
    font-family: inherit;
    background: var(--bg, #f8f9fa);
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%236b7280' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    padding-right: 22px;
}

.auth-country-select:focus {
    border-color: var(--primary, #3b82f6);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    z-index: 1;
    position: relative;
}

.auth-phone-row input[type="tel"] {
    flex: 1;
    min-width: 0;
    border-radius: 0 10px 10px 0;
}

.auth-phone-row input[type="tel"]:focus {
    z-index: 1;
    position: relative;
}

/* ─── Buttons ─── */

.auth-btn {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 10px;
    background: var(--primary, #3b82f6);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s;
    font-family: inherit;
}

.auth-btn:hover:not(:disabled) {
    opacity: 0.9;
}

.auth-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.auth-actions {
    display: flex;
    justify-content: space-between;
    margin-top: 12px;
}

.auth-link {
    background: none;
    border: none;
    color: var(--primary, #3b82f6);
    font-size: 12px;
    cursor: pointer;
    text-decoration: underline;
    padding: 0;
    font-family: inherit;
}

/* ─── Errors & info ─── */

.auth-error {
    padding: 10px 14px;
    background: rgba(239, 68, 68, 0.08);
    color: var(--red, #ef4444);
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 16px;
}

.auth-info {
    font-size: 13px;
    color: var(--muted, #6b7280);
    margin-bottom: 16px;
}

.auth-hint {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 12px;
    font-size: 11px;
    color: var(--muted, #999);
}

/* ─── FIDO2 placeholder ─── */

.auth-fido2-placeholder {
    text-align: center;
    padding: 32px 16px;
    color: var(--muted, #6b7280);
}

.auth-fido2-placeholder p {
    margin: 8px 0 0;
    font-size: 13px;
}

/* ─── Footer ─── */

.auth-footer {
    text-align: center;
    margin-top: 16px;
    font-size: 11px;
    color: var(--muted, #999);
}

/* ─── Users CRUD (admin) ─── */

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.page-header h2 {
    margin: 0;
    font-size: 18px;
}

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

.form-actions {
    margin-top: 24px;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.table th,
.table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border, #e5e7eb);
}

.table th {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--muted, #6b7280);
}

.row-inactive {
    opacity: 0.5;
}

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
}

.badge-admin { background: rgba(239, 68, 68, 0.1); color: #ef4444; }
.badge-manager { background: rgba(59, 130, 246, 0.1); color: #3b82f6; }
.badge-gestionnaire { background: rgba(34, 197, 94, 0.1); color: #16a34a; }

.actions { white-space: nowrap; }
.actions a,
.actions button {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    padding: 2px 4px;
}

.muted { color: var(--muted, #999); }

.btn { padding: 6px 14px; border: 1px solid var(--border, #d1d5db); border-radius: 8px; background: #fff; font-size: 12px; cursor: pointer; text-decoration: none; color: inherit; }
.btn-primary { background: var(--primary, #3b82f6); color: #fff; border-color: transparent; }
.btn-sm { padding: 4px 10px; font-size: 11px; }

/* ─── Sidebar user (quand inclus via element) ─── */

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-user-info {
    flex: 1;
    min-width: 0;
}

.sidebar-user-info strong {
    display: block;
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-info small {
    font-size: 10px;
    color: var(--muted, #999);
}

.sidebar-logout {
    flex-shrink: 0;
    opacity: 0.5;
    transition: opacity 0.15s;
}

.sidebar-logout:hover {
    opacity: 1;
}

/* ─── Responsive ─── */

@media (max-width: 480px) {
    .auth-container { padding: 16px; }
    .auth-card { padding: 24px; }
    .form-grid { grid-template-columns: 1fr; }
}
