/**
 * Trusted Path Survey & Interview Shared Styles
 * Version: 1.1
 * Supports: Survey forms, Interview guides
 * Themes: developer (champion), engineering, compliance, cto, program, influencer
 */

/* ========================================================================
   CSS Variables & Theme Configuration
   ======================================================================== */

:root {
    /* Base palette */
    --tp-white: #FFFFFF;
    --tp-off-white: #F8F9FA;
    --tp-light-grey: #E9ECEF;
    --tp-medium-grey: #6C757D;
    --tp-dark-grey: #343A40;
    --tp-black: #212529;

    /* Brand colours */
    --tp-primary: #1B3A5C;
    --tp-accent: #E8792F;
    --tp-accent-hover: #D06A24;

    /* Status colours */
    --tp-success: #28A745;
    --tp-error: #D32F2F;
    --tp-warning: #FFC107;
    --tp-info: #17A2B8;

    /* Typography */
    --tp-font-body: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, 'Helvetica Neue', Arial, sans-serif;
    --tp-font-heading: 'Segoe UI Semibold', 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;

    /* Spacing */
    --tp-spacing-xs: 4px;
    --tp-spacing-sm: 8px;
    --tp-spacing-md: 16px;
    --tp-spacing-lg: 24px;
    --tp-spacing-xl: 32px;
    --tp-spacing-xxl: 48px;

    /* Borders */
    --tp-border-radius: 6px;
    --tp-border-colour: #DEE2E6;

    /* Shadows */
    --tp-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --tp-shadow-md: 0 4px 12px rgba(0, 0, 0, 0.10);
}

/* Persona theme overrides */
[data-survey-theme="developer"]  { --tp-primary: #1B3A5C; --tp-accent: #E8792F; }
[data-survey-theme="engineering"] { --tp-primary: #1A2744; --tp-accent: #2E86C1; }
[data-survey-theme="compliance"]  { --tp-primary: #5B1A2E; --tp-accent: #C0392B; }
[data-survey-theme="cto"]         { --tp-primary: #1C2833; --tp-accent: #27AE60; }
[data-survey-theme="program"]     { --tp-primary: #2C3E50; --tp-accent: #8E44AD; }
[data-survey-theme="influencer"]  { --tp-primary: #1A3636; --tp-accent: #16A085; }

/* ========================================================================
   Reset & Base
   ======================================================================== */

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--tp-font-body);
    color: var(--tp-black);
    background-color: var(--tp-off-white);
    line-height: 1.6;
    padding: var(--tp-spacing-lg) var(--tp-spacing-md);
}

/* ========================================================================
   Survey / Interview Container
   ======================================================================== */

.survey-container,
.interview-container {
    max-width: 800px;
    margin: 0 auto;
    background: var(--tp-white);
    border-radius: var(--tp-border-radius);
    box-shadow: var(--tp-shadow-md);
    overflow: hidden;
}

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

.survey-header,
.interview-header {
    background: var(--tp-primary);
    color: var(--tp-white);
    padding: var(--tp-spacing-xl) var(--tp-spacing-xl) var(--tp-spacing-lg);
    text-align: center;
}

.survey-header h1,
.interview-header h1 {
    font-family: var(--tp-font-heading);
    font-size: 1.1rem;
    letter-spacing: 3px;
    text-transform: uppercase;
    margin-bottom: var(--tp-spacing-sm);
    opacity: 0.9;
}

.survey-header h2,
.interview-header h2 {
    font-family: var(--tp-font-heading);
    font-size: 1.6rem;
    font-weight: 600;
    margin-bottom: var(--tp-spacing-xs);
}

.survey-header h3,
.interview-header h3 {
    font-size: 1rem;
    font-weight: 400;
    opacity: 0.85;
}

.interview-header .interview-meta {
    display: flex;
    justify-content: center;
    gap: var(--tp-spacing-lg);
    margin-top: var(--tp-spacing-md);
    font-size: 0.85rem;
    opacity: 0.8;
}

/* ========================================================================
   Form Body
   ======================================================================== */

.survey-form,
.interview-form {
    padding: var(--tp-spacing-lg) var(--tp-spacing-xl) var(--tp-spacing-xl);
}

/* ========================================================================
   Introduction
   ======================================================================== */

.introduction {
    background: var(--tp-off-white);
    border-left: 4px solid var(--tp-accent);
    padding: var(--tp-spacing-md) var(--tp-spacing-lg);
    margin-bottom: var(--tp-spacing-xl);
    border-radius: 0 var(--tp-border-radius) var(--tp-border-radius) 0;
}

.introduction p {
    font-size: 0.95rem;
    color: var(--tp-dark-grey);
    margin-bottom: var(--tp-spacing-sm);
}

.introduction p:last-child {
    margin-bottom: 0;
}

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

.section {
    margin-bottom: var(--tp-spacing-xl);
    padding-bottom: var(--tp-spacing-lg);
    border-bottom: 1px solid var(--tp-light-grey);
}

.section:last-of-type {
    border-bottom: none;
}

.section-title {
    font-family: var(--tp-font-heading);
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--tp-primary);
    margin-bottom: var(--tp-spacing-lg);
    padding-bottom: var(--tp-spacing-sm);
    border-bottom: 2px solid var(--tp-accent);
}

/* ========================================================================
   Interview Phase Headers (Interview-specific)
   ======================================================================== */

.phase-header {
    background: linear-gradient(135deg, var(--tp-primary), color-mix(in srgb, var(--tp-primary) 80%, var(--tp-accent)));
    color: var(--tp-white);
    padding: var(--tp-spacing-md) var(--tp-spacing-lg);
    margin: var(--tp-spacing-xl) calc(-1 * var(--tp-spacing-xl)) var(--tp-spacing-lg);
    font-family: var(--tp-font-heading);
}

.phase-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: var(--tp-spacing-xs);
}

.phase-header p {
    font-size: 0.85rem;
    opacity: 0.85;
    font-style: italic;
}

/* ========================================================================
   Interview Guide Elements
   ======================================================================== */

.interviewer-note {
    background: #FFF8E1;
    border-left: 4px solid var(--tp-warning);
    padding: var(--tp-spacing-sm) var(--tp-spacing-md);
    margin-bottom: var(--tp-spacing-md);
    border-radius: 0 var(--tp-border-radius) var(--tp-border-radius) 0;
    font-size: 0.88rem;
    color: var(--tp-dark-grey);
}

.interviewer-note strong {
    color: var(--tp-black);
}

.opening-question {
    background: color-mix(in srgb, var(--tp-accent) 8%, white);
    border-left: 4px solid var(--tp-accent);
    padding: var(--tp-spacing-md) var(--tp-spacing-lg);
    margin-bottom: var(--tp-spacing-lg);
    border-radius: 0 var(--tp-border-radius) var(--tp-border-radius) 0;
    font-style: italic;
    font-size: 1.05rem;
    color: var(--tp-dark-grey);
}

.probe-list {
    list-style: none;
    padding-left: var(--tp-spacing-md);
    margin-top: var(--tp-spacing-sm);
}

.probe-list li {
    position: relative;
    padding-left: var(--tp-spacing-lg);
    margin-bottom: var(--tp-spacing-sm);
    font-size: 0.9rem;
    color: var(--tp-medium-grey);
}

.probe-list li::before {
    content: '→';
    position: absolute;
    left: 0;
    color: var(--tp-accent);
    font-weight: 600;
}

.response-area {
    margin-top: var(--tp-spacing-sm);
}

.expected-patterns {
    background: var(--tp-off-white);
    border-radius: var(--tp-border-radius);
    padding: var(--tp-spacing-md);
    margin-top: var(--tp-spacing-sm);
    margin-bottom: var(--tp-spacing-md);
}

.expected-patterns summary {
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--tp-primary);
    user-select: none;
}

.expected-patterns ul {
    list-style: disc;
    padding-left: var(--tp-spacing-lg);
    margin-top: var(--tp-spacing-sm);
}

.expected-patterns li {
    font-size: 0.85rem;
    color: var(--tp-medium-grey);
    margin-bottom: var(--tp-spacing-xs);
}

/* ========================================================================
   Questions
   ======================================================================== */

.question {
    margin-bottom: var(--tp-spacing-lg);
}

.question-label {
    display: block;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--tp-black);
    margin-bottom: var(--tp-spacing-sm);
    line-height: 1.5;
}

.question-number {
    display: inline-block;
    min-width: 28px;
    color: var(--tp-accent);
    font-weight: 700;
}

.question-instruction {
    font-size: 0.85rem;
    color: var(--tp-medium-grey);
    font-style: italic;
    margin-bottom: var(--tp-spacing-sm);
}

.required-indicator {
    color: var(--tp-error);
    font-weight: 700;
}

/* ========================================================================
   Contact Fields
   ======================================================================== */

.contact-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--tp-spacing-md);
}

.contact-field {
    display: flex;
    flex-direction: column;
}

.contact-field label {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: var(--tp-spacing-xs);
    color: var(--tp-black);
}

/* ========================================================================
   Form Controls
   ======================================================================== */

.text-input,
textarea,
select {
    width: 100%;
    padding: 10px 14px;
    font-family: var(--tp-font-body);
    font-size: 0.9rem;
    border: 1px solid var(--tp-border-colour);
    border-radius: var(--tp-border-radius);
    background-color: var(--tp-white);
    color: var(--tp-black);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.text-input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--tp-accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--tp-accent) 15%, transparent);
}

.text-input.short,
select.short {
    max-width: 400px;
}

textarea {
    min-height: 100px;
    resize: vertical;
}

/* Other input (hidden by default) */
.other-input {
    display: none;
    margin-top: var(--tp-spacing-sm);
    width: 100%;
    max-width: 400px;
}

/* ========================================================================
   Options List (Radio / Checkbox)
   ======================================================================== */

.options-list {
    list-style: none;
    padding: 0;
}

.options-list li {
    margin-bottom: var(--tp-spacing-sm);
}

.options-list label {
    display: flex;
    align-items: flex-start;
    gap: var(--tp-spacing-sm);
    cursor: pointer;
    padding: var(--tp-spacing-sm) var(--tp-spacing-md);
    border-radius: var(--tp-border-radius);
    transition: background-color 0.15s ease;
    font-size: 0.9rem;
    line-height: 1.5;
}

.options-list label:hover {
    background-color: var(--tp-off-white);
}

.options-list input[type="radio"],
.options-list input[type="checkbox"] {
    margin-top: 3px;
    flex-shrink: 0;
    accent-color: var(--tp-accent);
}

/* ========================================================================
   Rating Table
   ======================================================================== */

.rating-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: var(--tp-spacing-sm);
    font-size: 0.88rem;
}

.rating-table th,
.rating-table td {
    padding: 10px 8px;
    text-align: center;
    border-bottom: 1px solid var(--tp-light-grey);
}

.rating-table th:first-child,
.rating-table td:first-child {
    text-align: left;
    width: 50%;
    padding-right: var(--tp-spacing-md);
}

.rating-table thead th {
    background: var(--tp-off-white);
    font-weight: 600;
    color: var(--tp-primary);
    font-size: 0.82rem;
    white-space: nowrap;
}

.rating-header {
    width: 10%;
    min-width: 36px;
}

.rating-table tbody tr:hover {
    background-color: color-mix(in srgb, var(--tp-accent) 4%, white);
}

.rating-table input[type="radio"] {
    accent-color: var(--tp-accent);
    cursor: pointer;
}

/* ========================================================================
   Observation Grid (Interview-specific)
   ======================================================================== */

.observation-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--tp-spacing-md);
    margin-bottom: var(--tp-spacing-lg);
}

.observation-card {
    border: 1px solid var(--tp-border-colour);
    border-radius: var(--tp-border-radius);
    padding: var(--tp-spacing-md);
}

.observation-card label {
    display: block;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--tp-primary);
    margin-bottom: var(--tp-spacing-sm);
}

.observation-card select {
    width: 100%;
}

/* ========================================================================
   GDPR Consent
   ======================================================================== */

.gdpr-consent {
    background: var(--tp-off-white);
    border-left: 4px solid var(--tp-primary);
    padding: var(--tp-spacing-md) var(--tp-spacing-lg);
    margin: var(--tp-spacing-xl) 0 var(--tp-spacing-lg);
    border-radius: 0 var(--tp-border-radius) var(--tp-border-radius) 0;
    transition: border-left-color 0.3s ease;
}

.gdpr-consent label {
    display: flex;
    align-items: flex-start;
    gap: var(--tp-spacing-sm);
    cursor: pointer;
    font-size: 0.9rem;
    line-height: 1.5;
}

.gdpr-consent input[type="checkbox"] {
    margin-top: 3px;
    flex-shrink: 0;
    accent-color: var(--tp-accent);
}

.gdpr-consent p {
    font-size: 0.82rem;
    color: var(--tp-medium-grey);
    margin-top: var(--tp-spacing-sm);
    padding-left: 24px;
}

.gdpr-consent a {
    color: var(--tp-accent);
    text-decoration: none;
}

.gdpr-consent a:hover {
    text-decoration: underline;
}

/* ========================================================================
   Submit Section
   ======================================================================== */

.submit-section {
    text-align: center;
    padding-top: var(--tp-spacing-lg);
}

.submit-btn {
    display: inline-block;
    padding: 14px 48px;
    font-family: var(--tp-font-heading);
    font-size: 1rem;
    font-weight: 600;
    color: var(--tp-white);
    background: var(--tp-accent);
    border: none;
    border-radius: var(--tp-border-radius);
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease, box-shadow 0.2s ease;
    box-shadow: var(--tp-shadow-sm);
}

.submit-btn:hover:not(:disabled) {
    background: var(--tp-accent-hover);
    box-shadow: var(--tp-shadow-md);
}

.submit-btn:active:not(:disabled) {
    transform: translateY(1px);
}

.submit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ========================================================================
   Submission Status
   ======================================================================== */

.submission-status {
    display: none;
    margin-top: var(--tp-spacing-md);
    padding: var(--tp-spacing-sm) var(--tp-spacing-md);
    border-radius: var(--tp-border-radius);
    font-size: 0.9rem;
    text-align: center;
}

.submission-status.loading {
    color: var(--tp-info);
    background: color-mix(in srgb, var(--tp-info) 10%, white);
    border: 1px solid color-mix(in srgb, var(--tp-info) 25%, white);
}

.submission-status.success {
    color: var(--tp-success);
    background: color-mix(in srgb, var(--tp-success) 10%, white);
    border: 1px solid color-mix(in srgb, var(--tp-success) 25%, white);
}

.submission-status.error {
    color: var(--tp-error);
    background: color-mix(in srgb, var(--tp-error) 10%, white);
    border: 1px solid color-mix(in srgb, var(--tp-error) 25%, white);
}

/* ========================================================================
   Thank You
   ======================================================================== */

.thank-you {
    display: none;
    text-align: center;
    padding: var(--tp-spacing-xl);
    margin-top: var(--tp-spacing-lg);
    background: color-mix(in srgb, var(--tp-success) 6%, white);
    border-radius: var(--tp-border-radius);
    border: 1px solid color-mix(in srgb, var(--tp-success) 20%, white);
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.thank-you.visible {
    opacity: 1;
    transform: translateY(0);
}

.thank-you p {
    margin-bottom: var(--tp-spacing-sm);
}

.thank-you p:last-child {
    margin-bottom: 0;
}

/* ========================================================================
   Error States
   ======================================================================== */

.has-error .text-input,
.has-error textarea,
.has-error select {
    border-color: var(--tp-error);
    box-shadow: 0 0 0 3px rgba(211, 47, 47, 0.12);
}

.has-error .options-list {
    border-left: 3px solid var(--tp-error);
    padding-left: var(--tp-spacing-sm);
}

.error-message {
    display: none;
    font-size: 0.82rem;
    color: var(--tp-error);
    margin-top: var(--tp-spacing-xs);
}

.has-error .error-message {
    display: block;
}

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

.survey-footer,
.interview-footer {
    text-align: center;
    padding: var(--tp-spacing-lg);
    background: var(--tp-off-white);
    border-top: 1px solid var(--tp-light-grey);
    font-size: 0.82rem;
    color: var(--tp-medium-grey);
}

.survey-footer a,
.interview-footer a {
    color: var(--tp-accent);
    text-decoration: none;
}

.survey-footer a:hover,
.interview-footer a:hover {
    text-decoration: underline;
}

.survey-footer p,
.interview-footer p {
    margin-bottom: var(--tp-spacing-xs);
}

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

@media (max-width: 768px) {
    body {
        padding: var(--tp-spacing-sm);
    }

    .survey-form,
    .interview-form {
        padding: var(--tp-spacing-md) var(--tp-spacing-md) var(--tp-spacing-lg);
    }

    .survey-header,
    .interview-header {
        padding: var(--tp-spacing-lg) var(--tp-spacing-md);
    }

    .contact-fields {
        grid-template-columns: 1fr;
    }

    .observation-grid {
        grid-template-columns: 1fr;
    }

    .phase-header {
        margin-left: calc(-1 * var(--tp-spacing-md));
        margin-right: calc(-1 * var(--tp-spacing-md));
        padding: var(--tp-spacing-md);
    }

    .rating-table {
        font-size: 0.82rem;
    }

    .rating-table th:first-child,
    .rating-table td:first-child {
        width: 40%;
    }
}

@media (max-width: 480px) {
    .rating-table {
        font-size: 0.78rem;
    }

    .submit-btn {
        width: 100%;
        padding: 14px 20px;
    }
}

/* ========================================================================
   Print Styles (for interview guides printed in the field)
   ======================================================================== */

@media print {
    body {
        background: white;
        padding: 0;
    }

    .survey-container,
    .interview-container {
        box-shadow: none;
        max-width: none;
    }

    .phase-header {
        margin-left: 0;
        margin-right: 0;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .submit-section,
    .submission-status {
        display: none !important;
    }

    .expected-patterns[open] {
        break-inside: avoid;
    }

    textarea {
        border: 1px solid #ccc;
        min-height: 80px;
    }
}
