/* Root variables with your colors */
:root {
    --primary-color: #177676; /* Main accents, buttons */
    --dark-color: #1f394c;    /* Backgrounds, hovers */
    --text-color: #718096;    /* Subtle text, borders */
    --bg-color: #ffffff;      /* White backgrounds */
    --border-color: #ddd;
    --high-risk-color: #ff0000; /* Brighter red for pop */
    --developing-color: #ff6600; /* Vibrant orange */
    --maturing-color: #ffcc00; /* Yellow */
    --high-color: #00cc00; /* Brighter green */
}

/* Fonts */
body .smartai-ip-modal * {
    font-family: 'Open Sans', sans-serif !important; /* Body text override for plugin only */
    color: var(--text-color);
}

.smartai-ip-modal h1, .smartai-ip-modal h2, .smartai-ip-modal h3, .section h2 {
    font-family: 'Montserrat', sans-serif !important;
    font-weight: 600;
}

/* Button */
.smartai-ip-launch-btn {
    background-color: var(--primary-color);
    color: white !important;
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 18px;
    transition: background-color 0.3s ease, transform 0.2s;
}

.smartai-ip-launch-btn:hover {
    background-color: var(--dark-color);
    transform: translateY(-2px);
}

/* Modal */
.smartai-ip-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000001; /* Ultra-high to override theme elements like floating images/nav */
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.smartai-ip-modal-content {
    background: var(--bg-color);
    padding: 30px;
    max-width: 900px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    border-radius: 12px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
    position: relative;
}

.smartai-ip-close {
    position: absolute;
    top: 15px;
    right: 15px;
    font-size: 20px; /* Smaller size */
    color: white !important; /* White 'x' with !important to override any potential conflicts */
    background-color: var(--primary-color); /* Primary color background for visibility */
    border-radius: 50%; /* Circular for button-like feel */
    width: 28px; /* Fixed size container */
    height: 28px; /* Fixed size container */
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.3s, transform 0.2s;
}

.smartai-ip-close:hover {
    background-color: var(--dark-color);
    color: white !important; /* Ensure white on hover too */
    transform: scale(1.1);
}

/* Logo - Smaller, top-left marker, no shadow */
.smartai-ip-logo {
    float: left;
    max-width: 200px; /* Smaller as reaffirming marker */
    height: auto;
    margin: 0 20px 20px 0; /* Spacing: right/bottom for flow around content */
    border-radius: 4px;
}

/* Form */
#smartai-ip-checklist-form {
    display: flex;
    flex-direction: column;
    clear: both; /* Ensure form starts below logo if wrapped */
}

.progress {
    text-align: center;
    font-size: 16px; /* Smaller for consistency */
    color: var(--primary-color);
    margin-bottom: 20px;
    font-weight: 600;
}

.user-details h2, .section h2 {
    font-size: 20px; /* Reduced for match with Company Details */
    color: var(--primary-color);
    margin-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 5px;
    transition: color 0.3s;
} 

.scoring-note {
    font-size: 12px; /* Small, non-invasive */
    color: #999; /* Gray for subtlety */
    font-style: italic;
    margin-bottom: 15px;
}

.user-details .user-row {
    display: flex;
    justify-content: space-between;
    gap: 30px; /* Increased spacing between fields */
    margin-bottom: 25px; /* More space between rows */
}

.user-details label {
    flex: 1; /* Equal width */
    font-size: 14px; /* Reduced size */
    font-weight: normal; /* Lighter for less emphasis */
    margin-bottom: 20px; /* Increased vertical padding between labels/inputs */
}

.user-details input,
.user-details select {
    width: 100%;
    height: 42px; /* Explicit height for equality (includes border/padding) */
    line-height: 1.5; /* Consistent text alignment */
    box-sizing: border-box; /* Ensure padding/border included in height */
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 14px; /* Reduced for consistency */
    font-family: 'Open Sans', sans-serif;
    margin-top: 5px; /* Space from label */
    background-color: var(--bg-color);
    transition: border-color 0.3s;
}

.user-details input:focus,
.user-details select:focus {
    border-color: var(--primary-color);
}

.user-details select {
    appearance: none; /* Remove default arrow for custom */
    background-image: url('data:image/svg+xml;utf8,<svg fill="currentColor" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M7 10l5 5 5-5z"/><path d="M0 0h24v24H0z" fill="none"/></svg>'); /* Custom arrow */
    background-repeat: no-repeat;
    background-position-x: calc(100% - 10px);
    background-position-y: center;
}

.section {
    margin-bottom: 20px;
}

.question-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
}

.question-table th, .question-table td {
    padding: 10px 15px; /* Reduced for smaller feel, added horizontal for spacing */
    text-align: left; /* Left align for question, center for others */
    border-bottom: 1px solid var(--border-color);
    font-size: 14px; /* Reduced for consistency */
    box-sizing: border-box;
    vertical-align: middle; /* Vertical center for radios */
}

.question-table th {
    background: var(--primary-color);
    color: white !important;
    font-weight: 600;
}

.question-table th:not(:first-child) {
    text-align: center; /* Center options (0,1,2) */
}

.question-table td:first-child {
    width: 70%; /* Wider for question text */
}

.question-table td:not(:first-child) {
    text-align: center; /* Center radios under options */
    width: 10%; /* Fixed width for 0/1/2 columns to align radios */
}

.question-table label {
    display: none; /* Hide labels on desktop */
}

.question input[type="radio"] {
    margin: 0;
    accent-color: var(--primary-color);
}

.navigation {
    display: flex;
    justify-content: space-between;
    margin-top: 20px;
}

.smartai-ip-modal .prev-btn, .smartai-ip-modal .next-btn {
    background: var(--primary-color) !important; /* More specific selector with !important to override theme */
    color: white !important;
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    transition: background 0.3s, transform 0.2s;
}

.smartai-ip-modal .prev-btn:hover, .smartai-ip-modal .next-btn:hover {
    background: var(--dark-color) !important;
    transform: translateY(-2px);
}

/* Results - New Garmin-Style with more polish */
#smartai-ip-results {
    margin-top: 20px;
    clear: both;
}

#smartai-ip-results h2 {
    font-size: 20px; /* Align to form headers */
}

#smartai-ip-results h3 {
    font-size: 20px; /* Match form h2 size */
    color: var(--primary-color);
    margin-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 5px;
    transition: color 0.3s;
}

#smartai-ip-results p, #smartai-ip-results li {
    font-size: 14px; /* Align to form body text */
    line-height: 1.6; /* Better readability */
}

.high-risk-low-readiness {
    color: var(--high-risk-color);
}

.developing-readiness {
    color: var(--developing-color);
}

.maturing-readiness {
    color: var(--maturing-color);
}

.high-readiness {
    color: var(--high-color);
}

.factors-header, .factor-item {
    transition: background 0.3s, box-shadow 0.3s;
}

.factors-header:hover, .factor-item:hover {
    box-shadow: 0 2px 6px rgba(23,118,118,0.15) !important;
}

.smartai-ip-modal .results-container .factors-list .factor-item {
    background: var(--primary-color) !important; /* Green when closed */
    transition: background-color 0.3s ease !important; /* Smooth background transition */
}

.smartai-ip-modal .results-container .factors-list .factor-item > div:first-child {
    color: white !important; /* Header wrapper white for inheritance */
    padding-right: 40px !important; /* Add space for icon to avoid overlap */
    transition: color 0.3s ease !important; /* Smooth color transition */
}

.smartai-ip-modal .results-container .factors-list .factor-item > div:first-child > div:first-child {
    color: white !important; /* Group div white for inheritance */
    transition: color 0.3s ease !important;
}

.smartai-ip-modal .results-container .factors-list .factor-item > div:first-child > div:first-child > div:first-child {
    color: white !important; /* Section name white */
    font-weight: 600 !important;
    transition: color 0.3s ease !important;
}

.smartai-ip-modal .results-container .factors-list .factor-item > div:first-child > div:first-child > div:nth-child(2) {
    color: white !important; /* Score white */
    font-weight: bold !important;
    transition: color 0.3s ease !important;
}

.smartai-ip-modal .results-container .factors-list .factor-item > div:first-child > div:last-child {
    color: white !important; /* Readiness level white when closed */
    transition: color 0.3s ease !important;
}

.smartai-ip-modal .results-container .factors-list .factor-item .factor-detail {
    background: #f9f9f9 !important; /* Light when open */
    color: var(--text-color) !important;
}

.smartai-ip-modal .results-container .factors-list .factor-item[aria-expanded="true"] {
    background: #f9f9f9 !important; /* Switch to light when open */
}

.smartai-ip-modal .results-container .factors-list .factor-item[aria-expanded="true"] > div:first-child {
    color: var(--text-color) !important; /* Header wrapper grey for inheritance */
    padding-right: 40px !important; /* Keep padding when open */
}

.smartai-ip-modal .results-container .factors-list .factor-item[aria-expanded="true"] > div:first-child > div:first-child {
    color: var(--text-color) !important; /* Group div grey for inheritance */
}

.smartai-ip-modal .results-container .factors-list .factor-item[aria-expanded="true"] > div:first-child > div:first-child > div:first-child {
    color: var(--text-color) !important; /* Section name grey when open */
    font-weight: 600 !important;
}

.smartai-ip-modal .results-container .factors-list .factor-item[aria-expanded="true"] > div:first-child > div:first-child > div:nth-child(2) {
    color: var(--text-color) !important; /* Score grey when open */
    font-weight: bold !important;
}

.smartai-ip-modal .results-container .factors-list .factor-item[aria-expanded="true"] > div:first-child > div:last-child {
    color: inherit !important; /* Readiness level color-coded when open */
}

.smartai-ip-modal .results-container .factors-list .factor-item span {
    right: 15px !important; /* Keep icon position, but ensure no overlap with padding */
    top: 20px !important; /* Slightly lower to center vertically if needed */
    transition: transform 0.3s ease; /* Smooth icon rotation */
}

.smartai-ip-modal .results-container .factors-list .factor-item[aria-expanded="true"] span {
    color: #177676 !important; /* Icon green when open */
    transform: rotate(180deg); /* Rotate icon for open state */
}

.factor-item > div:first-child {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    flex-wrap: nowrap !important; /* Prevent wrap to avoid overlap */
    gap: 10px; /* Space between elements */
    transition: color 0.3s ease !important; /* Additional transition for safety */
}

.factor-item > div:first-child > div:last-child {
    flex-shrink: 0; /* Prevent level text shrink/overlap */
    max-width: 50%; /* Cap to avoid pushing icon */
    text-align: right;
    word-break: break-word; /* Break long words if needed */
}

.factor-item span {
    position: absolute;
    color: white !important; /* White when closed, with !important to override */
    transition: color 0.3s ease, transform 0.3s ease;
}

.cta-button {
    background: var(--primary-color);
    color: white !important;
    padding: 12px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 18px;
    margin-top: 20px;
    transition: background 0.3s, transform 0.2s;
}

.cta-button:hover {
    background: var(--dark-color);
    transform: translateY(-2px);
}

/* Progress Bar Animation */
.progress-bar div {
    transition: width 1.5s ease-in-out;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .smartai-ip-modal-content {
        padding: 15px; /* Tighter for mobile */
        width: 95%;
    }

    .smartai-ip-logo {
        float: none;
        max-width: 150px; /* Even smaller on mobile */
        margin: 0 auto 20px auto; /* Centered */
        display: block;
    }

    .user-details .user-row {
        flex-direction: column; /* Stack fields on small screens */
        gap: 15px; /* Tighter gap */
    }

    .question-table th, .question-table td {
        padding: 8px 10px; /* Reduced horizontal too */
    }

    .question-table th {
        display: none; /* Hide header on mobile */
    }

    .question-table td:first-child {
        width: 100%;
        font-weight: bold; /* Question bold on mobile */
    }

    .question-table td:not(:first-child) {
        display: flex;
        align-items: center; /* Center option and radio vertically on mobile */
        text-align: left;
        padding-left: 0; /* Reset for mobile */
    }

    .question-table label {
        display: inline-block; /* Show labels on mobile for clarity */
        margin-right: 10px; /* Space between label and radio */
        line-height: 1; /* Tighten line-height for vertical center */
        font-size: 14px;
    }

    .question-table tr {
        display: block;
        margin-bottom: 15px;
        border-bottom: 1px solid var(--border-color);
        padding-bottom: 10px;
    }

    .question-table td {
        display: block;
        text-align: left;
    }

    .navigation {
        flex-direction: column;
        gap: 10px;
    }

    /* Report responsive - tighter, centered */
    .results-container {
        padding: 15px;
    }

    .overall-section {
        padding: 10px;
    }

    .overall-score {
        font-size: 50px !important;
    }

    .progress-bar {
        width: 100% !important; /* Full width on mobile */
        margin: 10px auto;
    }

    .factor-item {
        padding: 12px;
    }

    .smartai-ip-modal .results-container .factors-list .factor-item > div:first-child {
        padding-right: 30px !important; /* Tighter on mobile */
    }

    .smartai-ip-modal .results-container .factors-list .factor-item span {
        right: 10px !important;
        top: 18px !important;
    }

    .cta-button {
        width: 100%; /* Full width for easy tap */
    }
}

/* Login modal specific styles (align to checklist form without affecting others) */
#smartai-ip-login-modal .smartai-ip-modal-content h2 {
    font-size: 20px;
    color: var(--primary-color);
    margin-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 5px;
    clear: both; /* Ensure below logo */
}

#smartai-ip-login-modal .smartai-ip-modal-content form p {
    margin-bottom: 20px; /* Match user-details label margin */
}

#smartai-ip-login-modal .smartai-ip-modal-content form label {
    display: block;
    font-size: 14px;
    font-weight: normal;
    margin-bottom: 5px; /* Space before input */
}

#smartai-ip-login-modal .smartai-ip-modal-content form input[type="text"],
#smartai-ip-login-modal .smartai-ip-modal-content form input[type="password"],
#smartai-ip-login-modal .smartai-ip-modal-content form input[type="email"] {
    width: 100%;
    height: 42px;
    box-sizing: border-box;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 14px;
    background-color: var(--bg-color);
    transition: border-color 0.3s;
}

#smartai-ip-login-modal .smartai-ip-modal-content form input:focus {
    border-color: var(--primary-color);
}

#smartai-ip-login-modal .smartai-ip-modal-content form input[type="checkbox"] {
    accent-color: var(--primary-color);
    margin-right: 10px;
}

#smartai-ip-login-modal .smartai-ip-modal-content form p:nth-child(3) { /* Remember Me p */
    display: flex;
    align-items: center;
    font-size: 14px;
}

#smartai-ip-login-modal .smartai-ip-modal-content form input[type="submit"] {
    background: var(--primary-color) !important;
    color: white !important;
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    transition: background 0.3s, transform 0.2s;
    width: auto; /* Not full width like inputs */
}

#smartai-ip-login-modal .smartai-ip-modal-content form input[type="submit"]:hover {
    background: var(--dark-color) !important;
    transform: translateY(-2px);
}

#smartai-ip-login-modal .smartai-ip-modal-content #login-error {
    font-size: 14px;
    color: red !important;
    margin-top: -10px;
    margin-bottom: 10px;
}

#smartai-ip-login-modal .smartai-ip-modal-content #reset-message {
    font-size: 14px;
    margin-top: -10px;
    margin-bottom: 10px;
}

#smartai-ip-login-modal .smartai-ip-modal-content p a {
    font-size: 14px;
    color: var(--primary-color);
    text-decoration: none;
    transition: text-decoration 0.3s;
}

#smartai-ip-login-modal .smartai-ip-modal-content p a:hover {
    text-decoration: underline;
}

/* Responsive for login modal */
@media (max-width: 768px) {
    #smartai-ip-login-modal .smartai-ip-modal-content form p {
        flex-direction: column; /* Stack if needed, but already block */
    }

    #smartai-ip-login-modal .smartai-ip-modal-content form input[type="submit"] {
        width: 100%; /* Full for mobile tap */
    }
}

/* Tweaks for login modal size, centering, and load flash */
#smartai-ip-login-modal {
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
}

#smartai-ip-login-modal[style*="display: flex"] {
    opacity: 1;
    visibility: visible;
}

#smartai-ip-login-modal .smartai-ip-modal-content {
    max-width: 600px; /* Slightly smaller */
}

/* Body scroll lock and reflow prevention when modal open */
html.modal-open, body.modal-open {
    overflow: hidden !important;
    height: 100vh !important;
    position: fixed !important;
    width: 100% !important;
    -webkit-overflow-scrolling: auto !important; /* iOS touch fix */
    touch-action: none !important; /* Prevent touch scroll leakage */
}

/* General overrides for fixed/sticky elements when modal open (theme-agnostic) */
html.modal-open [style*="position: fixed"], html.modal-open [style*="position: sticky"], html.modal-open .fixed, html.modal-open .sticky, html.modal-open .wp-block-image, html.modal-open .wp-block-button, html.modal-open .wp-block-buttons, html.modal-open .floating, html.modal-open .overlay, html.modal-open .header, html.modal-open .nav, html.modal-open .site-header, html.modal-open .site-container, html.modal-open #wrapper, html.modal-open .content-wrap {
    z-index: 1 !important; /* Force behind modal */
    position: static !important; /* Disable positioning */
    overflow: hidden !important; /* Stop any internal scroll */
}
/* ARROW STYLING — UNICODE */
.factor-item .accordion-arrow {
    font-size: 18px !important;
    font-weight: bold !important;
    line-height: 1 !important;
    position: absolute !important;
    right: 15px !important;
    top: 20px !important;
    transition: transform 0.3s ease !important;
    user-select: none !important;
    pointer-events: none !important;
}

.factor-item[aria-expanded="true"] .accordion-arrow {
    transform: rotate(180deg) !important;
    color: #177676 !important;
}

.factor-item .accordion-arrow {
    color: white !important;
}

/* Mobile */
@media (max-width: 768px) {
    .factor-item .accordion-arrow {
        right: 10px !important;
        top: 18px !important;
    }
}