/**
 * Customize for Me (CFM) Styles
 * Matches the Blocks Editor design patterns from frontend.css
 */

/* ==========================================
   CFM Form Container - mirrors .dlbg-blocks-editor
   ========================================== */
.dlbg-cfm-form {
    margin: 20px 0;
    padding: 0;
    width: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* ==========================================
   CFM Section - mirrors .dlbg-blocks-section
   ========================================== */
.dlbg-cfm-section {
    background: #fff;
    border-radius: 10px;
    overflow: hidden;
    border: none;
    width: 100%;
    box-sizing: border-box;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Section Title - mirrors .dlbg-blocks-section-title */
.dlbg-cfm-section-title {
    margin: 0;
    padding: 14px 20px;
    background: linear-gradient(135deg, #4A90E2 0%, #5BA0F2 100%);
    color: #fff;
    font-size: 1.05em;
    font-weight: 600;
    letter-spacing: 0.5px;
    border-bottom: none;
    display: flex;
    align-items: center;
    gap: 10px;
}

.dlbg-cfm-section-title::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 50%;
}

/* Section Content - mirrors .dlbg-blocks-section-content */
.dlbg-cfm-section-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 20px;
    background: #f9f9f9;
}

/* ==========================================
   Instruction Banner - mirrors .dlbg-blocks-instructions
   ========================================== */
.dlbg-cfm-instructions {
    background: #f0f7ff;
    border: 1px solid #c5ddf5;
    border-radius: 8px;
    padding: 15px 20px;
    margin-bottom: 0;
}

.dlbg-cfm-instructions-inner {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.dlbg-cfm-instructions-inner > i {
    color: #4A90E2;
    font-size: 20px;
    margin-top: 2px;
    flex-shrink: 0;
}

.dlbg-cfm-instructions p {
    margin: 0 0 5px;
    font-size: 0.95em;
    line-height: 1.6;
    color: #2c5282;
}

.dlbg-cfm-instructions p:last-child {
    margin-bottom: 0;
}

.dlbg-cfm-instructions strong,
.dlbg-cfm-instructions b {
    font-weight: 700 !important;
    font-style: normal;
}

/* ==========================================
   Form Fields Container
   ========================================== */
.dlbg-cfm-fields {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* ==========================================
   Individual Field Row - mirrors .dlbg-block-item
   ========================================== */
.dlbg-cfm-field-row {
    background: #fff;
    border-radius: 6px;
    padding: 15px;
    border: 1px solid #ddd;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Field Labels - mirrors .dlbg-block-item-label */
.dlbg-cfm-label {
    display: block;
    font-weight: 600;
    margin-bottom: 4px;
    color: #333;
    font-size: 0.95em;
}

.dlbg-cfm-required {
    color: #dc3232;
    margin-left: 2px;
}

.dlbg-cfm-field-error {
    border-color: #dc3232 !important;
    box-shadow: 0 0 0 1px #dc3232 !important;
}

.dlbg-cfm-field-error-msg {
    color: #dc3232;
    font-size: 0.85em;
    margin-top: 4px;
    font-weight: 500;
}

.dlbg-cfm-validation-banner {
    background: #fef2f2;
    border: 1px solid #fca5a5;
    border-radius: 6px;
    color: #991b1b;
    padding: 12px 16px;
    margin-bottom: 16px;
    font-size: 0.95em;
    line-height: 1.5;
}

.dlbg-cfm-validation-banner i {
    margin-right: 6px;
}

/* ==========================================
   Input Styles - mirrors .dlbg-block-text-input
   ========================================== */
.dlbg-cfm-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 0.95em;
    line-height: 1.5;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}

.dlbg-cfm-input:focus {
    outline: none;
    border-color: #4A90E2;
    box-shadow: 0 0 0 2px rgba(74, 144, 226, 0.1);
}

.dlbg-cfm-select {
    appearance: auto;
    cursor: pointer;
    background: #fff;
}

.dlbg-cfm-textarea {
    resize: vertical;
    min-height: 80px;
}

/* ==========================================
   Poem Field
   ========================================== */
.dlbg-cfm-poem-field {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.dlbg-cfm-poem-textarea {
    min-height: 120px;
}

/* Browse Poems button - uses .dlbg-btn .dlbg-btn-secondary from frontend.css */
.dlbg-cfm-browse-poems-btn {
    align-self: flex-start;
}

.dlbg-cfm-browse-poems-btn i {
    font-size: 0.9em;
}

/* Poem actions row (Browse Poems + Translate) */
.dlbg-cfm-poem-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* CFM Translate button */
.dlbg-cfm-translate-btn {
    background: #fff !important;
    border: 1px solid #999 !important;
    color: #666 !important;
    padding: 2px 10px !important;
    font-size: 11px !important;
    cursor: pointer;
    line-height: 1 !important;
    border-radius: 2px !important;
    transition: all 0.2s;
    flex-shrink: 0;
    align-self: flex-start;
    white-space: nowrap;
    letter-spacing: 0.3px;
    margin: 0 !important;
    height: auto !important;
    min-height: 0 !important;
    text-transform: none !important;
}

.dlbg-cfm-translate-btn:hover {
    border-color: #0073aa !important;
    color: #0073aa !important;
    background: #fff !important;
}

/* ==========================================
   File Upload - mirrors .dlbg-block-upload-area
   ========================================== */
.dlbg-cfm-file-field {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.dlbg-cfm-upload-area {
    border: 2px dashed #ccc;
    border-radius: 8px;
    padding: 40px 20px;
    text-align: center;
    background: #fafafa;
    cursor: pointer;
    transition: border-color 0.2s, background-color 0.2s;
    position: relative;
}

.dlbg-cfm-upload-area:hover,
.dlbg-cfm-upload-area.dlbg-cfm-drag-over {
    border-color: #00bdf8;
    background: #f0f9ff;
}

.dlbg-cfm-upload-prompt {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    color: #666;
}

.dlbg-cfm-upload-prompt i {
    font-size: 48px;
    color: #999;
    margin-bottom: 5px;
}

.dlbg-cfm-upload-prompt span {
    font-size: 1em;
    color: #666;
}

.dlbg-cfm-upload-prompt small {
    font-size: 0.85em;
    color: #888;
}

.dlbg-cfm-file-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

/* File Previews */
.dlbg-cfm-file-previews {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.dlbg-cfm-file-preview {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    max-width: 280px;
    position: relative;
}

.dlbg-cfm-file-thumb {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 4px;
    flex-shrink: 0;
}

.dlbg-cfm-file-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f5f5f5;
    border-radius: 4px;
    flex-shrink: 0;
}

.dlbg-cfm-file-icon i {
    font-size: 22px;
    color: #666;
}

.dlbg-cfm-file-name {
    font-size: 0.85em;
    color: #555;
    word-break: break-all;
    flex: 1;
    line-height: 1.3;
}

.dlbg-cfm-file-remove {
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    padding: 4px;
    font-size: 14px;
    flex-shrink: 0;
    transition: color 0.2s;
}

.dlbg-cfm-file-remove:hover {
    color: #dc3232;
}

/* Upload Progress */
.dlbg-cfm-upload-progress {
    display: flex;
    align-items: center;
    gap: 10px;
}

.dlbg-cfm-progress-bar {
    flex: 1;
    height: 6px;
    background: #e0e0e0;
    border-radius: 3px;
    overflow: hidden;
}

.dlbg-cfm-progress-fill {
    height: 100%;
    background: #00bdf8;
    border-radius: 3px;
    transition: width 0.2s;
    width: 0%;
}

.dlbg-cfm-progress-text {
    font-size: 12px;
    color: #666;
    white-space: nowrap;
}

/* Max files notice */
.dlbg-cfm-max-files-notice {
    background: #fff8e1;
    border: 1px solid #ffcc02;
    border-radius: 6px;
    padding: 10px 14px;
    font-size: 0.9em;
    line-height: 1.5;
    color: #856404;
}

.dlbg-cfm-max-files-notice i {
    margin-right: 6px;
}

/* ==========================================
   Poems Modal Overrides (when used from CFM)
   ========================================== */
.dlbg-poem-item {
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    margin-bottom: 8px;
    overflow: hidden;
}

.dlbg-poem-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    cursor: pointer;
    background: #fafafa;
    transition: background 0.2s;
}

.dlbg-poem-title:hover {
    background: #f0f0f0;
}

.dlbg-poem-title-text {
    font-weight: 600;
    font-size: 14px;
    color: #333;
}

.dlbg-poem-toggle-icon {
    color: #999;
    transition: transform 0.2s;
}

.dlbg-poem-item.expanded .dlbg-poem-toggle-icon {
    transform: rotate(180deg);
}

.dlbg-poem-body {
    padding: 15px;
    border-top: 1px solid #e0e0e0;
}

.dlbg-poem-text {
    font-size: 13.5px;
    line-height: 1.6;
    color: #444;
    margin-bottom: 12px;
    white-space: pre-line;
}

.dlbg-poem-select-btn {
    padding: 8px 20px;
    background: #00bdf8;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.2s;
}

.dlbg-poem-select-btn:hover {
    background: #00a3d9;
}

/* ==========================================
   Body class when CFM is enabled
   ========================================== */
body.dlbg-cfm-enabled-product .dlbg-cfm-form {
    /* Additional overrides if needed */
}

/* ==========================================
   Responsive
   ========================================== */
@media (max-width: 768px) {
    .dlbg-cfm-section-content {
        padding: 15px;
    }

    .dlbg-cfm-instructions-inner {
        flex-direction: column;
        gap: 8px;
    }

    .dlbg-cfm-instructions-inner > i {
        display: none;
    }

    .dlbg-cfm-field-row {
        padding: 12px;
    }

    .dlbg-cfm-file-preview {
        max-width: 100%;
    }

    .dlbg-cfm-file-previews {
        flex-direction: column;
    }

    .dlbg-cfm-upload-area {
        padding: 25px 15px;
    }

    .dlbg-cfm-upload-prompt i {
        font-size: 36px;
    }
}

@media (max-width: 480px) {
    .dlbg-cfm-instructions {
        padding: 12px;
    }

    .dlbg-cfm-input {
        padding: 8px 10px;
        font-size: 16px; /* Prevent zoom on iOS */
    }
}
