/**
 * Classmates Core — Frontend Styles
 *
 * Brand Colors:
 *   Teal:   #00687b
 *   Cream:  #f5f1ee
 *   Yellow: #FFF900 (TOS links)
 *
 * The form wrapper is structural only — background, padding,
 * border-radius are controlled by Elementor.
 *
 * Themes:
 *   .cm-theme--light   (dark text, teal button)
 *   .cm-theme--dark    (white text, cream button)
 *   .cm-theme--minimal (inherit from Elementor)
 *
 * @version 2.1.0
 */

/* ════════════════════════════════════════════════════════════════════
   RESET & BASE STRUCTURE
   ════════════════════════════════════════════════════════════════════ */

.cm-form-wrapper {
    font-family: inherit;
    line-height: 1.5;
    box-sizing: border-box;
    max-width: 520px;
    margin: 0 auto;
}

.cm-form-wrapper *,
.cm-form-wrapper *::before,
.cm-form-wrapper *::after {
    box-sizing: border-box;
}

.cm-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* ════════════════════════════════════════════════════════════════════
   SECTION HEADING
   ════════════════════════════════════════════════════════════════════ */

.cm-form-heading {
    text-align: center;
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0 0 24px 0;
    padding: 0;
    line-height: 1.3;
}

/* ════════════════════════════════════════════════════════════════════
   FIELD GROUPS
   ════════════════════════════════════════════════════════════════════ */

.cm-field-group {
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* ════════════════════════════════════════════════════════════════════
   INPUTS & SELECT
   ════════════════════════════════════════════════════════════════════ */

.cm-input {
    width: 100%;
    padding: 14px 16px;
    font-size: 1rem;
    font-family: inherit;
    border: 1px solid transparent;
    border-radius: 0;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    -webkit-appearance: none;
    appearance: none;
}

.cm-input:focus {
    border-color: #00687b;
    box-shadow: 0 0 0 2px rgba(0, 104, 123, 0.2);
}

.cm-input--selected {
    border-color: #00687b !important;
}

.cm-select {
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2300687b' d='M1.41 0L6 4.58 10.59 0 12 1.41l-6 6-6-6z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    padding-right: 44px;
    height: auto;
    line-height: 1.5;
    padding-top: 8px;
    padding-bottom: 8px;
}

/* ════════════════════════════════════════════════════════════════════
   TYPEAHEAD DROPDOWN
   ════════════════════════════════════════════════════════════════════ */

.cm-typeahead-wrapper {
    position: relative;
}

.cm-typeahead-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1000;
    max-height: 260px;
    overflow-y: auto;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    background-color: #fff;
    border: 1px solid #e0dcd8;
    border-top: none;
}

.cm-typeahead-item {
    padding: 12px 16px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 2px;
    transition: background-color 0.15s ease;
}

.cm-typeahead-item:hover,
.cm-typeahead-item:focus {
    background-color: #f5f1ee;
}

.cm-typeahead-item:focus {
    outline: 2px solid #00687b;
    outline-offset: -2px;
}

.cm-school-name {
    font-weight: 600;
    font-size: 0.92rem;
    color: #1a202c;
}

.cm-school-location {
    font-size: 0.8rem;
    color: #888;
}

.cm-typeahead-empty {
    cursor: default;
    font-style: italic;
    color: #888;
    padding: 14px 16px;
    text-align: center;
}

/* ════════════════════════════════════════════════════════════════════
   SCHOOL SEARCH HINT ("Please enter 3 or more characters")
   ════════════════════════════════════════════════════════════════════ */

.cm-school-hint {
    font-size: 0.82rem;
    padding: 6px 4px 0 4px;
    line-height: 1.3;
}

/* ════════════════════════════════════════════════════════════════════
   REQUIRED NOTE & TERMS OF SERVICE
   ════════════════════════════════════════════════════════════════════ */

.cm-required-note {
    font-size: 0.85rem;
    font-weight: 600;
    margin: 4px 0 0 0;
}

.cm-required-asterisk {
    color: #e07c4e;
}

.cm-tos-text {
    font-size: 0.85rem;
    line-height: 1.5;
    margin: 0;
}

.cm-tos-link {
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 2px;
    color: #FFF900;
}

/* ════════════════════════════════════════════════════════════════════
   SUBMIT BUTTON
   ════════════════════════════════════════════════════════════════════ */

.cm-submit-group {
    margin-top: 8px;
}

.cm-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 16px 24px;
    font-size: 1.1rem;
    font-weight: 700;
    font-family: inherit;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease, opacity 0.2s ease;
    letter-spacing: 0.01em;
}

.cm-button:hover:not(:disabled) {
    transform: translateY(-1px);
}

.cm-button:active:not(:disabled) {
    transform: translateY(0);
}

.cm-button:disabled {
    cursor: not-allowed;
    opacity: 0.65;
}

.cm-button--loading {
    pointer-events: none;
}

.cm-button-loading {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.cm-spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: cm-spin 0.6s linear infinite;
}

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

/* ════════════════════════════════════════════════════════════════════
   TWO-STEP FORM: Progress Bar
   ════════════════════════════════════════════════════════════════════ */

.cm-progress-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    margin-bottom: 24px;
}

.cm-progress-step {
    display: flex;
    align-items: center;
    gap: 8px;
    opacity: 0.4;
    transition: opacity 0.3s ease;
}

.cm-progress-step--active {
    opacity: 1;
}

.cm-progress-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-size: 0.85rem;
    font-weight: 700;
    flex-shrink: 0;
}

.cm-progress-label {
    font-size: 0.85rem;
    font-weight: 600;
}

.cm-progress-divider {
    width: 40px;
    height: 2px;
    margin: 0 12px;
    opacity: 0.3;
}

/* Progress bar theme colors */
.cm-theme--dark .cm-progress-number {
    background-color: rgba(255, 255, 255, 0.2);
    color: #fff;
}

.cm-theme--dark .cm-progress-step--active .cm-progress-number {
    background-color: #fff;
    color: #00687b;
}

.cm-theme--dark .cm-progress-label {
    color: #fff;
}

.cm-theme--dark .cm-progress-divider {
    background-color: #fff;
}

.cm-theme--light .cm-progress-number {
    background-color: rgba(0, 104, 123, 0.15);
    color: #00687b;
}

.cm-theme--light .cm-progress-step--active .cm-progress-number {
    background-color: #00687b;
    color: #fff;
}

.cm-theme--light .cm-progress-label {
    color: #00687b;
}

.cm-theme--light .cm-progress-divider {
    background-color: #00687b;
}

/* ════════════════════════════════════════════════════════════════════
   TWO-STEP FORM: Steps & Buttons
   ════════════════════════════════════════════════════════════════════ */

.cm-step {
    display: none;
}

.cm-step--active {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Ensure step 2 inputs match the full form exactly */
.cm-step .cm-input {
    width: 100%;
    padding: 14px 16px;
    font-size: 1rem;
    font-family: inherit;
    border: 1px solid transparent;
    border-radius: 0;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.cm-theme--dark .cm-step .cm-input {
    background-color: #fff;
    border-color: #fff;
    color: #1a202c;
}

.cm-theme--light .cm-step .cm-input {
    background-color: #fff;
    border-color: #e0dcd8;
    color: #1a202c;
}

/* ════════════════════════════════════════════════════════════════════
   TWO-STEP FORM: Back Link
   ════════════════════════════════════════════════════════════════════ */

.cm-back-link-wrapper {
    text-align: center;
    margin-top: 4px;
}

.cm-back-link {
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 2px;
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.cm-back-link:hover {
    opacity: 0.7;
}

.cm-theme--dark .cm-back-link {
    color: rgba(255, 255, 255, 0.8);
}

.cm-theme--dark .cm-back-link:hover {
    color: #fff;
}

.cm-theme--light .cm-back-link {
    color: #00687b;
}

.cm-theme--light .cm-back-link:hover {
    color: #005466;
}

/* ════════════════════════════════════════════════════════════════════
   FORM MESSAGE (Error / Success)
   ════════════════════════════════════════════════════════════════════ */

.cm-form-message {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.92rem;
    font-weight: 500;
    margin-bottom: 8px;
}

.cm-form-message--error {
    background-color: #fff5f5;
    color: #c53030;
    border: 1px solid #fed7d7;
}

.cm-form-message--success {
    background-color: #f0fff4;
    color: #276749;
    border: 1px solid #c6f6d5;
}


/* ════════════════════════════════════════════════════════════════════
   THEME: LIGHT
   ════════════════════════════════════════════════════════════════════ */

.cm-theme--light {
    /* Background handled by Elementor */
}

.cm-theme--light .cm-form-heading {
    color: #00687b;
}

.cm-theme--light .cm-input {
    background-color: #fff;
    border-color: #e0dcd8;
    color: #1a202c;
}

.cm-theme--light .cm-input::placeholder {
    color: #a8a099;
}

.cm-theme--light .cm-input:focus {
    border-color: #00687b;
    background-color: #fff;
}

.cm-theme--light .cm-select {
    color: #a8a099;
}

.cm-theme--light .cm-select.cm-has-value {
    color: #1a202c;
}

.cm-theme--light .cm-school-hint {
    color: #666;
}

.cm-theme--light .cm-required-note {
    color: #e07c4e;
}

.cm-theme--light .cm-tos-text {
    color: #1a202c;
}

.cm-theme--light .cm-tos-link {
    color: #1a202c;
}

.cm-theme--light .cm-button-primary {
    background-color: #00687b;
    color: #fff;
}

.cm-theme--light .cm-button-primary:hover:not(:disabled) {
    background-color: #005466;
}


/* ════════════════════════════════════════════════════════════════════
   THEME: DARK
   ════════════════════════════════════════════════════════════════════ */

.cm-theme--dark {
    /* Background handled by Elementor */
}

.cm-theme--dark .cm-form-heading {
    color: #fff;
}

.cm-theme--dark .cm-input {
    background-color: #fff;
    border-color: #fff;
    color: #1a202c;
}

.cm-theme--dark .cm-input::placeholder {
    color: #a8a099;
}

.cm-theme--dark .cm-input:focus {
    border-color: #fff;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.3);
}

.cm-theme--dark .cm-select {
    color: #a8a099;
}

.cm-theme--dark .cm-select.cm-has-value {
    color: #1a202c;
}

.cm-theme--dark .cm-school-hint {
    color: rgba(255, 255, 255, 0.8);
}

.cm-theme--dark .cm-required-note {
    color: #e07c4e;
}

.cm-theme--dark .cm-tos-text {
    color: rgba(255, 255, 255, 0.85);
}

.cm-theme--dark .cm-tos-link {
    color: #FFF900;
}

.cm-theme--dark .cm-button-primary {
    background-color: #f5f1ee;
    color: #00687b;
}

.cm-theme--dark .cm-button-primary:hover:not(:disabled) {
    background-color: #ede8e3;
}

.cm-theme--dark .cm-form-message--error {
    background-color: rgba(197, 48, 48, 0.15);
    color: #fc8181;
    border-color: rgba(197, 48, 48, 0.3);
}

.cm-theme--dark .cm-form-message--success {
    background-color: rgba(39, 103, 73, 0.15);
    color: #68d391;
    border-color: rgba(39, 103, 73, 0.3);
}

.cm-theme--dark .cm-typeahead-dropdown {
    background-color: #fff;
    border-color: #e0dcd8;
}


/* ════════════════════════════════════════════════════════════════════
   THEME: MINIMAL
   ════════════════════════════════════════════════════════════════════ */

.cm-theme--minimal .cm-form-heading {
    color: inherit;
}

.cm-theme--minimal .cm-input {
    background-color: transparent;
    border: 1px solid currentColor;
    color: inherit;
    opacity: 0.85;
}

.cm-theme--minimal .cm-input:focus {
    opacity: 1;
}

.cm-theme--minimal .cm-typeahead-dropdown {
    background-color: inherit;
    border: 1px solid currentColor;
}

.cm-theme--minimal .cm-typeahead-item {
    color: inherit;
}

.cm-theme--minimal .cm-button-primary {
    background-color: currentColor;
}

.cm-theme--minimal .cm-tos-text {
    color: inherit;
}


/* ════════════════════════════════════════════════════════════════════
   THEME: BRIDGE
   Clean, light editorial style matching the Classmates bridge page.
   White form area, thin borders, dark text, navy/blue accents.
   ════════════════════════════════════════════════════════════════════ */

.cm-theme--bridge {
    /* Background handled by Elementor */
}

.cm-theme--bridge .cm-form-heading {
    color: #1a202c;
}

.cm-theme--bridge .cm-input {
    background-color: #fff;
    border: 1px solid #ccc;
    color: #1a202c;
    border-radius: 8px;
    padding: 12px 14px;
    font-size: 0.95rem;
}

.cm-theme--bridge .cm-input::placeholder {
    color: #999;
}

.cm-theme--bridge .cm-input:focus {
    border-color: #3B5998;
    box-shadow: 0 0 0 2px rgba(59, 89, 152, 0.15);
    background-color: #fff;
}

.cm-theme--bridge .cm-select {
    color: #999;
    border-radius: 8px;
}

.cm-theme--bridge .cm-select.cm-has-value {
    color: #1a202c;
}

.cm-theme--bridge .cm-school-hint {
    color: #666;
}

/* Typeahead dropdown — clean, table-like rows */
.cm-theme--bridge .cm-typeahead-dropdown {
    background-color: #fff;
    border: 1px solid #ccc;
    border-top: none;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.cm-theme--bridge .cm-typeahead-item {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    border-bottom: 1px solid #eee;
}

.cm-theme--bridge .cm-typeahead-item:last-child {
    border-bottom: none;
}

.cm-theme--bridge .cm-typeahead-item:hover,
.cm-theme--bridge .cm-typeahead-item:focus {
    background-color: #D2D2D2;
}

.cm-theme--bridge .cm-school-name {
    color: #1a202c;
    font-weight: 500;
    font-size: 0.9rem;
}

.cm-theme--bridge .cm-school-location {
    color: #666;
    font-size: 0.85rem;
    text-align: right;
    white-space: nowrap;
}

/* Progress bar */
.cm-theme--bridge .cm-progress-number {
    background-color: #e0e0e0;
    color: #666;
}

.cm-theme--bridge .cm-progress-step--active .cm-progress-number {
    background-color: #3b5998;
    color: #fff;
}

.cm-theme--bridge .cm-progress-label {
    color: #1a202c;
}

.cm-theme--bridge .cm-progress-divider {
    background-color: #ccc;
}

/* Required note & TOS */
.cm-theme--bridge .cm-required-note {
    color: #3B5998;
}

.cm-theme--bridge .cm-tos-text {
    color: #555;
    font-size: 0.8rem;
}

.cm-theme--bridge .cm-tos-link {
    color: #3B5998 !important;
    text-decoration: underline;
}

/* Buttons */
.cm-theme--bridge .cm-button-primary {
    background-color: #3B5998;
    color: #fff;
    border-radius: 8px;
}

.cm-theme--bridge .cm-button-primary:hover:not(:disabled) {
    background-color: #2d4a86;
    color: #fff;
}

/* Back link */
.cm-theme--bridge .cm-back-link {
    color: #3b5998;
}

.cm-theme--bridge .cm-step--active {
    gap: 16px !important;
}

.cm-theme--bridge .cm-step--active .cm-field-group {
    margin-bottom: 16px;
}

.cm-theme--bridge .cm-back-link:hover {
    color: #2d4a86;
}

/* Error/Success messages */
.cm-theme--bridge .cm-form-message--error {
    background-color: #fff5f5;
    color: #c53030;
    border: 1px solid #fed7d7;
}

.cm-theme--bridge .cm-form-message--success {
    background-color: #f0fff4;
    color: #276749;
    border: 1px solid #c6f6d5;
}


/* ════════════════════════════════════════════════════════════════════
   RESPONSIVE
   ════════════════════════════════════════════════════════════════════ */

@media ( max-width: 600px ) {
    .cm-form-heading {
        font-size: 1.3rem;
        margin-bottom: 20px;
    }

    .cm-input {
        padding: 13px 14px;
        font-size: 16px; /* Prevents iOS zoom on focus */
    }

    .cm-select {
        padding-top: 7px;
        padding-bottom: 7px;
    }

    .cm-button {
        padding: 15px 16px;
        font-size: 1rem;
    }

    .cm-tos-text {
        font-size: 0.8rem;
    }
}
