/* ═══════════════════════════════════════════
   kdFast - Formulaires
   ═══════════════════════════════════════════ */

/* ── Variables ── */
:root {
    --kf-radius: 8px;
    --kf-border: #d1d5db;
    --kf-border-focus: var(--kdBlue);
    --kf-bg: #fff;
    --kf-bg-disabled: #f3f4f6;
    --kf-text: #1f2937;
    --kf-text-muted: #9ca3af;
    --kf-label: #374151;
    --kf-error: #dc2626;
    --kf-success: #16a34a;
    --kf-gap: 10px;
    --kf-input-height: 40px;
    --kf-font-size: 14px;
}

/* ── Modale formulaire (boxGlobal) ── */
.kf-modal {
    background: var(--kf-bg);
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.15);
    width: 600px;
    max-width: 95vw;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* ── Header modal (style rb-header) ── */
.kf-modal-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px 24px;
    background: linear-gradient(135deg, #2563eb, #1d4ed8, #1e40af);
    color: #fff;
    position: relative;
    overflow: hidden;
    border-radius: 12px 12px 0 0;
}

.kf-modal-header::before {
    content: '';
    position: absolute;
    top: -35px;
    right: -35px;
    width: 130px;
    height: 130px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    pointer-events: none;
}

.kf-modal-header::after {
    content: '';
    position: absolute;
    bottom: -45px;
    left: 28%;
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
    pointer-events: none;
}

.kf-modal-header .kf-modal-icon {
    position: relative;
    z-index: 1;
    flex-shrink: 0;
}

.kf-modal-header .kf-modal-icon i {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 18px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.kf-modal-header .kf-modal-title {
    position: relative;
    z-index: 1;
    flex: 1;
    min-width: 0;
    font-size: 17px;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.kf-modal-header .kf-modal-subtitle {
    font-size: 12px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.65);
    margin-top: 2px;
}

.kf-modal-header .kf-modal-close {
    position: relative;
    z-index: 1;
}

.kf-modal-header .kf-modal-close i {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.75);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-size: 16px;
}

.kf-modal-header .kf-modal-close i:hover {
    background: rgba(255, 255, 255, 0.25);
    color: #fff;
}

.kf-modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

/* ── Formulaire conteneur ── */
.kf-form {
    display: flex;
    flex-wrap: wrap;
    gap: var(--kf-gap);
}

/* ── Groupe de champ ── */
.kf-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    position: relative;
}

/* ── Label ── */
.kf-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--kf-label);
}

.kf-label-required::after {
    content: ' *';
    color: var(--kf-error);
}

.kf-label-hint {
    font-weight: 400;
    color: var(--kf-text-muted);
    font-size: 11px;
    margin-left: 4px;
}

/* ── Input ── */
.kf-input {
    height: var(--kf-input-height);
    padding: 0 12px;
    border: 1px solid var(--kf-border);
    border-radius: var(--kf-radius);
    font-size: var(--kf-font-size);
    color: var(--kf-text);
    background: var(--kf-bg);
    transition: border-color 0.2s, box-shadow 0.2s;
    width: 100%;
}

.kf-input:focus {
    border-color: var(--kf-border-focus);
    box-shadow: 0 0 0 3px rgba(62,151,255,0.15);
    outline: none;
}

.kf-input:disabled {
    background: var(--kf-bg-disabled);
    color: var(--kf-text-muted);
    cursor: not-allowed;
}

.kf-input::placeholder {
    color: var(--kf-text-muted);
}

.kf-input-error {
    border-color: var(--kf-error) !important;
}

.kf-input-success {
    border-color: var(--kf-success) !important;
}

/* ── Textarea ── */
.kf-textarea {
    padding: 10px 12px;
    border: 1px solid var(--kf-border);
    border-radius: var(--kf-radius);
    font-size: var(--kf-font-size);
    color: var(--kf-text);
    background: var(--kf-bg);
    transition: border-color 0.2s, box-shadow 0.2s;
    width: 100%;
    resize: vertical;
    font-family: inherit;
}

.kf-textarea:focus {
    border-color: var(--kf-border-focus);
    box-shadow: 0 0 0 3px rgba(62,151,255,0.15);
    outline: none;
}

/* ── Select ── */
.kf-select-wrapper {
    position: relative;
}

.kf-select {
    height: var(--kf-input-height);
    padding: 0 32px 0 12px;
    border: 1px solid var(--kf-border);
    border-radius: var(--kf-radius);
    font-size: var(--kf-font-size);
    color: var(--kf-text);
    background: var(--kf-bg);
    transition: border-color 0.2s;
    width: 100%;
    cursor: pointer;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

.kf-select:focus {
    border-color: var(--kf-border-focus);
    box-shadow: 0 0 0 3px rgba(62,151,255,0.15);
    outline: none;
}

.kf-select-arrow {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--kf-text-muted);
    pointer-events: none;
}

/* ── Input file ── */
.kf-file {
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px dashed var(--kf-border);
    border-radius: var(--kf-radius);
    padding: 15px;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--kf-text-muted);
    font-size: 13px;
    gap: 8px;
    min-height: 50px;
}

.kf-file:hover, .kf-file.dragOver {
    border-color: var(--kdBlue);
    background: rgba(62,151,255,0.04);
    color: var(--kdBlue);
}

.kf-file.kf-file-selected {
    border-color: var(--kf-success);
    background: rgba(22,163,106,0.04);
    color: var(--kf-success);
}

.kf-file input[type="file"] {
    display: none;
}

/* ── Footer boutons (Submit/Cancel/Delete) ── */
.kf-footer {
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px 20px;
    border-top: 1px solid var(--kdGreyL);
}

.kf-btn {
    height: 38px;
    padding: 0 20px;
    border: none;
    border-radius: var(--kf-radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.kf-btn-primary {
    background: var(--kdBlue);
    color: white;
}

.kf-btn-primary:hover {
    background: #2563eb;
}

.kf-btn-secondary {
    background: var(--kdGreyL);
    color: var(--kf-text);
}

.kf-btn-secondary:hover {
    background: #d1d5db;
}

.kf-btn-danger {
    background: #fee2e2;
    color: var(--kf-error);
}

.kf-btn-danger:hover {
    background: #fecaca;
}

/* ── Password toggle ── */
.kf-password-toggle {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    color: var(--kf-text-muted);
    z-index: 5;
}

.kf-password-toggle:hover {
    color: var(--kdBlue);
}

/* ── Input avec icône ── */
.kf-input-icon-wrapper {
    position: relative;
}

.kf-input-icon-wrapper .kf-input {
    padding-left: 36px;
}

.kf-input-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--kf-text-muted);
    font-size: 14px;
    pointer-events: none;
}

/* ── Messages validation ── */
.kf-error-text {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--kf-error);
    margin-top: 2px;
}

.kf-success-text {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--kf-success);
    margin-top: 2px;
}

.kf-help-text {
    font-size: 11px;
    color: var(--kf-text-muted);
    margin-top: 2px;
}

/* ── Confirmation YesNo ── */
.kf-confirm {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    padding: 20px;
    text-align: center;
}

.kf-confirm-text {
    font-size: 15px;
    color: var(--kf-text);
}

.kf-confirm-detail {
    font-size: 14px;
    font-weight: 600;
    color: var(--kdBlueD);
}

.kf-confirm-buttons {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

/* ── Widget boutons (page settings) ── */
.kf-widget {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 15px 20px;
    background: white;
    border: 1px solid var(--kdGreyL);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
    color: var(--kf-text);
    margin-bottom: 8px;
}

.kf-widget:hover {
    border-color: var(--kdBlue);
    background: rgba(62,151,255,0.03);
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.kf-widget i {
    font-size: 18px;
    color: var(--kdBlue);
    width: 24px;
    text-align: center;
}

/* ── Trix editor ── */
.kf-trix-wrapper trix-editor {
    border: 1px solid var(--kf-border);
    border-radius: var(--kf-radius);
    min-height: 150px;
    font-size: var(--kf-font-size);
}

.kf-trix-wrapper trix-editor:focus {
    border-color: var(--kf-border-focus);
    box-shadow: 0 0 0 3px rgba(62,151,255,0.15);
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .kf-modal {
        width: 100%;
        max-width: 100%;
        border-radius: 12px 12px 0 0;
        max-height: 95vh;
    }
    
    .kf-group {
        width: 100% !important;
        flex: none !important;
    }
}

/* ── Cadre formulaire inline (dans onglets, pages) ── */
.kf-card {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 24px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
    width: 100%;
    max-width: 700px;
}

.kf-card-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 15px;
    font-weight: 600;
    color: var(--kdBlueD);
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid #f1f5f9;
}

.kf-card-title i {
    color: var(--kdBlue);
    font-size: 16px;
}
