/**
 * GFTEC Frontend Styles
 *
 * Styles for the edit event form and key entry form.
 * Design adapted from Gravity Forms SCSS Skeleton to maintain consistency.
 *
 * @package GFTEC
 */

/* Variables - Matching GF Skeleton Design */
.gftec-edit-event-wrapper,
.gftec-edit-form-wrapper,
.gftec-key-form-wrapper,
.gftec-error-wrapper {
    /* Core design tokens */
    --page-bg: #FAFAFA;
    --form-bg: #ffffff;
    --text-color: #212121;
    --heading-color: #000000;
    --border-color: #D9D8D8;
    --accent-color: #f9ae33;
    --error-color: #F15C5A;
    --success-color: #46b450;
    --text-light: #555;
    --gap-2xs: 0.5rem;
    --gap-xs: 0.75rem;

    /* Bricks Builder variables for button consistency */
    --bricks-color-blhvyj: #000000;  /* Button text color */
    --bricks-color-vdcldn: #f9ae33;  /* Button background (accent) */
    --bricks-color-zrbyki: #e09a1f;  /* Button hover background */

    font-family: 'Lato', sans-serif;
    color: var(--text-color);
}

/* Form Wrapper - Matches Bricks container layout */
.gftec-edit-event-wrapper,
.gftec-edit-form-wrapper,
.gftec-key-form-wrapper,
.gftec-error-wrapper {
    max-width: 100%;
    width: 100%;
    margin: 0;
    padding: 0;
    background: var(--form-bg);
}

/* Form Header - Matching GF gform_heading style */
.gftec-form-header {
    margin-bottom: 2rem;
}

.gftec-form-header h2 {
    margin: 0 0 10px;
    font-size: 28px;
    font-weight: 700;
    color: var(--heading-color);
}

.gftec-event-info {
    margin: 0;
    color: var(--text-light);
    font-size: 0.95rem;
}

/* Messages */
#gftec-messages {
    margin-bottom: 20px;
}

#gftec-messages:empty {
    display: none;
}

/* Notices - Matching GF Validation Style */
.gftec-notice {
    padding: 20px;
    margin-bottom: 30px;
    border-left: 4px solid;
}

.gftec-notice p {
    margin: 0;
}

.gftec-notice-success {
    background-color: #f0f8ff;
    border-color: #bde0fe;
    color: var(--text-color);
}

.gftec-notice-error {
    background-color: rgba(241, 92, 90, 0.05);
    border-color: var(--error-color);
    color: var(--text-color);
}

.gftec-notice-error strong {
    color: var(--error-color);
}

.gftec-notice-warning {
    background-color: rgba(249, 174, 51, 0.1);
    border-color: var(--accent-color);
    color: var(--text-color);
}

/* Form Sections - Matching GF gform_body style */
.gftec-form-section {
    margin-bottom: 2rem;
}

.gftec-form-section:last-of-type {
    margin-bottom: 0;
}

.gftec-section-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--heading-color);
    margin: 0 0 1.5rem;
    padding: 0;
}

.gftec-section-description {
    color: var(--text-light);
    font-size: 0.85rem;
    margin-bottom: 15px;
}

/* Collapsible Sections */
.gftec-section-toggle {
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    user-select: none;
    transition: color 0.2s ease;
}

.gftec-section-toggle:hover {
    color: var(--accent-color);
}

.gftec-section-toggle:focus {
    outline: none;
    color: var(--accent-color);
}

.gftec-toggle-icon::before {
    content: '\25BC';
    font-size: 10px;
    opacity: 0.5;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.gftec-section-toggle:hover .gftec-toggle-icon::before {
    opacity: 1;
}

.gftec-section-toggle[aria-expanded="false"] .gftec-toggle-icon::before {
    transform: rotate(-90deg);
}

.gftec-section-toggle[aria-expanded="false"] + .gftec-section-content {
    display: none;
}

/* Fieldset */
.gftec-fieldset {
    border: 1px solid var(--border-color);
    padding: 20px;
    margin: 0 0 20px;
}

.gftec-fieldset legend {
    font-weight: 700;
    padding: 0 10px;
    font-size: 1rem;
}

/* Form Fields */
.gftec-field {
    margin-bottom: 2rem;
}

.gftec-field:last-child {
    margin-bottom: 0;
}

.gftec-field label {
    display: block;
    gap: 2px;
    font-size: 0.9rem;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-color);
}

.gftec-field .required {
    color: var(--error-color);
    font-weight: bold;
    margin-left: 2px;
}

/* Form Inputs - Matching GF Skeleton */
.gftec-field input[type="text"],
.gftec-field input[type="email"],
.gftec-field input[type="url"],
.gftec-field input[type="tel"],
.gftec-field input[type="date"],
.gftec-field input[type="time"],
.gftec-field input[type="number"],
.gftec-field textarea,
.gftec-field select {
    width: 100%;
    padding: var(--gap-2xs) var(--gap-xs);
    height: auto;
    max-height: 12ch;
    font-size: 1rem;
    font-family: 'Lato', sans-serif;
    border: 1px solid var(--border-color);
    border-radius: 0;
    background-color: var(--form-bg);
    color: var(--text-color);
    box-shadow: none;
    box-sizing: border-box;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.gftec-field textarea {
    max-height: none;
    resize: vertical;
    min-height: 120px;
}

.gftec-field input:hover,
.gftec-field textarea:hover,
.gftec-field select:hover {
    border-color: #b0b0b0;
}

.gftec-field input:focus,
.gftec-field textarea:focus,
.gftec-field select:focus {
    outline: transparent;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(249, 174, 51, 0.2);
}

.gftec-field input::placeholder,
.gftec-field textarea::placeholder {
    color: #999;
    font-family: 'Lato', sans-serif;
}

.gftec-field input:focus::placeholder,
.gftec-field textarea:focus::placeholder {
    color: #aaa;
}

/* Field Description */
.gftec-field-description {
    font-size: 0.85rem;
    color: var(--text-light);
    padding-top: 8px;
}

/* Field Rows (side by side) */
.gftec-field-row {
    display: flex;
    gap: 20px;
    margin-bottom: 2rem;
}

.gftec-field-row .gftec-field {
    margin-bottom: 0;
}

.gftec-field-half {
    flex: 1;
}

@media (max-width: 600px) {
    .gftec-field-row {
        flex-direction: column;
        gap: 0;
    }

    .gftec-field-row .gftec-field {
        margin-bottom: 2rem;
    }
}

/* Date & Time Row - Matching GF Layout */
.gftec-datetime-row {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.gftec-datetime-row .gftec-field-date {
    flex: 1;
    min-width: 0;
}

.gftec-datetime-row .gftec-field-time-group {
    flex: 0 0 auto;
}

.gftec-time-inputs {
    display: flex;
    gap: 8px;
}

.gftec-time-inputs input.gftec-time-hour,
.gftec-time-inputs input.gftec-time-minute {
    width: 60px;
    text-align: center;
    -moz-appearance: textfield;
}

.gftec-time-inputs input.gftec-time-hour::-webkit-outer-spin-button,
.gftec-time-inputs input.gftec-time-minute::-webkit-outer-spin-button,
.gftec-time-inputs input.gftec-time-hour::-webkit-inner-spin-button,
.gftec-time-inputs input.gftec-time-minute::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

@media (max-width: 600px) {
    .gftec-datetime-row {
        flex-wrap: wrap;
    }

    .gftec-datetime-row .gftec-field-date {
        flex: 1 1 100%;
        margin-bottom: 1rem;
    }

    .gftec-datetime-row .gftec-field-time-group {
        flex: 1 1 100%;
    }

    .gftec-time-inputs {
        justify-content: flex-start;
    }

    .gftec-time-inputs input.gftec-time-hour,
    .gftec-time-inputs input.gftec-time-minute {
        width: 70px;
    }
}

/* Checkbox Fields - Matching GF Skeleton Custom Checkboxes */
.gftec-field-checkbox {
    margin-bottom: 12px;
}

.gftec-checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: normal;
    margin: 0;
}

.gftec-checkbox-label input[type="checkbox"] {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    min-width: 18px;
    max-width: 18px;
    flex: 0 0 18px;
    margin: 0;
    padding: 0;
    border: 1px solid var(--border-color);
    border-radius: 0 !important;
    background-color: var(--form-bg);
    box-shadow: none;
    cursor: pointer;
    position: relative;
    vertical-align: middle;
    transition: border-color 0.2s ease, background-color 0.2s ease;
}

.gftec-checkbox-label input[type="checkbox"]:hover {
    border-color: #b0b0b0;
}

.gftec-checkbox-label input[type="checkbox"]:focus {
    outline: transparent !important;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(249, 174, 51, 0.2);
}

.gftec-checkbox-label input[type="checkbox"]:checked {
    background-color: var(--accent-color);
    border-color: var(--accent-color);
}

.gftec-checkbox-label input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    left: 5px;
    top: 2px;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.gftec-checkbox-label span {
    font-size: 0.95rem;
    color: var(--text-color);
    line-height: 1.4;
}

.gftec-checkbox-group {
    background: var(--page-bg);
    padding: 15px 20px;
    border-left: 4px solid var(--border-color);
}

/* Current Image */
.gftec-current-image {
    max-width: 300px;
    margin-top: 10px;
}

.gftec-current-image img {
    max-width: 100%;
    height: auto;
    border: 1px solid var(--border-color);
}

/* Buttons - Matching GF Skeleton Submit Style */
.gftec-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 1em 2.5em;
    font-size: 1rem;
    font-family: 'Lato', sans-serif;
    font-weight: 700;
    text-transform: uppercase;
    line-height: 1.4em;
    text-decoration: none;
    border: none;
    border-radius: 0;
    cursor: pointer;
    transition: all ease 0.3s;
}

.gftec-button:focus {
    outline: transparent;
}

.gftec-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.gftec-button-primary {
    background-color: var(--bricks-color-vdcldn, var(--accent-color));
    color: var(--bricks-color-blhvyj, var(--heading-color));
}

.gftec-button-primary:hover:not(:disabled) {
    background-color: var(--bricks-color-zrbyki, #e09a1f);
}

.gftec-button-primary:focus:not(:disabled) {
    box-shadow: 0 0 0 3px rgba(249, 174, 51, 0.4);
}

.gftec-button-secondary {
    background-color: var(--page-bg);
    color: var(--text-color);
    border: 1px solid var(--border-color);
}

.gftec-button-secondary:hover:not(:disabled) {
    background-color: #e5e5e5;
    border-color: #b0b0b0;
}

.gftec-button-danger {
    background-color: var(--error-color);
    color: #fff;
}

.gftec-button-danger:hover:not(:disabled) {
    background-color: #d94543;
}

.gftec-button-danger:focus:not(:disabled) {
    box-shadow: 0 0 0 3px rgba(241, 92, 90, 0.4);
}

/* Button Loading State */
.gftec-button-loading {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.gftec-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(0, 0, 0, 0.2);
    border-radius: 50%;
    border-top-color: var(--heading-color);
    animation: gftec-spin 0.8s linear infinite;
}

.gftec-button-danger .gftec-spinner {
    border-color: rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
}

@keyframes gftec-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Actions - Matching GF gform_footer style */
.gftec-actions {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    margin-top: 2rem;
    padding-top: 0;
}

/* Modal */
.gftec-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gftec-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
}

.gftec-modal-content {
    position: relative;
    background: var(--form-bg);
    padding: 30px;
    max-width: 450px;
    width: 90%;
    z-index: 1;
    border-left: 4px solid var(--error-color);
}

.gftec-modal-content h3 {
    margin: 0 0 15px;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--error-color);
}

.gftec-modal-content p {
    margin: 0 0 20px;
    color: var(--text-light);
    font-size: 0.95rem;
}

.gftec-modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

/* Key Form */
.gftec-key-form-wrapper {
    text-align: center;
}

.gftec-key-form-wrapper h2 {
    margin-bottom: 10px;
    font-weight: 700;
    color: var(--heading-color);
}

.gftec-key-form-wrapper p {
    color: var(--text-light);
    margin-bottom: 25px;
}

.gftec-key-form-wrapper .gftec-field {
    text-align: left;
    max-width: 400px;
    margin: 0 auto 20px;
}

.gftec-key-form-wrapper .gftec-actions {
    justify-content: center;
    align-items: center;
}

.gftec-help-text {
    font-size: 0.85rem;
    color: var(--text-light);
    margin-top: 25px;
}

/* Error Wrapper */
.gftec-error-wrapper {
    text-align: center;
    border-left: 4px solid var(--error-color);
}

.gftec-error-wrapper h2 {
    color: var(--error-color);
}

/* Validation Error State on Fields */
.gftec-field.gftec-field-error label {
    color: var(--error-color);
}

.gftec-field.gftec-field-error input,
.gftec-field.gftec-field-error textarea,
.gftec-field.gftec-field-error select {
    border-color: var(--error-color) !important;
}

.gftec-field.gftec-field-error input:focus,
.gftec-field.gftec-field-error textarea:focus,
.gftec-field.gftec-field-error select:focus {
    box-shadow: 0 0 0 3px rgba(241, 92, 90, 0.2) !important;
}

.gftec-field-error-message {
    color: var(--error-color);
    font-size: 0.85rem;
    font-weight: normal;
    margin-top: 6px;
    padding: 0;
}

/* Responsive */
@media (max-width: 600px) {
    .gftec-form-header h2 {
        font-size: 22px;
    }

    .gftec-actions {
        flex-direction: column;
    }

    .gftec-button {
        width: 100%;
    }

    .gftec-modal-actions {
        flex-direction: column-reverse;
    }

    .gftec-modal-actions .gftec-button {
        width: 100%;
    }
}

/* Rich Text Editor - Matching Gravity Forms TinyMCE Style */
.gftec-field-richtext .ginput_container_textarea {
    width: 100%;
}

.gftec-field-richtext .wp-editor-wrap {
    max-width: 100%;
    width: 100%;
    border: 1px solid var(--border-color);
    background: var(--form-bg);
}

.gftec-field-richtext .wp-editor-tools {
    position: relative;
    background: var(--page-bg);
    border-bottom: 1px solid var(--border-color);
    padding: 0;
}

.gftec-field-richtext .wp-editor-tabs {
    display: none; /* Hide Visual/Text tabs like GF */
}

.gftec-field-richtext .wp-editor-container {
    border: none;
}

.gftec-field-richtext .mce-tinymce {
    box-shadow: none !important;
    border: none !important;
}

.gftec-field-richtext .mce-toolbar-grp {
    background: var(--page-bg) !important;
    border-bottom: 1px solid var(--border-color) !important;
    padding: 4px !important;
}

.gftec-field-richtext .mce-btn {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

.gftec-field-richtext .mce-btn:hover,
.gftec-field-richtext .mce-btn:focus {
    background: rgba(0, 0, 0, 0.05) !important;
}

.gftec-field-richtext .mce-btn.mce-active {
    background: rgba(249, 174, 51, 0.2) !important;
}

.gftec-field-richtext .mce-btn button {
    padding: 4px 6px !important;
}

.gftec-field-richtext .mce-ico {
    color: var(--text-color) !important;
}

.gftec-field-richtext .mce-edit-area {
    border: none !important;
    background: var(--form-bg);
}

.gftec-field-richtext .mce-edit-area iframe {
    min-height: 180px;
}

/* Focus state for TinyMCE iframe */
.gftec-field-richtext .wp-editor-iframe-active {
    outline: none;
}

.gftec-field-richtext .mce-edit-area:focus-within {
    box-shadow: inset 0 0 0 1px var(--accent-color);
}

.gftec-field-richtext .wp-editor-wrap:focus-within {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(249, 174, 51, 0.2);
}

/* TinyMCE Content Styles */
.gftec-field-richtext .mce-content-body {
    font-family: 'Lato', sans-serif;
    font-size: 1rem;
    line-height: 1.6;
    color: var(--text-color);
    padding: 12px;
}

.gftec-field-richtext .mce-content-body p {
    margin: 0 0 1em;
}

.gftec-field-richtext .mce-content-body p:last-child {
    margin-bottom: 0;
}

/* Status bar */
.gftec-field-richtext .mce-statusbar {
    display: none !important; /* Hide statusbar like GF */
}

/* Path row */
.gftec-field-richtext .mce-path {
    display: none !important;
}

/* Word count (if visible) */
.gftec-field-richtext .mce-wordcount {
    display: none !important;
}

/* Responsive */
@media (max-width: 600px) {
    .gftec-field-richtext .mce-toolbar .mce-btn-group {
        flex-wrap: wrap;
    }
}

/* Print styles */
@media print {
    .gftec-actions,
    .gftec-modal {
        display: none !important;
    }
}

/* ----- Staging workflow: open-staging banner on the edit page ----- */
.gftec-bio-staging-banner {
    background: #fff8e1;
    border-left: 4px solid #bf8700;
    padding: 12px 14px;
    margin: 0 0 18px;
    border-radius: 3px;
    color: #3b2f00;
}
.gftec-bio-staging-banner strong { display: block; margin-bottom: 2px; }
.gftec-bio-staging-banner .meta { color: #6b5a1a; font-size: 13px; }
.gftec-bio-staging-banner p { margin: 6px 0 0; font-size: 13px; line-height: 1.4; }

/* ----- Staging workflow: mark fields that differ from live ----- */
.gfield.gftec-bio-staged {
    background: #fff8e1;
    border-left: 3px solid #bf8700;
    padding-left: 10px;
    margin-left: -3px;
}
.gfield.gftec-bio-staged .gfield_label::after {
    content: '🟡';
    margin-left: 6px;
    font-size: 0.9em;
    vertical-align: middle;
}
