/* PayLink CRM — Composants UI */

/* ========== Cards ========== */
.card {
    background: #FFFFFF;
    border: 1px solid #E5E7EB;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.card-body {
    padding: 24px;
}

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

.card-header h2, .card-header h3 {
    margin: 0;
}

.card-footer {
    padding: 16px 24px;
    border-top: 1px solid #E5E7EB;
    background: #F9FAFB;
    border-radius: 0 0 12px 12px;
}

/* ========== Boutons ========== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s ease;
    border: none;
    text-decoration: none;
    line-height: 1;
    white-space: nowrap;
}

.btn svg {
    width: 16px;
    height: 16px;
}

.btn-primary {
    background: #2563EB;
    color: white;
}
.btn-primary:hover {
    background: #1D4ED8;
    color: white;
}

.btn-secondary {
    background: white;
    border: 1px solid #D1D5DB;
    color: #374151;
}
.btn-secondary:hover {
    background: #F9FAFB;
    border-color: #9CA3AF;
}

.btn-danger {
    background: #DC2626;
    color: white;
}
.btn-danger:hover {
    background: #B91C1C;
    color: white;
}

.btn-success {
    background: #059669;
    color: white;
}
.btn-success:hover {
    background: #047857;
    color: white;
}

.btn-ghost {
    background: transparent;
    color: #6B7280;
    padding: 8px;
}
.btn-ghost:hover {
    background: #F3F4F6;
    color: #111827;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-lg {
    padding: 12px 24px;
    font-size: 16px;
}

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

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

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

.form-label .required {
    color: #DC2626;
    margin-left: 2px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #D1D5DB;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    color: #111827;
    background: #FFFFFF;
    transition: all 0.15s ease;
    outline: none;
}

.form-control:focus {
    border-color: #2563EB;
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

.form-control::placeholder {
    color: #9CA3AF;
}

.form-control.error {
    border-color: #DC2626;
}

.form-control.error:focus {
    box-shadow: 0 0 0 3px rgba(220,38,38,0.1);
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236B7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 38px;
}

textarea.form-control {
    resize: vertical;
    min-height: 80px;
}

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

.form-error {
    font-size: 12px;
    color: #DC2626;
    margin-top: 4px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

@media (max-width: 640px) {
    .form-row {
        grid-template-columns: 1fr;
    }
}

/* ========== Tables ========== */
.table-wrapper {
    overflow-x: auto;
}

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

table thead th {
    background: #F9FAFB;
    padding: 12px 16px;
    font-size: 13px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6B7280;
    text-align: left;
    border-bottom: 1px solid #E5E7EB;
    white-space: nowrap;
}

table tbody td {
    padding: 14px 16px;
    font-size: 14px;
    border-bottom: 1px solid #F3F4F6;
    color: #374151;
}

table tbody tr:hover {
    background: #F9FAFB;
}

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

.table-actions {
    display: flex;
    gap: 4px;
    align-items: center;
}

/* ========== Badges ========== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 500;
    line-height: 1;
    white-space: nowrap;
}

.badge-success {
    background: #ECFDF5;
    color: #059669;
}

.badge-warning {
    background: #FFFBEB;
    color: #D97706;
}

.badge-danger {
    background: #FEF2F2;
    color: #DC2626;
}

.badge-info {
    background: #EFF6FF;
    color: #2563EB;
}

.badge-gray {
    background: #F3F4F6;
    color: #6B7280;
}

/* ========== Pagination ========== */
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 0;
    flex-wrap: wrap;
    gap: 12px;
}

.pagination-info {
    font-size: 14px;
    color: #6B7280;
}

.pagination-links {
    display: flex;
    gap: 4px;
}

.pagination-links a,
.pagination-links span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: #374151;
    border: 1px solid #E5E7EB;
    transition: all 0.15s ease;
}

.pagination-links a:hover {
    background: #F3F4F6;
    border-color: #D1D5DB;
}

.pagination-links .active {
    background: #2563EB;
    color: white;
    border-color: #2563EB;
}

.pagination-links .disabled {
    opacity: 0.4;
    pointer-events: none;
}

/* ========== Toasts ========== */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    border-radius: 10px;
    background: white;
    border: 1px solid #E5E7EB;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    font-size: 14px;
    min-width: 300px;
    max-width: 450px;
    animation: toastSlideIn 0.3s ease;
}

.toast.removing {
    animation: toastSlideOut 0.3s ease forwards;
}

.toast-success { border-left: 4px solid #059669; }
.toast-error { border-left: 4px solid #DC2626; }
.toast-warning { border-left: 4px solid #D97706; }
.toast-info { border-left: 4px solid #2563EB; }

.toast-close {
    margin-left: auto;
    background: none;
    border: none;
    color: #9CA3AF;
    cursor: pointer;
    padding: 4px;
    font-size: 18px;
    line-height: 1;
}
.toast-close:hover {
    color: #6B7280;
}

@keyframes toastSlideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes toastSlideOut {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

/* ========== Modals ========== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay.show {
    display: flex;
}

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

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

.modal-header h3 {
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    color: #9CA3AF;
    cursor: pointer;
    padding: 4px;
    font-size: 20px;
    line-height: 1;
}
.modal-close:hover {
    color: #6B7280;
}

.modal-body {
    padding: 24px;
}

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

/* ========== KPI Cards ========== */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 32px;
}

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

.kpi-card {
    background: white;
    border: 1px solid #E5E7EB;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.kpi-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.kpi-card-label {
    font-size: 13px;
    font-weight: 500;
    color: #6B7280;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.kpi-card-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.kpi-card-icon.blue { background: #EFF6FF; color: #2563EB; }
.kpi-card-icon.green { background: #ECFDF5; color: #059669; }
.kpi-card-icon.amber { background: #FFFBEB; color: #D97706; }
.kpi-card-icon.red { background: #FEF2F2; color: #DC2626; }

.kpi-card-value {
    font-size: 28px;
    font-weight: 700;
    color: #111827;
    margin-bottom: 4px;
}

.kpi-card-change {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    font-weight: 500;
}

.kpi-card-change.up { color: #059669; }
.kpi-card-change.down { color: #DC2626; }
.kpi-card-change.neutral { color: #6B7280; }

/* ========== Toggle Switch ========== */
.toggle {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: #D1D5DB;
    border-radius: 12px;
    transition: 0.2s;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: white;
    top: 3px;
    left: 3px;
    transition: 0.2s;
}

.toggle input:checked + .toggle-slider {
    background: #2563EB;
}

.toggle input:checked + .toggle-slider::before {
    transform: translateX(20px);
}

/* ========== Empty State ========== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
}

.empty-state svg {
    width: 80px;
    height: 80px;
    color: #D1D5DB;
    margin-bottom: 16px;
}

.empty-state h3 {
    font-size: 16px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 14px;
    color: #6B7280;
    margin-bottom: 20px;
}

/* ========== Grid Layouts ========== */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }

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

/* ========== Misc ========== */
.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }

.copy-field {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #F9FAFB;
    border: 1px solid #E5E7EB;
    border-radius: 8px;
    padding: 8px 12px;
}

.copy-field input {
    flex: 1;
    border: none;
    background: none;
    font-size: 13px;
    color: #374151;
    font-family: 'Courier New', monospace;
    outline: none;
}

.copy-field button {
    background: none;
    border: none;
    color: #2563EB;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
}
.copy-field button:hover {
    color: #1D4ED8;
}

/* ========== Processor Cards (sélection) ========== */
.processor-selector {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
}

.processor-card {
    border: 2px solid #E5E7EB;
    border-radius: 12px;
    padding: 16px;
    text-align: center;
    cursor: pointer;
    transition: all 0.15s ease;
    background: white;
}

.processor-card:hover {
    border-color: #93C5FD;
    background: #F8FAFF;
}

.processor-card.selected {
    border-color: #2563EB;
    background: #EFF6FF;
}

.processor-card.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.processor-card img {
    width: 40px;
    height: 40px;
    margin-bottom: 8px;
    object-fit: contain;
}

.processor-card .name {
    font-size: 13px;
    font-weight: 500;
    color: #374151;
}

/* ========== Charts container ========== */
.chart-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-bottom: 32px;
}

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

.chart-card {
    background: white;
    border: 1px solid #E5E7EB;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.chart-card h3 {
    font-size: 15px;
    font-weight: 600;
    color: #111827;
    margin-bottom: 16px;
}

.chart-card canvas {
    max-height: 250px;
}

/* ========== Filters Bar ========== */
.filters-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.filters-bar .form-control {
    width: auto;
    min-width: 160px;
}

.search-input {
    position: relative;
}

.search-input input {
    padding-left: 38px;
}

.search-input svg {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: #9CA3AF;
}

/* ========== Login Page ========== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #F9FAFB;
    padding: 20px;
}

.login-card {
    background: white;
    border: 1px solid #E5E7EB;
    border-radius: 16px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.06);
    width: 100%;
    max-width: 420px;
    padding: 40px;
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo-icon {
    width: 56px;
    height: 56px;
    background: #2563EB;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 24px;
    margin-bottom: 16px;
}

.login-logo h1 {
    font-size: 24px;
    font-weight: 700;
    color: #111827;
}

.login-logo p {
    font-size: 14px;
    color: #6B7280;
    margin-top: 4px;
}

.login-form .btn {
    width: 100%;
    padding: 12px;
    font-size: 15px;
    margin-top: 8px;
}

/* ========== Alert box ========== */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.alert-error {
    background: #FEF2F2;
    color: #DC2626;
    border: 1px solid #FECACA;
}

.alert-success {
    background: #ECFDF5;
    color: #059669;
    border: 1px solid #A7F3D0;
}

.alert-warning {
    background: #FFFBEB;
    color: #D97706;
    border: 1px solid #FDE68A;
}

.alert-info {
    background: #EFF6FF;
    color: #2563EB;
    border: 1px solid #BFDBFE;
}

/* ========== Autocomplete ========== */
.autocomplete-wrapper {
    position: relative;
}

.autocomplete-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #E5E7EB;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.08);
    max-height: 250px;
    overflow-y: auto;
    z-index: 100;
    display: none;
}

.autocomplete-results.show {
    display: block;
}

.autocomplete-item {
    padding: 10px 14px;
    cursor: pointer;
    font-size: 14px;
    border-bottom: 1px solid #F3F4F6;
    transition: background 0.1s ease;
}

.autocomplete-item:hover {
    background: #F9FAFB;
}

.autocomplete-item:last-child {
    border-bottom: none;
}

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

.autocomplete-item .detail {
    font-size: 12px;
    color: #6B7280;
}
