@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');

/* ClientPilot Premium CSS variables */
.cp-form-wrapper {
    --cp-font: 'Poppins', sans-serif;
    --cp-primary: var(--cp-primary-color, #0B4EA2);
    --cp-accent: var(--cp-accent-color, #F4B400);
    --cp-dark: #1e293b;
    --cp-gray-light: #f8fafc;
    --cp-border: #e2e8f0;
    --cp-text-muted: #64748b;
    --cp-success: #10b981;
    --cp-danger: #ef4444;
    --cp-radius-lg: 16px;
    --cp-radius-md: 8px;
    --cp-shadow: 0 10px 30px -5px rgba(0,0,0,0.08);
    --cp-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    
    width: 100%;
    max-width: 800px;
    margin: 40px auto;
    font-family: var(--cp-font);
    box-sizing: border-box;
}

.cp-form-wrapper * {
    box-sizing: border-box;
}

/* Form Container Card */
.cp-form-card {
    background: #ffffff;
    border-radius: var(--cp-radius-lg);
    border: 1px solid var(--cp-border);
    box-shadow: var(--cp-shadow);
    padding: 40px;
    transition: var(--cp-transition);
}

.cp-form-card:hover {
    box-shadow: 0 20px 40px -10px rgba(0,0,0,0.12);
}

/* Form Header */
.cp-form-header {
    text-align: center;
    margin-bottom: 35px;
}

.cp-form-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--cp-dark);
    margin: 0 0 10px 0;
    background: linear-gradient(135deg, var(--cp-dark) 0%, var(--cp-primary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.cp-form-desc {
    font-size: 15px;
    color: var(--cp-text-muted);
    margin: 0;
    line-height: 1.6;
}

/* Fields Grid Layout */
.cp-form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
}

.cp-col-full {
    grid-column: span 2;
}

/* Form Group */
.cp-field-group {
    display: flex;
    flex-direction: column;
}

.cp-field-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--cp-dark);
    margin-bottom: 8px;
    display: inline-flex;
    align-items: center;
}

.cp-required {
    color: var(--cp-danger);
    margin-left: 4px;
    font-weight: bold;
}

/* Input Fields Styling */
.cp-form-wrapper input[type="text"],
.cp-form-wrapper input[type="email"],
.cp-form-wrapper input[type="tel"],
.cp-form-wrapper input[type="phone"],
.cp-form-wrapper input[type="number"],
.cp-form-wrapper input[type="password"],
.cp-form-wrapper select,
.cp-form-wrapper textarea {
    font-family: var(--cp-font) !important;
    font-size: 14px !important;
    color: var(--cp-dark) !important;
    padding: 12px 16px !important;
    border: 1.5px solid var(--cp-border) !important;
    border-radius: var(--cp-radius-md) !important;
    background-color: #ffffff !important;
    transition: var(--cp-transition) !important;
    outline: none !important;
    width: 100% !important;
    height: auto !important;
    box-shadow: none !important;
}

.cp-form-wrapper input:focus,
.cp-form-wrapper select:focus,
.cp-form-wrapper textarea:focus {
    border-color: var(--cp-primary) !important;
    box-shadow: 0 0 0 4px rgba(11, 78, 162, 0.1) !important;
}

.cp-form-grid select {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    background-size: 16px;
    padding-right: 40px;
    cursor: pointer;
}

/* Address Fields Sub-Grid */
.cp-address-group {
    background: var(--cp-gray-light);
    border: 1px dashed var(--cp-border);
    padding: 24px;
    border-radius: var(--cp-radius-lg);
    margin-top: 10px;
}

.cp-address-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 16px;
}

.cp-address-grid input[name="street"] {
    grid-column: span 6;
}

.cp-address-grid input[name="street_2"] {
    grid-column: span 6;
}

.cp-address-grid input[name="city"] {
    grid-column: span 2;
}

.cp-address-grid input[name="state"] {
    grid-column: span 2;
}

.cp-address-grid input[name="zip"] {
    grid-column: span 2;
}

@media(max-width: 576px) {
    .cp-address-grid input[name="city"],
    .cp-address-grid input[name="state"],
    .cp-address-grid input[name="zip"] {
        grid-column: span 6;
    }
}

/* Checkbox and Radio styling */
.cp-checkbox-list,
.cp-radio-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    background: var(--cp-gray-light);
    padding: 20px;
    border-radius: var(--cp-radius-md);
    border: 1px solid var(--cp-border);
}

.cp-checkbox-item,
.cp-radio-item {
    display: flex;
    align-items: center;
    position: relative;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--cp-dark);
    user-select: none;
}

.cp-checkbox-item input,
.cp-radio-item input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.cp-checkbox-box {
    height: 18px;
    width: 18px;
    background-color: #fff;
    border: 2px solid var(--cp-border);
    border-radius: 4px;
    margin-right: 10px;
    display: inline-block;
    position: relative;
    transition: var(--cp-transition);
}

.cp-checkbox-item input:checked ~ .cp-checkbox-box {
    background-color: var(--cp-primary);
    border-color: var(--cp-primary);
}

.cp-checkbox-box::after {
    content: "";
    position: absolute;
    display: none;
    left: 5px;
    top: 2px;
    width: 4px;
    height: 8px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.cp-checkbox-item input:checked ~ .cp-checkbox-box::after {
    display: block;
}

.cp-radio-dot {
    height: 18px;
    width: 18px;
    background-color: #fff;
    border: 2px solid var(--cp-border);
    border-radius: 50%;
    margin-right: 10px;
    display: inline-block;
    position: relative;
    transition: var(--cp-transition);
}

.cp-radio-item input:checked ~ .cp-radio-dot {
    border-color: var(--cp-primary);
}

.cp-radio-dot::after {
    content: "";
    position: absolute;
    display: none;
    top: 4px;
    left: 4px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--cp-primary);
}

.cp-radio-item input:checked ~ .cp-radio-dot::after {
    display: block;
}

/* File Upload Zone */
.cp-file-upload-zone {
    position: relative;
    border: 2.5px dashed var(--cp-border);
    border-radius: var(--cp-radius-lg);
    background-color: var(--cp-gray-light);
    padding: 30px;
    text-align: center;
    transition: var(--cp-transition);
    cursor: pointer;
}

.cp-file-upload-zone:hover,
.cp-file-upload-zone.cp-dragover {
    border-color: var(--cp-primary);
    background-color: rgba(11, 78, 162, 0.02);
}

.cp-file-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.cp-file-upload-prompt .dashicons-cloud-upload {
    font-size: 40px;
    width: 40px;
    height: 40px;
    color: var(--cp-text-muted);
    margin-bottom: 10px;
    transition: var(--cp-transition);
}

.cp-file-upload-zone:hover .dashicons-cloud-upload {
    color: var(--cp-primary);
    transform: translateY(-2px);
}

.cp-file-upload-prompt p {
    font-size: 14px;
    font-weight: 500;
    color: var(--cp-dark);
    margin: 0 0 5px 0;
}

.cp-file-limits {
    font-size: 12px;
    color: var(--cp-text-muted);
}

.cp-file-list {
    margin-top: 15px;
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.cp-file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #ffffff;
    border: 1px solid var(--cp-border);
    border-radius: var(--cp-radius-md);
    padding: 8px 12px;
    font-size: 13px;
    color: var(--cp-dark);
    z-index: 10;
}

.cp-file-item-name {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
}

.cp-file-item-remove {
    cursor: pointer;
    color: var(--cp-danger);
    transition: var(--cp-transition);
}

.cp-file-item-remove:hover {
    transform: scale(1.1);
}

/* Appointment Picker Layout */
.cp-calendar-section {
    margin-top: 40px;
    padding-top: 30px;
    border-top: 1.5px solid var(--cp-border);
}

.cp-section-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--cp-dark);
    margin: 0 0 5px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.cp-section-title .dashicons {
    font-size: 20px;
    width: 20px;
    height: 20px;
    color: var(--cp-primary);
}

.cp-section-desc {
    font-size: 14px;
    color: var(--cp-text-muted);
    margin: 0 0 25px 0;
}

.cp-calendar-grid {
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    gap: 30px;
}

@media(max-width: 768px) {
    .cp-form-grid,
    .cp-calendar-grid {
        grid-template-columns: 1fr;
    }
    .cp-col-full {
        grid-column: auto;
    }
}

/* Datepicker input */
.cp-datepicker-wrapper {
    position: relative;
}

.cp-datepicker-wrapper input {
    cursor: pointer !important;
    font-weight: 600;
    padding-right: 40px !important;
}

.cp-datepicker-wrapper .dashicons-calendar {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--cp-text-muted);
    pointer-events: none;
    font-size: 18px;
}

/* Slots Grid styling */
.cp-slots-grid {
    background: var(--cp-gray-light);
    border: 1.5px solid var(--cp-border);
    border-radius: var(--cp-radius-lg);
    padding: 24px;
    min-height: 120px;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-content: flex-start;
    justify-content: center;
}

.cp-slots-placeholder {
    color: var(--cp-text-muted);
    font-size: 13px;
    text-align: center;
    margin: auto;
}

.cp-slot-button {
    background: #ffffff;
    border: 1px solid var(--cp-border);
    border-radius: var(--cp-radius-md);
    padding: 10px 14px;
    font-size: 14px;
    font-weight: 600;
    color: var(--cp-dark);
    cursor: pointer;
    text-align: center;
    flex: 1 1 calc(33.3% - 10px);
    max-width: calc(33.3% - 10px);
    transition: var(--cp-transition);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    line-height: 1.2;
}

.cp-slot-button:hover {
    border-color: var(--cp-primary);
    color: var(--cp-primary);
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}

.cp-slot-button.cp-selected {
    background: var(--cp-primary);
    border-color: var(--cp-primary);
    color: #ffffff;
    box-shadow: 0 4px 10px rgba(11, 78, 162, 0.2);
}

.cp-slot-button.cp-selected .cp-slot-seats {
    background: rgba(255,255,255,0.25);
    color: #ffffff;
}

.cp-slot-button.cp-slot-unavailable {
    opacity: 0.5;
    cursor: not-allowed;
    background: #f1f5f9;
}

.cp-slot-time {
    font-size: 14px;
    font-weight: 700;
}

.cp-slot-seats {
    font-size: 11px;
    font-weight: 600;
    background: #eef2ff;
    color: #4f46e5;
    border-radius: 20px;
    padding: 1px 8px;
    white-space: nowrap;
    transition: var(--cp-transition);
}

.cp-slot-seats.cp-slot-seats-urgent {
    background: #fef2f2;
    color: #dc2626;
}

.cp-slot-seats.cp-slot-full {
    background: #f1f5f9;
    color: #94a3b8;
}

.cp-slots-loader {
    margin: auto;
    text-align: center;
}

/* Spinner */
.cp-spinner {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 3px solid rgba(11, 78, 162, 0.1);
    border-radius: 50%;
    border-top-color: var(--cp-primary);
    animation: cp-spin 1s ease-in-out infinite;
}

@keyframes cp-spin {
    to { transform: rotate(360deg); }
}

/* Footer & Actions */
.cp-form-footer {
    margin-top: 35px;
    text-align: center;
}

.cp-submit-button {
    background: linear-gradient(135deg, var(--cp-primary) 0%, var(--cp-dark) 100%) !important;
    color: #ffffff !important;
    border: none !important;
    border-radius: var(--cp-radius-md) !important;
    padding: 14px 40px !important;
    font-size: 16px !important;
    font-weight: 700 !important;
    cursor: pointer !important;
    transition: var(--cp-transition) !important;
    box-shadow: 0 6px 20px rgba(11, 78, 162, 0.25) !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 10px !important;
    width: auto !important;
    height: auto !important;
    line-height: normal !important;
    text-transform: none !important;
}

.cp-submit-button:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 10px 25px rgba(11, 78, 162, 0.35) !important;
    color: #ffffff !important;
}

.cp-submit-button-secondary {
    background: #64748b !important;
    box-shadow: none !important;
}

.cp-submit-button-secondary:hover {
    background: #475569 !important;
    box-shadow: 0 4px 10px rgba(71, 85, 105, 0.2) !important;
}

.cp-submit-button:active {
    transform: translateY(0);
}

.cp-submit-button .cp-spinner {
    width: 18px;
    height: 18px;
    border-width: 2px;
    border-color: rgba(255,255,255,0.2);
    border-top-color: #fff;
}

.cp-form-alert {
    margin-top: 15px;
    font-size: 14px;
    font-weight: 500;
    padding: 10px;
    border-radius: var(--cp-radius-md);
}

.cp-form-alert.cp-error {
    background-color: rgba(239, 68, 68, 0.08);
    border: 1px solid var(--cp-danger);
    color: var(--cp-danger);
}

/* Modals */
.cp-modal {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background-color: rgba(30, 41, 59, 0.55) !important;
    backdrop-filter: blur(4px) !important;
    display: none !important;
    align-items: center !important;
    justify-content: center !important;
    z-index: 999999999 !important;
    padding: 20px !important;
    box-sizing: border-box !important;
}

.cp-modal.cp-modal-show {
    display: flex !important;
}

.cp-modal-content {
    background: #ffffff;
    border-radius: var(--cp-radius-lg);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    border: 1px solid var(--cp-border);
    max-width: 500px;
    width: 100%;
    padding: 35px;
    text-align: center;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    z-index: 1000000;
}

.cp-success-icon {
    font-size: 50px;
    width: 50px;
    height: 50px;
    color: var(--cp-success);
    margin-bottom: 15px;
}

.cp-modal-header h3 {
    margin: 0;
    font-size: 22px;
    color: var(--cp-dark);
    font-weight: 700;
}

.cp-modal-body p {
    font-size: 14px;
    line-height: 1.6;
    color: var(--cp-text-muted);
}

.cp-req-id-display {
    background: var(--cp-gray-light);
    border: 1px solid var(--cp-border);
    border-radius: var(--cp-radius-md);
    padding: 12px;
    margin: 15px 0;
    font-size: 16px !important;
}

.cp-modal-body hr {
    border: 0;
    border-top: 1px solid var(--cp-border);
    margin: 20px 0;
}

.cp-modal-body h4 {
    margin: 0 0 10px 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--cp-dark);
}

.cp-modal-skip {
    margin: 15px 0 0 0 !important;
    font-size: 13px !important;
}

.cp-modal-skip a {
    color: var(--cp-text-muted);
    text-decoration: none;
    transition: var(--cp-transition);
}

.cp-modal-skip a:hover {
    color: var(--cp-dark);
    text-decoration: underline;
}

/* Password wrapper and visibility toggle */
.cp-password-wrapper {
    position: relative;
    width: 100%;
    display: block;
}

.cp-password-wrapper input {
    width: 100% !important;
    padding-right: 44px !important;
}

.cp-password-toggle {
    position: absolute !important;
    right: 12px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    background: none !important;
    border: none !important;
    padding: 0 !important;
    cursor: pointer !important;
    color: var(--cp-text-muted) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    z-index: 10 !important;
    box-shadow: none !important;
    height: auto !important;
    min-height: 0 !important;
    width: auto !important;
    transition: var(--cp-transition) !important;
}

.cp-password-toggle:hover {
    color: var(--cp-primary) !important;
}

.cp-password-toggle .dashicons {
    font-size: 20px;
    width: 20px;
    height: 20px;
}

.cp-read-only-input {
    background-color: var(--cp-gray-light) !important;
    border-color: var(--cp-border) !important;
    color: var(--cp-text-muted) !important;
    cursor: not-allowed !important;
}

/* Stacking context reset for modals inside parent containers */
body.cp-modal-open {
    overflow: hidden !important;
}

body.cp-modal-open .cp-form-wrapper {
    position: relative !important;
    z-index: 999999999 !important;
}

/* Layout overrides for assigned form pages to enforce full-width and hide sidebars */
body.cp-body-assigned-form h1.entry-title,
body.cp-body-assigned-form .entry-title,
body.cp-body-assigned-form .main-title-gradient,
body.cp-body-assigned-form .et_pb_title_container h1 {
    display: none !important;
}

body.cp-body-assigned-form #sidebar {
    display: none !important;
}

body.cp-body-assigned-form #left-area {
    width: 100% !important;
    float: none !important;
    border-right: none !important;
    padding-right: 0 !important;
}

/* Also for other standard theme wrapper elements */
body.cp-body-assigned-form #secondary,
body.cp-body-assigned-form .sidebar,
body.cp-body-assigned-form aside {
    display: none !important;
}

body.cp-body-assigned-form #primary,
body.cp-body-assigned-form .content-area {
    width: 100% !important;
    float: none !important;
    flex: 0 0 100% !important;
    max-width: 100% !important;
}

/* Hide Divi vertical container divider line pseudo-element */
body.cp-body-assigned-form #main-content .container:before {
    display: none !important;
    background: none !important;
    content: none !important;
}
