/* ============================================
   Modality Technology Partners - Onboarding Portal
   Theme matched to modality.ca
   ============================================ */

:root {
    --primary: #0076BD;
    --primary-dark: #005a91;
    --primary-light: #e6f2fa;
    --accent: #FF8D61;
    --accent-dark: #FF662B;
    --accent-light: #fff4ef;
    --text: #1F2029;
    --text-light: #6b7280;
    --text-muted: #9ca3af;
    --border: #e5e7eb;
    --border-focus: #7dbfe0;
    --bg: #f5f5f5;
    --white: #ffffff;
    --error: #dc2626;
    --error-light: #fef2f2;
    --success: #059669;
    --success-light: #ecfdf5;
    --warning: #d97706;
    --info: #0076BD;
    --info-light: #e6f2fa;
    --duo-green: #6bbf4e;
    --duo-bg: #f0faf0;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
    --radius: 8px;
    --radius-lg: 12px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Open Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(180deg, #e6f2fa 0%, #f5f5f5 35%, #f5f5f5 100%);
    background-attachment: fixed;
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* ============================================
   Login Page
   ============================================ */

.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1F2029 0%, #003d5c 50%, #0076BD 100%);
}

.login-container {
    width: 100%;
    max-width: 440px;
    padding: 20px;
}

.login-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 48px 40px;
    box-shadow: var(--shadow-lg);
    text-align: center;
    animation: cardEntrance 0.5s ease;
}

.login-logo {
    margin-bottom: 32px;
}

.logo-img {
    max-width: 280px;
    height: auto;
    margin-bottom: 16px;
}

.header-logo {
    height: 36px;
    width: auto;
}

.login-card h2 {
    font-family: 'Titillium Web', sans-serif;
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text);
}

.login-description {
    color: var(--text-light);
    margin-bottom: 32px;
    font-size: 15px;
}

.btn-microsoft {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 12px 32px;
    background: var(--white);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 15px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: var(--shadow-sm);
}

.btn-microsoft:hover {
    background: var(--bg);
    border-color: #d1d5db;
    box-shadow: var(--shadow);
}

.login-footer {
    margin-top: 24px;
    font-size: 13px;
    color: var(--text-muted);
}

/* ============================================
   App Header
   ============================================ */

.app-header {
    background: var(--white);
    border-bottom: 3px solid var(--primary);
    padding: 0 32px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.user-info {
    font-size: 14px;
    color: var(--text-light);
}

.btn-services {
    font-size: 13px;
    font-weight: 500;
    color: var(--primary);
    text-decoration: none;
    padding: 6px 12px;
    border-radius: var(--radius);
    transition: all 0.2s;
}

.btn-services:hover {
    background: var(--primary-light);
}

.btn-logout {
    font-size: 13px;
    color: var(--text-muted);
    text-decoration: none;
    padding: 6px 12px;
    border-radius: var(--radius);
    transition: all 0.2s;
}

.btn-logout:hover {
    background: var(--bg);
    color: var(--text);
}

/* ============================================
   Form Container
   ============================================ */

.form-container {
    max-width: 960px;
    margin: 0 auto;
    padding: 32px 20px 60px;
}

.form-header {
    margin-bottom: 32px;
}

.form-header h1 {
    font-family: 'Titillium Web', sans-serif;
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 8px;
}

.form-header p {
    color: var(--text-light);
    font-size: 15px;
}

.client-badge {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
    padding: 6px 16px;
    background: var(--primary-light);
    border-radius: 20px;
    font-size: 14px;
}

.badge-label {
    color: var(--text-light);
}

.badge-value {
    font-weight: 600;
    color: var(--primary);
}

/* Client logo (M365 org branding) — hidden until load event confirms a real image.
   Falls back to the "Organization:" label when the tenant has no branding set. */
.client-logo {
    max-height: 32px;
    max-width: 120px;
    object-fit: contain;
    display: none;
    border-radius: 3px;
}
.client-badge.has-logo .client-logo { display: inline-block; }
.client-badge.has-logo .badge-label { display: none; }

/* ============================================
   Form Sections
   ============================================ */

.form-section {
    background: var(--white);
    border: 1px solid var(--border);
    border-left: 4px solid var(--primary);
    border-radius: var(--radius-lg);
    padding: 28px 32px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
    position: relative;
}

/* When a picker inside this section is active, float the whole section above
   siblings so searchable dropdowns can overflow into the next section. Each
   section's page-reveal animation leaves a transform applied, creating its
   own stacking context — without this, later sections always paint on top. */
.form-section:focus-within {
    z-index: 10;
}

.section-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.section-number {
    width: 32px;
    height: 32px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    flex-shrink: 0;
}

.section-header h2 {
    font-family: 'Titillium Web', sans-serif;
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
}

/* ============================================
   Form Fields
   ============================================ */

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

.form-group label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 6px;
}

.required {
    color: var(--error);
}

.hint {
    font-weight: 400;
    color: var(--text-muted);
    font-size: 13px;
}

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="date"],
select,
textarea {
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 15px;
    font-family: inherit;
    color: var(--text);
    background: var(--white);
    transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.1);
}

textarea {
    resize: vertical;
}

/* Radio & Checkbox Groups */

.radio-group,
.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 4px;
}

.radio-option,
.checkbox-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 14px;
    font-weight: 400;
    transition: all 0.2s;
}

.radio-option:hover,
.checkbox-option:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.radio-option input,
.checkbox-option input {
    accent-color: var(--primary);
}

.radio-group-vertical {
    flex-direction: column;
}

.acknowledgment {
    background: var(--info-light);
    border: 1px solid #bfdbfe;
    padding: 14px 16px;
    border-radius: var(--radius);
    font-size: 14px;
    line-height: 1.5;
}

/* ============================================
   Searchable Dropdown
   ============================================ */

.searchable-select {
    position: relative;
}

.search-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 15px;
    font-family: inherit;
    color: var(--text);
    background: var(--white);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-input:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.1);
}

.search-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: min(50vh, 440px);
    overflow-y: auto;
    background: var(--white);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 50;
}

.search-option {
    display: flex;
    flex-direction: column;
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 1px solid var(--bg);
    transition: background 0.1s;
}

.search-option:hover {
    background: var(--primary-light);
}

.search-option.selected {
    background: var(--info-light);
}

.search-option .option-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
}

.search-option .option-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Conditional fields */
.conditional {
    animation: fadeIn 0.2s ease-in;
}

/* Only conditionals with multiple children span full width (e.g. quote section, software checklist).
   Simple single-field conditionals (e.g. mobile details) flow
   naturally in the grid beside their trigger. */
.form-grid > .conditional:not(.form-group) {
    grid-column: 1 / -1;
}

/* Toggle-pair: question + revealed field stay together as one unit.
   The revealed field appears indented directly below the toggle. */
.toggle-reveal {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes cardEntrance {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Info Banners */
.info-banner {
    display: flex;
    gap: 12px;
    padding: 14px 16px;
    background: var(--info-light);
    border: 1px solid #bfdbfe;
    border-radius: var(--radius);
    font-size: 14px;
}

.info-banner.info-duo {
    background: var(--duo-bg);
    border-color: #b6e2a8;
}

.info-icon {
    font-size: 20px;
    flex-shrink: 0;
}

/* ============================================
   Form Actions
   ============================================ */

.form-actions {
    text-align: center;
    padding: 20px 0;
}

.btn-submit {
    display: inline-block;
    padding: 14px 48px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    box-shadow: var(--shadow);
}

.btn-submit:hover {
    background: var(--accent-dark);
    box-shadow: var(--shadow-lg);
}

.btn-submit:disabled {
    background: var(--text-muted);
    cursor: not-allowed;
}

.btn-secondary {
    display: inline-block;
    padding: 14px 48px;
    background: var(--white);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    margin-left: 12px;
}

.btn-secondary:hover {
    background: var(--bg);
}

.submit-note {
    margin-top: 12px;
    font-size: 13px;
    color: var(--text-muted);
}

/* ============================================
   Success Page
   ============================================ */

.success-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 48px 40px;
    box-shadow: var(--shadow);
    text-align: center;
    max-width: 600px;
    margin: 0 auto;
    animation: cardEntrance 0.5s ease;
}

.success-icon {
    width: 72px;
    height: 72px;
    background: var(--accent-light);
    color: var(--accent);
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    margin-bottom: 20px;
}

.success-card h1 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
}

.success-message {
    font-size: 16px;
    color: var(--text-light);
    margin-bottom: 28px;
}

.success-details {
    background: var(--bg);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 28px;
    text-align: left;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

.detail-row:last-child {
    border-bottom: none;
}

.detail-label {
    font-weight: 500;
    color: var(--text-light);
}

.detail-value {
    font-weight: 600;
    color: var(--text);
}

.success-next-steps {
    text-align: left;
    margin-bottom: 28px;
}

.success-next-steps h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
}

.success-next-steps ol {
    padding-left: 24px;
    color: var(--text-light);
    font-size: 14px;
}

.success-next-steps li {
    margin-bottom: 8px;
}

.success-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

/* ============================================
   Error Page
   ============================================ */

.error-box {
    background: var(--error-light);
    border: 1px solid #fecaca;
    border-radius: var(--radius);
    padding: 16px 20px;
    margin: 20px 0;
    text-align: left;
    font-size: 14px;
    color: var(--error);
}

/* ============================================
   Footer
   ============================================ */

.app-footer {
    text-align: center;
    padding: 20px;
    font-size: 13px;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    margin-top: 40px;
}

/* ============================================
   Responsive
   ============================================ */

@media (max-width: 768px) {
    .form-grid {
        grid-template-columns: 1fr;
    }

    .form-section {
        padding: 20px;
    }

    .app-header {
        padding: 0 16px;
    }

    .form-header h1 {
        font-size: 22px;
    }

    .login-card {
        padding: 32px 24px;
    }

    .success-card {
        padding: 32px 24px;
    }

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

    .btn-secondary {
        margin-left: 0;
    }
}

/* ---- Device Details ---- */
.device-details {
    display: flex;
    gap: 12px;
    margin-top: 8px;
    padding: 8px 12px;
    background: var(--primary-light);
    border: 1px solid var(--border-focus);
    border-radius: 6px;
    font-size: 0.85rem;
    color: var(--text);
}
.device-details span {
    padding: 2px 8px;
    background: var(--white);
    border-radius: 4px;
    font-weight: 500;
}

/* ---- Email Validation Messages ---- */
.validation-message {
    font-size: 0.85rem;
    margin-top: 4px;
    padding: 4px 8px;
    border-radius: 4px;
}
.validation-message.checking {
    color: var(--text-light);
}
.validation-message.valid {
    color: var(--success);
    background: var(--success-light);
}
.validation-message.invalid {
    color: var(--error);
    background: var(--error-light);
}

/* ---- Option row: label + trailing chip (keeps option-label.textContent clean) ---- */
.search-option .option-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ---- Grouped search dropdown (e.g. tagged vs untagged devices) ---- */
.search-group-label {
    padding: 8px 14px 4px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    background: var(--bg);
    border-top: 1px solid var(--border);
    pointer-events: none;
}
.search-group-label:first-child {
    border-top: none;
}

/* ---- Device option: monospace tag column + device name + metadata row ---- */
.search-option.device-option {
    padding: 8px 14px;
}
.device-option .option-label {
    display: flex;
    align-items: baseline;
    gap: 12px;
}
.device-option .device-tag {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-weight: 700;
    color: var(--primary);
    min-width: 68px;
    flex-shrink: 0;
    letter-spacing: 0.02em;
}
.device-option .device-name {
    font-weight: 500;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.device-option.device-option-untagged .device-name {
    /* Indent to align with tagged devices' name column (68 + 12 = 80) */
    margin-left: 80px;
}
.device-option .option-hint {
    margin-left: 80px;
    margin-top: 1px;
}

/* Online/offline indicator dot */
.device-status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 4px;
    vertical-align: middle;
}
.device-status-dot.online { background: var(--success); }
.device-status-dot.offline { background: var(--text-muted); }

/* Footnote under picker */
.picker-footnote {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
    line-height: 1.4;
}

/* ---- Status Chips (inline badges inside dropdown options) ---- */
.status-chip {
    display: inline-block;
    margin-left: 8px;
    padding: 1px 8px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-radius: 10px;
    vertical-align: middle;
}
.status-chip-muted {
    background: #f3f4f6;
    color: var(--text-light);
    border: 1px solid var(--border);
}

/* ---- Info Notes (inline guidance, non-modal) ---- */
.info-note {
    font-size: 13px;
    padding: 10px 12px;
    border-radius: var(--radius);
    line-height: 1.4;
    margin-top: 6px;
}
.info-note-muted {
    background: #f9fafb;
    color: var(--text-light);
    border: 1px solid var(--border);
}
.info-note-block {
    background: var(--info-light);
    color: var(--text);
    border: 1px solid #bfdbfe;
    margin: 0 0 24px 0;
    padding: 14px 18px;
}

/* ---- Service Selector Cards ---- */
.service-cards {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 700px;
    margin: 0 auto;
}

.service-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px 24px;
    background: var(--white);
    border: 2px solid var(--border);
    border-radius: 12px;
    text-decoration: none;
    color: var(--text);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
    cursor: pointer;
}

.service-card:hover {
    border-color: var(--card-color, var(--primary));
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    transform: translateY(-1px);
}

.service-card-icon {
    flex-shrink: 0;
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: color-mix(in srgb, var(--card-color, var(--primary)) 10%, transparent);
    border-radius: 12px;
    color: var(--card-color, var(--primary));
}

.service-card-content {
    flex: 1;
    min-width: 0;
}

.service-card-content h3 {
    font-family: 'Titillium Web', sans-serif;
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0 0 4px 0;
    color: var(--text);
}

.service-card-content p {
    font-size: 0.9rem;
    color: var(--text-light);
    margin: 0;
}

.service-card-arrow {
    flex-shrink: 0;
    color: var(--text-light);
    transition: transform 0.2s ease, color 0.2s ease;
}

.service-card:hover .service-card-arrow {
    transform: translateX(3px);
    color: var(--card-color, var(--primary));
}

.service-card-disabled {
    opacity: 0.55;
    cursor: default;
    pointer-events: none;
}

.service-card-unavailable {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-style: italic;
}

@media (max-width: 600px) {
    .service-card {
        padding: 16px;
        gap: 12px;
    }
    .service-card-icon {
        width: 44px;
        height: 44px;
    }
    .service-card-icon svg {
        width: 24px;
        height: 24px;
    }
}
