/**
 * Custom Fields Module Styles
 *
 * Styles for course-specific booking fields and variant extra fields.
 *
 * @package KursBooking
 * @since   1.3.0
 */

/* ═══════════════════════════════════════════════════════════════════════════
   ADMIN: Custom Fields Metabox
   ═══════════════════════════════════════════════════════════════════════════ */

.kb-custom-fields-metabox {
    padding: 10px 0;
}

.kb-section {
    margin-bottom: 20px;
}

.kb-section-title {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0 0 10px 0;
    font-size: 14px;
    font-weight: 600;
    color: #1d2327;
}

.kb-section-title .dashicons {
    color: #2271b1;
    font-size: 18px;
    width: 18px;
    height: 18px;
}

.kb-section-divider {
    margin: 20px 0;
    border: 0;
    border-top: 1px solid #ddd;
}

/* ───────────────────────────────────────────────────────────────────────────
   Global Fields List
   ─────────────────────────────────────────────────────────────────────────── */

.kb-global-fields-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 15px 0;
}

.kb-global-field-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.kb-global-field-item:hover {
    background: #f0f0f0;
    border-color: #c0c0c0;
}

.kb-global-field-item.kb-disabled {
    opacity: 0.6;
    background: #fff;
}

.kb-global-field-item.kb-disabled:hover {
    opacity: 0.8;
}

.kb-global-field-item input[type="checkbox"] {
    margin: 0;
    flex-shrink: 0;
}

.kb-field-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.kb-field-label {
    font-weight: 500;
    color: #1d2327;
}

.kb-field-meta {
    display: flex;
    gap: 8px;
    color: #666;
    font-size: 12px;
}

.kb-field-type {
    background: #e0e0e0;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.kb-field-mandatory {
    color: #d63638;
    font-weight: bold;
    font-size: 16px;
}

/* ───────────────────────────────────────────────────────────────────────────
   Notice
   ─────────────────────────────────────────────────────────────────────────── */

.kb-notice {
    padding: 12px 16px;
    border-radius: 4px;
    margin: 15px 0;
}

.kb-notice-info {
    background: #f0f6fc;
    border-left: 4px solid #2271b1;
}

.kb-notice p {
    margin: 0;
}

.kb-link {
    margin-left: 8px;
    color: #2271b1;
    text-decoration: none;
}

.kb-link:hover {
    text-decoration: underline;
}

.kb-helper-text {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #666;
    font-size: 12px;
    margin-top: 10px;
}

.kb-helper-text .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
    color: #888;
}

/* ───────────────────────────────────────────────────────────────────────────
   Kurs-Specific Fields List
   ─────────────────────────────────────────────────────────────────────────── */

.kb-kurs-fields-list {
    margin: 15px 0;
    min-height: 50px;
}

.kb-no-fields-placeholder {
    text-align: center;
    padding: 30px 20px;
    background: #f9f9f9;
    border: 2px dashed #ddd;
    border-radius: 6px;
    color: #666;
}

.kb-no-fields-placeholder .dashicons {
    font-size: 36px;
    width: 36px;
    height: 36px;
    color: #ccc;
    margin-bottom: 5px;
}

.kb-no-fields-placeholder p {
    margin: 10px 0 0 0;
    font-size: 14px;
}

.kb-kurs-field-row {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    margin-bottom: 10px;
    padding: 14px;
    transition: border-color 0.2s ease;
}

.kb-kurs-field-row:hover {
    border-color: #c0c0c0;
}

.kb-field-row-inner {
    display: flex;
    align-items: center;
    gap: 10px;
}

.kb-drag-handle {
    cursor: move;
    color: #999;
    flex-shrink: 0;
}

.kb-drag-handle:hover {
    color: #666;
}

.kb-field-label-input {
    flex: 1;
    min-width: 150px;
    padding: 6px 10px;
}

.kb-field-type-select {
    width: 130px;
    padding: 6px 10px;
}

.kb-field-mandatory-label {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.kb-field-mandatory-label input[type="checkbox"] {
    display: none;
}

.kb-field-mandatory-label .dashicons {
    color: #ddd;
    cursor: pointer;
    transition: color 0.2s ease;
    font-size: 20px;
    width: 20px;
    height: 20px;
}

.kb-field-mandatory-label input:checked + .dashicons {
    color: #f0b849;
}

.kb-remove-kurs-field {
    color: #d63638 !important;
    padding: 4px 8px !important;
    flex-shrink: 0;
}

.kb-remove-kurs-field .dashicons {
    margin: 0;
    font-size: 16px;
    width: 16px;
    height: 16px;
}

.kb-field-options-row,
.kb-field-placeholder-row {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px dashed #eee;
    display: flex;
    align-items: center;
    gap: 10px;
}

.kb-field-options-row label,
.kb-field-placeholder-row label {
    flex-shrink: 0;
    font-weight: 500;
    min-width: 80px;
    color: #555;
}

.kb-field-options-row .description {
    flex-shrink: 0;
    color: #888;
    font-size: 12px;
    font-style: italic;
}

#kb-add-kurs-field {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

#kb-add-kurs-field .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   ADMIN: Variant Extra Fields
   ═══════════════════════════════════════════════════════════════════════════ */

.kb-variant-extra-field {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px dashed #e0e0e0;
}

.kb-has-extra-field {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    cursor: pointer;
}

.kb-has-extra-field input[type="checkbox"] {
    margin: 0;
}

.kb-extra-field-options {
    margin-top: 12px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 6px;
}

.kb-extra-field-row {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 12px;
}

.kb-extra-field-row:last-child {
    margin-bottom: 0;
}

.kb-extra-type-option {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    padding: 6px 12px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.kb-extra-type-option:hover {
    border-color: #2271b1;
}

.kb-extra-type-option:has(input:checked) {
    border-color: #2271b1;
    background: #f0f6fc;
}

.kb-extra-type-option input[type="radio"] {
    margin: 0;
}

.kb-quantity-options {
    flex-wrap: wrap;
}

.kb-quantity-options label {
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.kb-quantity-options input[type="number"] {
    width: 60px !important;
    padding: 4px 8px;
    text-align: center;
}

.kb-quantity-options input[type="checkbox"] {
    margin: 0;
}

/* Placeholder for new variants */
.kb-variant-extra-field-container:empty {
    display: none;
}

/* ═══════════════════════════════════════════════════════════════════════════
   FRONTEND: Extra Field Inputs
   ═══════════════════════════════════════════════════════════════════════════ */

.kb-extra-field-input {
    margin-top: 12px;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.kb-extra-field-label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 14px;
    color: #333;
}

.kb-extra-field-label .kb-required {
    color: #dc3545;
    margin-left: 3px;
}

.kb-extra-quantity {
    width: 90px;
    padding: 10px 14px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 16px;
    text-align: center;
    transition: border-color 0.2s ease;
}

.kb-extra-quantity:focus {
    border-color: #4a90d9;
    outline: none;
    box-shadow: 0 0 0 3px rgba(74, 144, 217, 0.15);
}

.kb-extra-text {
    width: 100%;
    max-width: 320px;
    padding: 10px 14px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s ease;
}

.kb-extra-text:focus {
    border-color: #4a90d9;
    outline: none;
    box-shadow: 0 0 0 3px rgba(74, 144, 217, 0.15);
}

/* Multiplier hint */
.kb-extra-multiply-hint {
    display: inline-block;
    margin-left: 10px;
    font-size: 12px;
    color: #666;
    font-weight: normal;
}

/* ═══════════════════════════════════════════════════════════════════════════
   FRONTEND: Merged Custom Fields (Step 2)
   ═══════════════════════════════════════════════════════════════════════════ */

.kb-merged-field {
    margin-bottom: 18px;
}

.kb-merged-field label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    color: #333;
}

.kb-merged-field .kb-required {
    color: #dc3545;
}

.kb-merged-field input[type="text"],
.kb-merged-field input[type="email"],
.kb-merged-field input[type="tel"],
.kb-merged-field input[type="number"],
.kb-merged-field input[type="date"],
.kb-merged-field select,
.kb-merged-field textarea {
    width: 100%;
    max-width: 400px;
    padding: 10px 14px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s ease;
}

.kb-merged-field input:focus,
.kb-merged-field select:focus,
.kb-merged-field textarea:focus {
    border-color: #4a90d9;
    outline: none;
    box-shadow: 0 0 0 3px rgba(74, 144, 217, 0.15);
}

.kb-merged-field textarea {
    min-height: 80px;
    resize: vertical;
}

.kb-radio-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.kb-radio-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: normal;
    cursor: pointer;
}

.kb-radio-group input[type="radio"] {
    margin: 0;
}

/* Field source indicator (dev mode) */
.kb-merged-field[data-field-source="kurs"]::before {
    content: '';
    /* Uncomment for debugging:
    content: 'Kurs';
    display: inline-block;
    font-size: 10px;
    padding: 2px 6px;
    background: #e8f4fd;
    color: #2271b1;
    border-radius: 3px;
    margin-bottom: 4px;
    */
}

/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 782px) {
    .kb-field-row-inner {
        flex-wrap: wrap;
    }

    .kb-field-label-input {
        width: 100%;
        min-width: 100%;
    }

    .kb-field-type-select {
        flex: 1;
    }

    .kb-extra-field-row {
        flex-wrap: wrap;
    }

    .kb-quantity-options {
        width: 100%;
    }

    .kb-extra-quantity,
    .kb-extra-text {
        width: 100%;
        max-width: none;
    }
}

@media (max-width: 480px) {
    .kb-global-field-item {
        flex-wrap: wrap;
    }

    .kb-field-info {
        flex-wrap: wrap;
        width: 100%;
    }

    .kb-extra-type-option {
        flex: 1;
        justify-content: center;
    }
}
