/**
 * Card/Panel Style Form Theme
 * Single unified card design with elevated appearance
 * File: src/scss/partials/form-themes/_card-panel.scss
 */

.fus-form.bfe-editor.card-panel {
    // Theme Variables
    --form-bg: #ffffff;
    --form-border: #e2e8f0;
    --form-border-focus: #4f46e5;
    --form-text: #334155;
    --form-text-light: #64748b;
    --form-text-dark: #0f172a;
    --card-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --card-shadow-hover: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --form-shadow-focus: 0 0 0 3px rgba(79, 70, 229, 0.1);
    --form-radius: 12px;
    --card-radius: 16px;
    --form-spacing: 1.75rem;
    --form-button-bg: #4f46e5;
    --form-button-hover: #4338ca;
    --form-button-text: #ffffff;
    --section-border: #f1f5f9;

    // Main card styling
    background: var(--form-bg);
    border: 1px solid var(--form-border);
    border-radius: var(--card-radius);
    padding: 2.5rem;
    margin: 2rem 0;
    box-shadow: var(--card-shadow);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    line-height: 1.6;
    color: var(--form-text);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;

    // Subtle gradient overlay
    &::before {
        content: "";
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        height: 4px;
        background: linear-gradient(90deg, var(--form-border-focus), #8b5cf6, #06b6d4);
        z-index: 1;
    }

    &:hover {
        box-shadow: var(--card-shadow-hover);
        transform: translateY(-2px);
    }

    // Typography
    h1,
    h2,
    h3,
    h4,
    h5,
    h6 {
        color: var(--form-text-dark);
        font-weight: 700;
        margin: 0 0 1rem 0;
        line-height: 1.3;
    }

    p {
        margin: 0 0 1rem 0;
        color: var(--form-text);
    }

    // Main wrapper
    .wrapper {
        max-width: 100%;
        position: relative;
        z-index: 2;

        .column {
            display: flex;
            flex-direction: column;
            gap: var(--form-spacing);
        }
    }

    // Section dividers for visual separation
    .fe_custom_field,
    .fus-post-title,
    .fus-editor-js-field-wrap,
    .fus-wrap,
    .select-wrap,
    .checkbox-wrap,
    .radio-wrap,
    .file-field,
    .textarea-field {
        margin-bottom: var(--form-spacing);
        padding-bottom: var(--form-spacing);
        border-bottom: 1px solid var(--section-border);
        
        &:last-child {
            border-bottom: none;
            margin-bottom: 0;
            padding-bottom: 0;
        }
    }

    // Labels
    label {
        display: block;
        font-weight: 600;
        color: var(--form-text-dark);
        margin-bottom: 0.75rem;
        font-size: 0.875rem;
        letter-spacing: 0.025em;
    }

    // Input fields styling
    input[type="text"],
    input[type="email"],
    input[type="url"],
    input[type="tel"],
    input[type="number"],
    input[type="date"],
    input[type="password"],
    input[type="google_map"],
    textarea,
    .fus-post-title #fus_post_title,
    select {
        width: 100%;
        padding: 1rem 1.25rem;
        border: 2px solid var(--form-border);
        border-radius: var(--form-radius);
        font-size: 1rem;
        color: var(--form-text);
        background: var(--form-bg);
        transition: all 0.2s ease;
        box-sizing: border-box;
        font-weight: 500;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);

        &:focus {
            outline: none;
            border-color: var(--form-border-focus);
            box-shadow: var(--form-shadow-focus), 0 4px 12px rgba(0, 0, 0, 0.1);
            transform: translateY(-1px);
        }

        &::placeholder {
            color: var(--form-text-light);
            font-weight: 400;
        }

        &:disabled {
            background-color: #f1f5f9;
            color: var(--form-text-light);
            cursor: not-allowed;
        }
    }

    // Textarea specific
    textarea {
        min-height: 140px;
        resize: vertical;
        line-height: 1.6;
    }

    // Post Title Field
    .fus-post-title {
        input[type="fus_post_title"] {
            font-size: 1.375rem;
            font-weight: 600;
            padding: 1.25rem;
            border: 2px solid var(--form-border);
            background: var(--form-bg);
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);

            &:focus {
                border-color: var(--form-border-focus);
                box-shadow: var(--form-shadow-focus), 0 4px 12px rgba(0, 0, 0, 0.1);
            }
        }
    }

    // Featured Image Upload
    .fus-editor-js-field-wrap.thumb-img-wrap {
        .image_loader {
            border: 2px dashed var(--form-border);
            border-radius: var(--form-radius);
            padding: 2.5rem;
            text-align: center;
            transition: all 0.3s ease;
            background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
            box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.03);

            &:hover {
                border-color: var(--form-border-focus);
                background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
                box-shadow: 0 4px 12px rgba(79, 70, 229, 0.1);
            }

            .thumbnail {
                display: flex;
                flex-direction: column;
                align-items: center;
                gap: 1rem;
                cursor: pointer;
                color: var(--form-text);

                .button-icon {
                    width: 48px;
                    height: 48px;
                    opacity: 0.7;
                }
            }

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

    // Editor Fields
    .fus-wrap {
        // EditorJS
        .EditorJS-editor {
            border: 2px solid var(--form-border);
            border-radius: var(--form-radius);
            min-height: 220px;
            overflow: hidden;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);

            .codex-editor {
                border-radius: var(--form-radius);

                .codex-editor__redactor {
                    padding: 1.5rem;
                }
            }

            .ce-toolbar {
                border-color: var(--form-border);
                background: #f8fafc;
            }
        }

        // TinyMCE
        .wp-editor-wrap {
            border: 2px solid var(--form-border);
            border-radius: var(--form-radius);
            overflow: hidden;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);

            .wp-editor-tools {
                background: #f8fafc;
                border-bottom: 2px solid var(--form-border);
                padding: 0.75rem;
            }

            .mce-tinymce {
                border: none !important;
            }
        }

        // MD Editor
        .md-editor {
            border: 2px solid var(--form-border);
            border-radius: var(--form-radius);
            overflow: hidden;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);

            .bytemd {
                border: none;

                .bytemd-toolbar {
                    background: #f8fafc;
                    border-bottom: 2px solid var(--form-border);
                    padding: 1rem;
                }
            }
        }
    }

    // Taxonomy Fields
    .select-wrap {
        .ss-main {
            border: 2px solid var(--form-border);
            border-radius: var(--form-radius);
            background: var(--form-bg);
            box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);

            .ss-single-selected {
                padding: 1rem 1.25rem;
                color: var(--form-text);
                height: auto;
                font-weight: 500;

                .placeholder {
                    color: var(--form-text-light);
                    font-weight: 400;
                }
            }

            .ss-content {
                border: 2px solid var(--form-border);
                border-radius: var(--form-radius);
                margin-top: 0.5rem;
                box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
                background: var(--form-bg);

                .ss-option {
                    padding: 1rem 1.25rem;
                    color: var(--form-text);
                    transition: all 0.15s ease;
                    font-weight: 500;

                    &:hover {
                        background: #f0f9ff;
                    }

                    &.ss-highlighted {
                        background: var(--form-border-focus);
                        color: white;
                        font-weight: 600;
                    }

                    &.optionChild {
                        margin-left: 15px;
                        padding: 0.75rem 1.25rem;
                        border-left: 3px solid var(--form-border);
                    }
                }
            }
        }
    }

    // Text Fields
    .fe_custom_field {
        // Header Field
        &.fe-header {
            h1,
            h2,
            h3,
            h4,
            h5,
            h6 {
                color: var(--form-border-focus);
                border-bottom: 2px solid var(--form-border);
                padding-bottom: 0.75rem;
                margin-bottom: 1rem;
                position: relative;

                &::after {
                    content: "";
                    position: absolute;
                    bottom: -2px;
                    left: 0;
                    width: 60px;
                    height: 2px;
                    background: var(--form-border-focus);
                }
            }
        }

        // Paragraph Field
        &.fe-paragraph {
            p {
                padding: 1.25rem;
                background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
                border-left: 4px solid var(--form-border-focus);
                border-radius: 0 var(--form-radius) var(--form-radius) 0;
                margin: 0;
                font-weight: 500;
                box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
            }
        }

        // Button Field
        button {
            background: linear-gradient(135deg, var(--form-button-bg) 0%, #8b5cf6 100%);
            color: var(--form-button-text);
            border: none;
            padding: 1rem 2rem;
            border-radius: var(--form-radius);
            font-weight: 600;
            cursor: pointer;
            transition: all 0.3s ease;
            font-size: 1rem;
            box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25);

            &:hover {
                background: linear-gradient(135deg, var(--form-button-hover) 0%, #7c3aed 100%);
                transform: translateY(-2px);
                box-shadow: 0 8px 25px rgba(79, 70, 229, 0.35);
            }

            &:active {
                transform: translateY(0);
            }
        }

        // Google Map Field
        &.google_map {
            .autocomplete {
                width: 100%;
                padding: 1rem 1.25rem;
                border: 2px solid var(--form-border);
                border-radius: var(--form-radius);
                font-size: 1rem;
                font-weight: 500;
                box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);

                &:focus {
                    border-color: var(--form-border-focus);
                    box-shadow: var(--form-shadow-focus), 0 4px 12px rgba(0, 0, 0, 0.1);
                    transform: translateY(-1px);
                }
            }
        }

        // Date Field
        &.date-field {
            input[type="date"] {
                position: relative;
                font-weight: 500;

                &::-webkit-calendar-picker-indicator {
                    opacity: 0.7;
                    cursor: pointer;
                }
            }
        }
    }

    // Checkbox Groups
    .checkbox-wrap {
        .checkbox-item {
            margin-bottom: 1rem;
            padding: 0.875rem;
            background: #f8fafc;
            border-radius: var(--form-radius);
            border: 1px solid #e2e8f0;
            transition: all 0.2s ease;

            &:hover {
                background: #f0f9ff;
                border-color: var(--form-border-focus);
            }

            label {
                display: flex;
                align-items: center;
                gap: 0.75rem;
                cursor: pointer;
                font-weight: 500;
                margin-bottom: 0;

                input[type="checkbox"] {
                    width: 1.25rem;
                    height: 1.25rem;
                    border: 2px solid var(--form-border);
                    border-radius: 0.375rem;
                    margin: 0;
                    cursor: pointer;
                    accent-color: var(--form-border-focus);

                    &:checked {
                        background-color: var(--form-border-focus);
                        border-color: var(--form-border-focus);
                    }

                    &:focus {
                        box-shadow: var(--form-shadow-focus);
                    }
                }
            }

            &:last-child {
                margin-bottom: 0;
            }
        }
    }

    // Radio Groups
    .radio-wrap {
        .radio-item {
            margin-bottom: 1rem;
            padding: 0.875rem;
            background: #f8fafc;
            border-radius: var(--form-radius);
            border: 1px solid #e2e8f0;
            transition: all 0.2s ease;

            &:hover {
                background: #f0f9ff;
                border-color: var(--form-border-focus);
            }

            label {
                display: flex;
                align-items: center;
                gap: 0.75rem;
                cursor: pointer;
                font-weight: 500;
                margin-bottom: 0;

                input[type="radio"] {
                    width: 1.25rem;
                    height: 1.25rem;
                    border: 2px solid var(--form-border);
                    margin: 0;
                    cursor: pointer;
                    accent-color: var(--form-border-focus);

                    &:checked {
                        background-color: var(--form-border-focus);
                        border-color: var(--form-border-focus);
                    }

                    &:focus {
                        box-shadow: var(--form-shadow-focus);
                    }
                }
            }

            &:last-child {
                margin-bottom: 0;
            }
        }
    }

    // File Upload Field
    .file-field {
        .filepond--root {
            border: 2px dashed var(--form-border);
            border-radius: var(--form-radius);
            background: linear-gradient(135deg, #f8fafc 0%, #f0f9ff 100%);
            transition: all 0.3s ease;
            box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.03);

            .filepond--drop-label {
                color: var(--form-text);
                font-weight: 600;
            }

            &:hover {
                border-color: var(--form-border-focus);
                background: linear-gradient(135deg, #e0f2fe 0%, #dbeafe 100%);
                box-shadow: 0 4px 12px rgba(79, 70, 229, 0.1);
            }

            .filepond--item {
                border-radius: var(--form-radius);
            }
        }
    }

    // Form Control Buttons
    .fus-form-block-header {
        display: flex;
        gap: 1.5rem;
        padding: 2rem 0 0 0;
        border-top: 2px solid var(--section-border);
        margin-top: 2rem;

        .sub-header {
            display: flex;
            gap: 1.5rem;
            align-items: center;
            width: 100%;

            button {
                background: linear-gradient(135deg, var(--form-button-bg) 0%, #8b5cf6 100%);
                color: var(--form-button-text);
                border: none;
                padding: 1rem 2.5rem;
                border-radius: var(--form-radius);
                font-weight: 700;
                cursor: pointer;
                transition: all 0.3s ease;
                font-size: 1rem;
                box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25);

                &:hover {
                    background: linear-gradient(135deg, var(--form-button-hover) 0%, #7c3aed 100%);
                    transform: translateY(-2px);
                    box-shadow: 0 8px 25px rgba(79, 70, 229, 0.35);
                }

                &.form-save-draft {
                    background: linear-gradient(135deg, #64748b 0%, #475569 100%);
                    box-shadow: 0 4px 12px rgba(100, 116, 139, 0.25);

                    &:hover {
                        background: linear-gradient(135deg, #475569 0%, #334155 100%);
                        box-shadow: 0 8px 25px rgba(100, 116, 139, 0.35);
                    }
                }

                &.view-page {
                    background: transparent;
                    color: var(--form-border-focus);
                    border: 2px solid var(--form-border-focus);
                    box-shadow: none;

                    &:hover {
                        background: var(--form-border-focus);
                        color: white;
                        box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25);
                    }
                }
            }
        }
    }

    // Messages
    #fus-message-wrap {
        margin: 1.5rem 0;

        .message {
            padding: 1.5rem;
            border-radius: var(--form-radius);
            margin-bottom: 1.5rem;
            font-weight: 500;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);

            &.success {
                background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
                color: #065f46;
                border: none;
                border-left: 4px solid #10b981;
            }

            &.error {
                background: linear-gradient(135deg, #fee2e2 0%, #fca5a5 100%);
                color: #991b1b;
                border: none;
                border-left: 4px solid #ef4444;
            }
        }
    }

    // Loading States
    .fus-loader {
        border: 3px solid var(--form-border);
        border-top: 3px solid var(--form-border-focus);
        border-radius: 50%;
        width: 24px;
        height: 24px;
        animation: spin 1s linear infinite;
    }

    @keyframes spin {
        0% {
            transform: rotate(0deg);
        }
        100% {
            transform: rotate(360deg);
        }
    }

    // Responsive Design
    @media (max-width: 768px) {
        padding: 2rem;
        margin: 1rem 0;

        .wrapper .column {
            gap: 1.5rem;
        }

        .fus-form-block-header .sub-header {
            flex-direction: column;
            align-items: stretch;
            gap: 1rem;

            button {
                width: 100%;
                text-align: center;
                padding: 1rem 1.5rem;
            }
        }

        .select-wrap .ss-content {
            margin-top: 0.25rem;
            border-radius: var(--form-radius);
        }
    }

    @media (max-width: 480px) {
        padding: 1.5rem;

        input[type="text"],
        input[type="email"],
        input[type="url"],
        input[type="tel"],
        input[type="number"],
        input[type="date"],
        input[type="password"],
        textarea,
        select {
            font-size: 16px; // Prevent zoom on iOS
            padding: 0.875rem 1rem;
        }

        .fus-post-title input {
            font-size: 1.25rem;
            padding: 1rem;
        }
    }
}

// High contrast mode support
@media (prefers-contrast: high) {
    .fus-form.bfe-editor.card-panel {
        --form-border: #000000;
        --form-border-focus: #0000ff;
        --form-text: #000000;
        --form-text-light: #333333;
    }
}

// Reduced motion support
@media (prefers-reduced-motion: reduce) {
    .fus-form.bfe-editor.card-panel {
        * {
            transition: none !important;
            animation: none !important;
            transform: none !important;
        }
    }
}