/* ================================================
   ELYVIA AGENCY PAGES - ENTERPRISE DESIGN SYSTEM
   Partagé par toutes les pages /agency/*
   ================================================ */

/* ---- PAGE WRAPPER ---- */
.ap-page {
    max-width: 1600px;
    margin: 0 auto;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ---- PAGE HEADER ---- */
.ap-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.75rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid #e2e8f0;
}

.ap-header-left {}

.ap-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #0f172a;
    margin: 0 0 0.2rem 0;
    letter-spacing: -0.02em;
}

.ap-subtitle {
    font-size: 0.875rem;
    color: #64748b;
    margin: 0;
    font-weight: 400;
}

.ap-header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* ---- BOUTONS ---- */
.ap-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    padding: 0.5rem 1.125rem;
    border: none;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.18s ease;
    text-decoration: none;
    white-space: nowrap;
    font-family: inherit;
}

.ap-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

.ap-btn-primary {
    background: #4f46e5;
    color: white;
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.3);
}

.ap-btn-primary:hover:not(:disabled) {
    background: #4338ca;
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(79, 70, 229, 0.4);
}

.ap-btn-secondary {
    background: white;
    color: #475569;
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.ap-btn-secondary:hover:not(:disabled) {
    background: #f8fafc;
    border-color: #cbd5e1;
    color: #1e293b;
}

.ap-btn-danger {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
}

.ap-btn-danger:hover:not(:disabled) {
    background: #fee2e2;
    border-color: #fca5a5;
}

.ap-btn-sm {
    padding: 0.3rem 0.7rem;
    font-size: 0.8125rem;
    border-radius: 6px;
}

.ap-btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: 7px;
    font-size: 0.9rem;
}

/* ---- FILTER / SEARCH ---- */
.ap-input {
    padding: 0.5rem 0.875rem;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 0.875rem;
    font-family: inherit;
    background: white;
    color: #1e293b;
    transition: all 0.15s ease;
    min-width: 200px;
}

.ap-input:focus {
    outline: none;
    border-color: #4f46e5;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.ap-select {
    padding: 0.5rem 0.875rem;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 0.875rem;
    font-family: inherit;
    background: white;
    color: #475569;
    cursor: pointer;
}

/* ---- TABLE ---- */
.ap-table-wrap {
    background: white;
    border-radius: 12px;
    border: 1px solid #f1f5f9;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    overflow: hidden;
}

.ap-table {
    width: 100%;
    border-collapse: collapse;
}

.ap-table thead {
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}

.ap-table th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.ap-table td {
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    color: #334155;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}

.ap-table tbody tr:last-child td {
    border-bottom: none;
}

.ap-table tbody tr {
    transition: background 0.12s ease;
}

.ap-table tbody tr:hover {
    background: #fafbfc;
}

/* Thumb image dans table */
.ap-thumb {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    background-size: cover;
    background-position: center;
    background-color: #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}

/* ---- BADGES ---- */
.ap-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.625rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.ap-badge-green  { background: #dcfce7; color: #15803d; }
.ap-badge-amber  { background: #fef3c7; color: #b45309; }
.ap-badge-blue   { background: #dbeafe; color: #1d4ed8; }
.ap-badge-indigo { background: #e0e7ff; color: #3730a3; }
.ap-badge-red    { background: #fee2e2; color: #b91c1c; }
.ap-badge-slate  { background: #f1f5f9; color: #475569; }
.ap-badge-cyan   { background: #cffafe; color: #0e7490; }
.ap-badge-violet { background: #f3e8ff; color: #6d28d9; }

/* ---- AVATAR ---- */
.ap-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4f46e5, #06b6d4);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.8125rem;
    font-weight: 700;
    flex-shrink: 0;
    text-transform: uppercase;
}

/* ---- ACTIONS GROUPE ---- */
.ap-actions {
    display: flex;
    gap: 0.35rem;
    align-items: center;
}

/* ---- EMPTY STATE ---- */
.ap-empty {
    text-align: center;
    padding: 4rem 2rem;
    background: white;
    border-radius: 12px;
    border: 1px solid #f1f5f9;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.ap-empty-icon {
    font-size: 3rem;
    opacity: 0.35;
    margin-bottom: 1rem;
}

.ap-empty h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: #1e293b;
    margin: 0 0 0.5rem 0;
}

.ap-empty p {
    color: #64748b;
    font-size: 0.9rem;
    margin: 0 0 1.5rem 0;
}

/* ---- LOADING ---- */
.ap-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.875rem;
    padding: 4rem;
    color: #64748b;
    font-size: 0.9rem;
}

.ap-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid #e2e8f0;
    border-top: 3px solid #4f46e5;
    border-radius: 50%;
    animation: ap-spin 0.75s linear infinite;
}

@keyframes ap-spin { to { transform: rotate(360deg); } }

/* ---- PIED DE TABLE ---- */
.ap-table-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.875rem 1rem;
    border-top: 1px solid #f1f5f9;
    font-size: 0.8125rem;
    color: #94a3b8;
    background: #fafbfc;
}

.ap-table-footer strong {
    color: #475569;
}

/* ---- MODAL ---- */
.ap-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1200;
    backdrop-filter: blur(2px);
    padding: 1rem;
}

.ap-modal {
    background: white;
    border-radius: 16px;
    width: 100%;
    max-width: 560px;
    max-height: 92vh;
    overflow-y: auto;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.2);
}

.ap-modal-lg {
    max-width: 720px;
}

.ap-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.375rem 1.5rem;
    border-bottom: 1px solid #f1f5f9;
}

.ap-modal-title {
    font-size: 1.0625rem;
    font-weight: 700;
    color: #0f172a;
    margin: 0;
}

.ap-modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: #f1f5f9;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.1rem;
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.ap-modal-close:hover {
    background: #e2e8f0;
    color: #1e293b;
}

.ap-modal-body {
    padding: 1.5rem;
}

.ap-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1.25rem 1.5rem;
    border-top: 1px solid #f1f5f9;
    background: #fafbfc;
    border-radius: 0 0 16px 16px;
}

/* ---- FORMULAIRE (modal) ---- */
.ap-form-group {
    margin-bottom: 1.25rem;
}

.ap-form-group:last-child {
    margin-bottom: 0;
}

.ap-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.4rem;
}

.ap-field {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 0.875rem;
    font-family: inherit;
    color: #1e293b;
    transition: all 0.15s ease;
    box-sizing: border-box;
    background: white;
}

.ap-field:focus {
    outline: none;
    border-color: #4f46e5;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

textarea.ap-field {
    resize: vertical;
    min-height: 90px;
}

.ap-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

@media (max-width: 560px) {
    .ap-form-row { grid-template-columns: 1fr; }
}

/* ---- ALERTES ---- */
.ap-alert {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.875rem;
    margin-top: 1rem;
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

.ap-alert-error {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

.ap-alert-success {
    background: #f0fdf4;
    color: #15803d;
    border: 1px solid #bbf7d0;
}

/* ---- SPINNER INLINE ---- */
.ap-spin-sm {
    width: 14px;
    height: 14px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: ap-spin 0.75s linear infinite;
    display: inline-block;
    flex-shrink: 0;
}

/* ---- SETTINGS LAYOUT ---- */
.ap-settings-grid {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.ap-settings-card {
    background: white;
    border-radius: 12px;
    border: 1px solid #f1f5f9;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    overflow: hidden;
}

.ap-settings-card-header {
    padding: 1.125rem 1.5rem;
    border-bottom: 1px solid #f1f5f9;
    background: #fafbfc;
}

.ap-settings-card-title {
    font-size: 0.9375rem;
    font-weight: 700;
    color: #1e293b;
    margin: 0;
}

.ap-settings-card-body {
    padding: 1.5rem;
}

.ap-setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.875rem 0;
    border-bottom: 1px solid #f8fafc;
}

.ap-setting-row:last-child {
    border-bottom: none;
}

.ap-setting-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: #64748b;
}

.ap-setting-value {
    font-size: 0.875rem;
    font-weight: 600;
    color: #1e293b;
}

.ap-color-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.ap-color-row .ap-field {
    font-family: monospace;
    flex: 1;
    min-width: 0;
}

.ap-color-picker {
    width: 52px;
    height: 38px;
    padding: 0;
    border: 1px solid #e2e8f0;
    border-radius: 7px;
    cursor: pointer;
    flex-shrink: 0;
}

.ap-color-dot {
    width: 38px;
    height: 38px;
    border-radius: 7px;
    border: 1px solid rgba(0,0,0,0.08);
    flex-shrink: 0;
}

.ap-form-hint {
    display: block;
    font-size: 0.8125rem;
    color: #94a3b8;
    margin-top: 0.375rem;
}

.ap-branding-preview {
    border-radius: 10px;
    padding: 2rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    min-height: 90px;
}

.ap-branding-preview img {
    max-height: 50px;
    max-width: 130px;
    object-fit: contain;
    border-radius: 4px;
}

.ap-branding-preview span {
    color: white;
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.ap-logo-preview {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.875rem 1rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    margin-bottom: 0.75rem;
}

.ap-logo-preview img {
    max-height: 60px;
    max-width: 160px;
    object-fit: contain;
}

/* ---- INVITATIONS ---- */
.ap-inv-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

@media (max-width: 900px) {
    .ap-inv-grid { grid-template-columns: repeat(2, 1fr); }
}

.ap-inv-stat {
    background: white;
    border-radius: 12px;
    border: 1px solid #f1f5f9;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.ap-inv-stat-icon {
    width: 40px;
    height: 40px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.ap-inv-stat-val {
    font-size: 1.625rem;
    font-weight: 800;
    color: #0f172a;
    line-height: 1;
    letter-spacing: -0.03em;
}

.ap-inv-stat-lbl {
    font-size: 0.8125rem;
    font-weight: 500;
    color: #64748b;
    margin-top: 0.2rem;
}

.ap-inv-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.ap-inv-card {
    background: white;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    overflow: hidden;
    transition: box-shadow 0.15s ease;
}

.ap-inv-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.07);
}

.ap-inv-card-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #f1f5f9;
}

.ap-inv-card-name {
    font-size: 0.9375rem;
    font-weight: 600;
    color: #0f172a;
    margin: 0 0 0.25rem 0;
}

.ap-inv-card-user {
    font-size: 0.8125rem;
    color: #64748b;
    margin: 0;
}

.ap-inv-card-body {
    padding: 0.875rem 1.25rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.5rem;
}

.ap-inv-info {
    font-size: 0.8125rem;
    color: #64748b;
}

.ap-inv-info strong {
    color: #374151;
    font-weight: 600;
    margin-right: 0.3rem;
}

/* ---- CHECKBOX CLIENT ---- */
.ap-client-check {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.75rem 1rem;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.ap-client-check:hover {
    border-color: #a5b4fc;
    background: #fafbff;
}

.ap-client-check input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #4f46e5;
}

.ap-client-check-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
}

.ap-client-check-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: #1e293b;
}

.ap-client-check-email {
    font-size: 0.8125rem;
    color: #64748b;
}

/* ---- IMAGE PREVIEW ---- */
.ap-img-preview {
    position: relative;
    display: inline-block;
    margin-top: 0.5rem;
}

.ap-img-preview img {
    max-width: 180px;
    max-height: 130px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    display: block;
}

.ap-img-remove {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #dc2626;
    color: white;
    border: none;
    cursor: pointer;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ---- RESPONSIVE ---- */
@media (max-width: 768px) {
    .ap-header { flex-direction: column; align-items: flex-start; }
    .ap-table th:nth-child(3),
    .ap-table td:nth-child(3) { display: none; }
}
