/**
 * Modern Form UI/UX v2 - Colorful, bold, premium feel
 * Apply to container: .default-form.cr-form-modern (or .cr-form-modern)
 */

/* Allow sticky sidebar: .boxed_wrapper has overflow:hidden which breaks position:sticky */
body.cr-has-form-sidebar .boxed_wrapper {
    overflow: visible !important;
}

/* Form pages banner: keep title compact so long admin text doesn’t dominate */
body.cr-has-form-sidebar .page-title {
    min-height: 800px;
    padding: 0;
    position: relative;
}
body.cr-has-form-sidebar .page-title .auto-container {
    width: 100%;
    position: relative;
    min-height: 800px;
}
body.cr-has-form-sidebar .page-title .content-box {
    position: relative;
    width: 100%;
    min-height: 800px;
}
body.cr-has-form-sidebar .page-title .title {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    margin: 0;
    padding: 0 1rem;
    text-align: center;
}
body.cr-has-form-sidebar .page-title .bread-crumb {
    position: absolute;
    bottom: 2rem;
    left: 0;
    text-align: left;
}
body.cr-has-form-sidebar .page-title .title h1 {
    font-size: 2.5rem;
    line-height: 1.35;
    font-weight: 700;
    color: #fff;
    width: 100%;
    margin: 0;
}

.cr-form-modern {
    --cr-primary: #0ea5e9;
    --cr-primary-dark: #0284c7;
    --cr-primary-light: #38bdf8;
    --cr-primary-glow: rgba(14, 165, 233, 0.35);
    --cr-accent: #a855f7;
    --cr-accent-soft: rgba(168, 85, 247, 0.18);
    --cr-coral: #f43f5e;
    --cr-coral-soft: rgba(244, 63, 94, 0.12);
    --cr-emerald: #10b981;
    --cr-emerald-soft: rgba(16, 185, 129, 0.15);
    --cr-amber: #f59e0b;
    --cr-success: #059669;
    --cr-success-soft: rgba(5, 150, 105, 0.15);
    --cr-error: #ef4444;
    --cr-error-soft: rgba(239, 68, 68, 0.12);
    --cr-slate: #1e293b;
    --cr-slate-mid: #475569;
    --cr-slate-light: #64748b;
    --cr-bg: #f1f5f9;
    --cr-bg-gradient: linear-gradient(165deg, #e0f2fe 0%, #f0f9ff 18%, #faf5ff 45%, #fdf2f8 70%, #fff7ed 88%, #fefce8 100%);
    --cr-card: #ffffff;
    --cr-border: #e2e8f0;
    --cr-border-focus: #0ea5e9;
    --cr-radius: 16px;
    --cr-radius-sm: 12px;
    --cr-radius-lg: 24px;
    --cr-radius-xl: 28px;
    --cr-shadow: 0 4px 20px rgba(0, 0, 0, 0.06), 0 1px 3px rgba(0, 0, 0, 0.04);
    --cr-shadow-lg: 0 25px 50px -12px rgba(0, 0, 0, 0.15), 0 12px 24px -8px rgba(14, 165, 233, 0.12);
    --cr-shadow-focus: 0 0 0 4px var(--cr-primary-glow);
    --cr-shadow-btn: 0 8px 24px rgba(14, 165, 233, 0.4);
    --cr-ease: cubic-bezier(0.34, 1.56, 0.64, 1);
    --cr-ease-out: cubic-bezier(0.22, 1, 0.36, 1);
    --cr-duration: 0.3s;
}

/* Section background - cream, no image */
.contact-style-two.sec-pad:has(.cr-form-modern) {
    position: relative;
    overflow: visible; /* allow sticky sidebar to work */
    background-color: #faf6f0;
}

.contact-style-two.sec-pad:has(.cr-form-modern) .auto-container {
    position: relative;
    z-index: 2;
}

/* Form card - glass-style with gradient border */
.cr-form-modern {
    max-width: 880px;
    margin-left: auto;
    margin-right: auto;
    padding: 2.75rem 2.5rem;
    background: var(--cr-card);
    border-radius: var(--cr-radius-lg);
    box-shadow: var(--cr-shadow);
    border: 1px solid var(--cr-border);
    position: relative;
    overflow: visible;
    animation: cr-form-enter 0.7s var(--cr-ease-out) both;
}

.cr-form-modern::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--cr-primary) 0%, var(--cr-accent) 50%, var(--cr-coral) 100%);
    border-radius: var(--cr-radius-lg) var(--cr-radius-lg) 0 0;
}

.cr-form-modern:hover {
    box-shadow: var(--cr-shadow-lg);
    transition: box-shadow 0.4s var(--cr-ease-out);
}

@keyframes cr-form-enter {
    from {
        opacity: 0;
        transform: translateY(28px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Staggered form groups */
.cr-form-modern .form-group {
    animation: cr-field-enter 0.55s var(--cr-ease-out) both;
    animation-delay: 0.05s;
}

@keyframes cr-field-enter {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Section headings - pill + gradient bar */
.cr-form-modern .cr-form-section {
    font-size: 1.0625rem;
    font-weight: 700;
    color: var(--cr-slate);
    margin-top: 2.25rem;
    margin-bottom: 1.125rem;
    padding: 0.6rem 1.25rem;
    padding-left: 1.25rem;
    background: linear-gradient(135deg, rgba(14, 165, 233, 0.08) 0%, rgba(168, 85, 247, 0.06) 100%);
    border-left: 4px solid var(--cr-primary);
    border-radius: 0 var(--cr-radius-sm) var(--cr-radius-sm) 0;
    letter-spacing: 0.02em;
    animation: cr-field-enter 0.55s var(--cr-ease-out) both;
}

.cr-form-modern .cr-form-section:first-of-type {
    margin-top: 1.75rem;
}

/* Labels */
.cr-form-modern .form-group label {
    display: block;
    font-weight: 600;
    color: var(--cr-slate);
    margin-bottom: 0.5rem;
    font-size: 0.9375rem;
    transition: color var(--cr-duration) var(--cr-ease);
}

/* Required asterisk stays on same line as label text */
.cr-form-modern .form-group label span.text-danger {
    color: var(--cr-error);
    font-weight: 700;
    display: inline;
}

/* Validation error message below input (not the asterisk) */
.cr-form-modern .form-group .text-danger.small {
    color: var(--cr-error) !important;
    font-size: 0.8125rem;
    margin-top: 0.4rem;
    display: block;
    font-weight: 500;
}

/* Inputs, selects, textareas - bolder focus, soft bg */
.cr-form-modern .form-control,
.cr-form-modern input[type="text"],
.cr-form-modern input[type="email"],
.cr-form-modern input[type="tel"],
.cr-form-modern input[type="number"],
.cr-form-modern input[type="date"],
.cr-form-modern input[type="file"],
.cr-form-modern select,
.cr-form-modern textarea {
    width: 100%;
    padding: 14px 18px;
    font-size: 1rem;
    line-height: 1.5;
    color: var(--cr-slate);
    background: #fefefe;
    border: 2px solid var(--cr-border);
    border-radius: var(--cr-radius-sm);
    transition: border-color var(--cr-duration) var(--cr-ease),
                box-shadow var(--cr-duration) var(--cr-ease),
                background var(--cr-duration) var(--cr-ease),
                transform 0.25s var(--cr-ease);
}

.cr-form-modern .form-control::placeholder,
.cr-form-modern input::placeholder,
.cr-form-modern textarea::placeholder {
    color: var(--cr-slate-light);
}

.cr-form-modern .form-control:hover,
.cr-form-modern input:not([type="file"]):hover,
.cr-form-modern select:hover,
.cr-form-modern textarea:hover {
    border-color: #cbd5e1;
    background: #fff;
}

.cr-form-modern .form-control:focus,
.cr-form-modern input:focus,
.cr-form-modern select:focus,
.cr-form-modern textarea:focus {
    border-color: var(--cr-primary);
    box-shadow: var(--cr-shadow-focus);
    outline: none;
    background: #fff;
    transform: translateY(-1px);
}

.cr-form-modern .form-control:focus-visible,
.cr-form-modern input:focus-visible,
.cr-form-modern select:focus-visible,
.cr-form-modern textarea:focus-visible {
    box-shadow: var(--cr-shadow-focus), 0 0 0 1px var(--cr-primary);
}

/* Error state */
.cr-form-modern .form-group.has-error .form-control,
.cr-form-modern .form-group.has-error input,
.cr-form-modern .form-group.has-error select,
.cr-form-modern .form-group.has-error textarea {
    border-color: var(--cr-error);
    background: var(--cr-error-soft);
    animation: cr-shake 0.5s var(--cr-ease);
}

@keyframes cr-shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-8px); }
    40% { transform: translateX(8px); }
    60% { transform: translateX(-5px); }
    80% { transform: translateX(5px); }
}

/* File inputs - colorful drop zone */
.cr-form-modern input[type="file"].form-control {
    padding: 28px 20px;
    border: 2px dashed var(--cr-border);
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
    cursor: pointer;
    min-height: 64px;
    font-size: 0.9375rem;
    color: var(--cr-slate-mid);
}

.cr-form-modern input[type="file"].form-control:hover {
    border-color: var(--cr-primary);
    background: linear-gradient(180deg, rgba(14, 165, 233, 0.06) 0%, rgba(168, 85, 247, 0.04) 100%);
    color: var(--cr-primary-dark);
}

.cr-form-modern input[type="file"].form-control:focus {
    border-style: solid;
    border-color: var(--cr-primary);
}

/* Select - custom arrow + focus; ensure dropdown is on top (native + nice-select) */
.cr-form-modern select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    padding-right: 48px;
}

/* When a dropdown is open, raise its form-group so the list appears above following fields */
.cr-form-modern .form-group:has(.nice-select.open) {
    position: relative;
    z-index: 9998;
}

.cr-form-modern .nice-select {
    position: relative;
    z-index: 1;
}

.cr-form-modern .nice-select.open {
    z-index: 9999;
}

.cr-form-modern .nice-select .list {
    z-index: 10000 !important;
    position: absolute !important;
}

/* Textarea */
.cr-form-modern textarea.form-control {
    min-height: 110px;
    resize: vertical;
}

/* Submit button - gradient, glow, hover lift */
.cr-form-modern .theme-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 18px 40px;
    font-size: 1rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #fff;
    background: linear-gradient(135deg, var(--cr-primary) 0%, var(--cr-primary-dark) 40%, var(--cr-accent) 100%);
    background-size: 200% 200%;
    border: none;
    border-radius: var(--cr-radius-sm);
    cursor: pointer;
    box-shadow: var(--cr-shadow-btn);
    transition: transform var(--cr-duration) var(--cr-ease),
                box-shadow var(--cr-duration) var(--cr-ease),
                background-position 0.5s var(--cr-ease);
    overflow: hidden;
    animation: cr-field-enter 0.55s var(--cr-ease-out) 0.35s both;
}

.cr-form-modern .theme-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.25) 0%, rgba(255,255,255,0) 50%);
    opacity: 0;
    transition: opacity var(--cr-duration) var(--cr-ease);
}

.cr-form-modern .theme-btn:hover {
    transform: translateY(-4px);
    box-shadow: 0 14px 32px rgba(14, 165, 233, 0.45), 0 0 0 1px rgba(255,255,255,0.1) inset;
    background-position: 100% 50%;
}

.cr-form-modern .theme-btn:hover::before {
    opacity: 1;
}

.cr-form-modern .theme-btn:active {
    transform: translateY(-2px);
}

/* Alerts - bolder and friendlier */
.auto-container > .alert,
.cr-form-modern .alert {
    border: none;
    border-radius: var(--cr-radius);
    padding: 1.125rem 1.5rem;
    font-weight: 500;
    box-shadow: var(--cr-shadow);
    animation: cr-slide-in 0.45s var(--cr-ease-out);
}

@keyframes cr-slide-in {
    from {
        opacity: 0;
        transform: translateY(-12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.auto-container > .alert-success,
.cr-form-modern .alert-success {
    background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
    color: #065f46;
    border-left: 4px solid var(--cr-success);
}

.auto-container > .alert-danger,
.cr-form-modern .alert-danger {
    background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
    color: #991b1b;
    border-left: 4px solid var(--cr-error);
}

/* Row spacing */
.cr-form-modern .row {
    margin-left: -0.5rem;
    margin-right: -0.5rem;
}

.cr-form-modern .row [class*="col-"] {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
}

.cr-form-modern .row .form-group {
    margin-bottom: 1rem;
}

/* Page subtitle / intro above form */
.contact-style-two .sec-title.centred {
    animation: cr-form-enter 0.6s var(--cr-ease-out) both;
}

.contact-style-two .sec-title.centred p.text-muted {
    font-size: 1.0625rem;
    color: var(--cr-slate-mid);
}

/* Optional badge above form - add class cr-form-badge to a <p> or <span> */
.cr-form-badge {
    display: inline-block;
    margin-bottom: 1rem;
    padding: 0.5rem 1rem;
    font-size: 0.8125rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--cr-primary-dark);
    background: linear-gradient(135deg, rgba(14, 165, 233, 0.12) 0%, rgba(168, 85, 247, 0.08) 100%);
    border-radius: 50px;
    border: 1px solid rgba(14, 165, 233, 0.2);
    animation: cr-field-enter 0.5s var(--cr-ease-out) 0.2s both;
}

/* Wide form (contact) */
.cr-form-modern.cr-form-wide {
    max-width: 1040px;
}

/* ========== Mobile responsive ========== */

/* Tablet and below: banner height and title */
@media (max-width: 991px) {
    body.cr-has-form-sidebar .page-title,
    body.cr-has-form-sidebar .page-title .auto-container,
    body.cr-has-form-sidebar .page-title .content-box {
        min-height: 420px;
    }
    body.cr-has-form-sidebar .page-title .title h1 {
        font-size: 1.875rem;
    }
    body.cr-has-form-sidebar .page-title .bread-crumb {
        bottom: 1.25rem;
        font-size: 0.875rem;
    }
}

/* Mobile: compact banner and form */
@media (max-width: 768px) {
    body.cr-has-form-sidebar .page-title,
    body.cr-has-form-sidebar .page-title .auto-container,
    body.cr-has-form-sidebar .page-title .content-box {
        min-height: 320px;
    }
    body.cr-has-form-sidebar .page-title .title {
        padding: 0 1rem;
    }
    body.cr-has-form-sidebar .page-title .title h1 {
        font-size: 1.5rem;
        line-height: 1.4;
    }
    body.cr-has-form-sidebar .page-title .bread-crumb {
        bottom: 1rem;
        left: 0;
        font-size: 0.8125rem;
        padding-right: 1rem;
    }
    .contact-style-two.sec-pad:has(.cr-form-modern) .auto-container {
        padding-left: 15px;
        padding-right: 15px;
    }
    .contact-style-two.sec-pad:has(.cr-form-modern) .row {
        margin-left: -0.5rem;
        margin-right: -0.5rem;
    }
    .contact-style-two.sec-pad:has(.cr-form-modern) .row [class*="col-"] {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
        max-width: 100%;
        flex: 0 0 100%;
    }
    .cr-form-modern {
        padding: 1.5rem 1.25rem;
        margin-left: 0;
        margin-right: 0;
        border-radius: var(--cr-radius);
    }
    .cr-form-modern::before {
        border-radius: var(--cr-radius) var(--cr-radius) 0 0;
    }
    .cr-form-modern .cr-form-section {
        margin-top: 1.75rem;
        margin-bottom: 0.875rem;
        font-size: 1rem;
        padding: 0.5rem 1rem;
    }
    .cr-form-modern .form-group label {
        font-size: 0.9375rem;
    }
    .cr-form-modern .theme-btn {
        width: 100%;
        padding: 1rem 1.5rem;
        font-size: 1rem;
        min-height: 48px;
    }
    .cr-form-modern input[type="text"],
    .cr-form-modern input[type="email"],
    .cr-form-modern input[type="tel"],
    .cr-form-modern input[type="number"],
    .cr-form-modern input[type="file"],
    .cr-form-modern textarea,
    .cr-form-modern select {
        min-height: 48px;
        font-size: 16px; /* prevents zoom on focus in iOS */
    }
    .cr-form-modern textarea {
        min-height: 100px;
    }
    .auto-container > .alert,
    .cr-form-modern .alert {
        padding: 1rem 1.25rem;
        font-size: 0.9375rem;
    }
}

/* Small phones */
@media (max-width: 576px) {
    body.cr-has-form-sidebar .page-title,
    body.cr-has-form-sidebar .page-title .auto-container,
    body.cr-has-form-sidebar .page-title .content-box {
        min-height: 260px;
    }
    body.cr-has-form-sidebar .page-title .title h1 {
        font-size: 1.25rem;
    }
    body.cr-has-form-sidebar .page-title .title {
        padding: 0 0.75rem;
    }
    body.cr-has-form-sidebar .page-title .bread-crumb {
        bottom: 0.75rem;
        font-size: 0.75rem;
    }
    .contact-style-two.sec-pad:has(.cr-form-modern) .auto-container {
        padding-left: 12px;
        padding-right: 12px;
    }
    .cr-form-modern {
        padding: 1.25rem 1rem;
    }
    .cr-form-modern .row {
        margin-left: -0.35rem;
        margin-right: -0.35rem;
    }
    .cr-form-modern .row [class*="col-"] {
        padding-left: 0.35rem;
        padding-right: 0.35rem;
    }
}

/* Extra small: minimal padding, keep touch targets */
@media (max-width: 380px) {
    body.cr-has-form-sidebar .page-title .title h1 {
        font-size: 1.125rem;
    }
    .contact-style-two.sec-pad:has(.cr-form-modern) .auto-container {
        padding-left: 10px;
        padding-right: 10px;
    }
    .cr-form-modern {
        padding: 1rem 0.75rem;
    }
}
