:root {
    --poll-live-background-color: white;
    --poll-selected-option-background-color: maroon;
    --poll-selected-option-text-color: white;
    --poll-selected-option-font-weight: bold;
}

/* Increase the font size of the title bar for a single-poll page */
body.poll::before {
    font-size: 16px;
}

/***********
* POLLS RESULT
***********/

.posts .poll-result {
    padding-top: 15px !important;
}

.poll-result {
    border-bottom: 1px solid var(--color-secondary);
    padding-bottom: 30px;
    /* margin-bottom: 20px; */
}

.poll-result .poll-prompt {
    /* Make this very responsive to resizing of the container */
    width: 100%;
}

.poll-result .apexchart-container {
    width: 100%;
    margin: 0;
    padding: 0;
    min-height: 0 !important;
}

.poll-result .poll-prompt {
    /* FIXME */
    color: #333;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.5;
    /* padding-bottom: 10px; */
}

/* ==========================================================================
   SECTION: POLLS: LIVE
   ========================================================================== */
__SECTION_POLLS_LIVE__ {
    display: block;
}

.posts .poll-live {
    padding-top: 15px;
    padding-bottom: 30px; /* Make room for the hide button, etc*/
    background: var(--poll-live-background-color);
    border-bottom: 1px solid var(--color-secondary);
}

.poll-live .poll-form {
    display: flex;
    flex-wrap: wrap;
}

.poll-live .poll-option input[type='radio'],
.poll-live .poll-option input[type='checkbox'] {
    display: none;
}

/* Highlight the selected button */
.poll-live .poll-option input[type='radio']:checked + label,
.poll-live .poll-option input[type='checkbox']:checked + label {
    background: var(--poll-selected-option-background-color);
    color: var(--poll-selected-option-text-color);
}

/* Stylize the labels as buttons */
.poll-live form label {
    background-color: #f0f0f0;
    border: 2px solid #ccc;
    display: inline-block;
    padding: 5px 10px;
    margin: 2px;
    border-radius: 5px;
    cursor: pointer;
    /* transition: background-color 0.3s, border-color 0.3s; */
}

/* Hover effect for buttons */
.poll-live .poll-option form label:hover {
    /* FIXME */
    background-color: #ddd;
}

.poll-form .poll-option label {
    /* FIXME */
    color: black;
    background: white;
    border: 2px solid var(--color-secondary);
    display: inline-block;
    padding: 10px 15px;
    border-radius: 10px;
    cursor: pointer;
    margin-top: 10px;
}

.poll-live .poll-prompt {
    /* FIXME */
    position: sticky;
    top: 0;

    color: #333;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.5;
    /* padding-bottom: 10px; */
}

.poll-live .poll-option {
    padding-left: 10px;
}

.poll-option input:disabled {
    opacity: 0.6;
}

.poll-option.pending {
    opacity: 0.7;
    pointer-events: none;
}

/* Enhanced poll option layout for images */
.poll-option-content {
    display: flex;
    align-items: center;
    /* gap: 10px; */
    width: 100%;
}

.poll-option-image {
    /* Fixed dimensions */
    width: 70px;
    height: 70px;

    /* Aspect ratio handling */
    object-fit: cover;
    object-position: center;

    /* Performance optimizations */
    image-rendering: auto;

    /* Visual styling */
    border-radius: 6px;
    border: 1px solid rgba(0, 0, 0, 0.1);

    /* Layout */
    flex-shrink: 0;
    display: block;
}

.poll-option-text {
    flex: 1;
    text-align: left;
}

/* Adjust existing label styling for better image integration */
.poll-form .poll-option label {
    color: black;
    background: white;
    border: 2px solid var(--color-secondary);
    display: block; /* Changed from inline-block for better control */
    padding: 12px 15px; /* Slightly increased padding for images */
    border-radius: 10px;
    cursor: pointer;
    margin-top: 10px;
    min-height: 44px; /* Ensure consistent height */
    box-sizing: border-box;
}

/* Enhanced styling for options with images */
.poll-option.poll-with-image label {
    padding: 8px 15px; /* Reduced padding when image is present */
}

/* Hover and selected states maintain existing behavior */
.poll-live .poll-option input[type='radio']:checked + label .poll-option-image,
.poll-live .poll-option input[type='checkbox']:checked + label .poll-option-image {
    border-color: var(--button-text-color-primary);
}

/* Poll option col count styling */
.poll-cols-1 .poll-option {
    width: 100%;
}

.poll-cols-2 .poll-option {
    width: 47.5%;
}

.poll-cols-3 .poll-option {
    width: 31%;
}

@media (max-width: 480px) {
    .poll-cols-2 .poll-option {
        width: 45%;
    }

    .poll-cols-3 .poll-option {
        width: 30%;
    }
}

/* Tile-style layout for poll options with images in 2 and 3 column layouts */
.poll-cols-2 .poll-option.poll-with-image label,
.poll-cols-3 .poll-option.poll-with-image label {
    padding: 0;
    height: 140px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Make sure the content container is flexible */
.poll-cols-2 .poll-option.poll-with-image .poll-option-content,
.poll-cols-3 .poll-option.poll-with-image .poll-option-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    flex: 1;
}

.poll-cols-2 .poll-option.poll-with-image .poll-option-image,
.poll-cols-3 .poll-option.poll-with-image .poll-option-image {
    width: 100%;
    height: 67%; /* Top 2/3 of the tile */
    object-fit: cover;
    object-position: center;
    border-radius: 10px 10px 0 0;
    border: none;
    flex-shrink: 0;
}

.poll-cols-2 .poll-option.poll-with-image .poll-option-text,
.poll-cols-3 .poll-option.poll-with-image .poll-option-text {
    /* Remove fixed height: 33% and replace with flexible min-height */
    min-height: 40px; /* Minimum height to maintain consistency */
    flex: 1; /* Allow text area to grow */
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.2;
    background: white;
    border-radius: 0 0 10px 10px;
    /* Allow text wrapping and expansion */
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Adjust tile height for different column counts */
.poll-cols-2 .poll-option.poll-with-image label {
    min-height: 160px; /* Change from fixed height to min-height */
    height: auto; /* Allow container to expand */
    display: flex;
    flex-direction: column;
}

.poll-cols-3 .poll-option.poll-with-image label {
    height: 120px;
    height: auto; /* Allow container to expand */
    display: flex;
    flex-direction: column;
}

.poll-cols-3 .poll-option.poll-with-image .poll-option-text {
    font-size: 12px;
    padding: 6px 8px;
}

/* Hover and selected states for tiles */
.poll-cols-2 .poll-option.poll-with-image input[type='radio']:checked + label,
.poll-cols-3 .poll-option.poll-with-image input[type='radio']:checked + label,
.poll-cols-2 .poll-option.poll-with-image input[type='checkbox']:checked + label,
.poll-cols-3 .poll-option.poll-with-image input[type='checkbox']:checked + label {
    border: 2px solid var(--color-secondary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.poll-cols-2 .poll-option.poll-with-image input[type='radio']:checked + label .poll-option-text,
.poll-cols-3 .poll-option.poll-with-image input[type='radio']:checked + label .poll-option-text,
.poll-cols-2 .poll-option.poll-with-image input[type='checkbox']:checked + label .poll-option-text,
.poll-cols-3 .poll-option.poll-with-image input[type='checkbox']:checked + label .poll-option-text {
    background: var(--poll-selected-option-background-color);
    color: var(--poll-selected-option-text-color);
    font-weight: var(--poll-selected-option-font-weight);
}

.poll-cols-2 .poll-option.poll-with-image label:hover,
.poll-cols-3 .poll-option.poll-with-image label:hover {
    /* transform: translateY(-2px); */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    /* transition: transform 0.2s ease, box-shadow 0.2s ease; */
}

/* Keep 1-column layout unchanged (horizontal) */
.poll-cols-1 .poll-option.poll-with-image .poll-option-content {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
}

.poll-cols-1 .poll-option.poll-with-image .poll-option-image {
    width: 70px;
    height: 70px;
    object-fit: cover;
    object-position: center;
    border-radius: 6px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

.poll-cols-1 .poll-option.poll-with-image .poll-option-text {
    flex: 1;
    text-align: left;
}

.poll-cols-1 .poll-option.poll-with-image label {
    padding: 8px 15px;
}

.poll-option input[type='checkbox']:disabled + label,
.poll-option input[type='radio']:disabled + label {
    opacity: 0.6;
    cursor: not-allowed;
}

.poll-option input[type='checkbox']:disabled + label:hover,
.poll-option input[type='radio']:disabled + label:hover {
    opacity: 0.8;
    transform: scale(1.02);
}

/* Responsive adjustments */
@media (max-width: 480px) {
    .poll-option-image {
        width: 32px;
        height: 32px;
    }

    .poll-option-content {
        gap: 8px;
    }

    .poll-form .poll-option label {
        padding: 10px 12px;
    }

    .poll-option.poll-with-image label {
        padding: 6px 12px;
    }
}

.poll-vote-counter-text {
    /* Typography */
    font-size: 13px;
    font-weight: 500;
    color: #666;
    letter-spacing: 0.02em;

    /* Layout */
    display: inline-block;
    text-align: center;
    padding: 8px 16px;

    margin-left: 2em;

    /* Modern styling */
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;

    /* Subtle effects */
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    transition: all 0.2s ease;
}

/* When votes are maxed out */
.poll-vote-counter-text.votes-maxed {
    background: #f8d7da;
    color: #721c24;
    border-color: #f5c6cb;
}

/* ==========================================================================
   SECTION: POLLS: MODERATE
   ========================================================================== */
__SECTION_POLLS_MODERATE__ {
    display: block;
}

.polls-list {
    padding: 10px;
}

.poll-edit .modal {
    display: block;
    position: fixed;
    width: 90%;
    max-width: 550px;
    left: 5%;
    top: 10vh;
    max-height: 80vh; /* Add this - limits modal height to 80% of viewport */
    z-index: 10;
    overflow-y: auto;
}

.poll-edit .poll-form {
    background-color: var(--main-background-color);
    padding: 20px;
    border-radius: 6px;
    width: 100%;
    min-height: 500px;
    /* Remove max-height: 80%; - let the modal container handle height */
    /* Remove overflow-y: auto; - let the modal container handle scrolling */
    box-sizing: border-box;
}

.poll-edit [x-cloak] {
    display: none !important;
}

.poll-edit .overlay {
    background: black; /* FIXME */
    width: 100%;
    height: 100%;
    position: fixed;
    top: 0;
    left: 0;
    opacity: 0.5;
    z-index: 10;
}

.poll-edit .poll-form h2 {
    margin-bottom: 20px;
    font-size: 1.5rem;
}

.poll-edit .poll-form label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

.poll-edit .poll-form input[type='text'],
.poll-form button {
    border: 1px solid #ccc; /* FIXME */
    width: 90%;
    padding: 10px;
    margin-bottom: 10px;
    border-radius: 4px;
    font-size: 1rem;
}

.poll-edit .poll-form button {
    background-color: var(--color-secondary);
    color: #fff;
    cursor: pointer;
    border: none;
}

.poll-edit .poll-form button:hover {
    background-color: var(--color-primary);
}

.poll-edit .poll-form button:disabled {
    position: relative;
}

.poll-edit .poll-form button:disabled:hover {
    background-color: #ccc;
    cursor: not-allowed;
}

.poll-edit .poll-form button:disabled:hover::after {
    content: attr(data-disabled-reason);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    z-index: 1000;
    margin-bottom: 5px;
}

.poll-edit .poll-form button:disabled:hover::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #333;
    margin-bottom: -5px;
    z-index: 1000;
}

.poll-edit .options-container {
    margin-bottom: 20px;
}

.poll-edit .options-container .option {
    margin-bottom: 5px;
}

.poll-edit .option {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
}

.poll-edit .option input[type='text'] {
    flex: 1;
}

.poll-edit .close-button {
    color: var(--color-primary);
    position: absolute;
    top: 10px;
    right: 10px;
}

.poll-edit .close-button::before {
    text-indent: 0;
    content: var(--close-fa-icon-code);
    font-family: var(--font-icon);
    font-weight: 900;
    z-index: 9;
    font-size: 18px;
    /* display: inline-block; */
    /* margin-right: 200px; */
}

.poll-edit .poll-option-grab-icon::before {
    display: flex;
    content: var(--grab-fa-icon-code);
    font-family: var(--font-icon);
    color: var(--color-secondary);

    width: 20px;
    height: 20px;
    float: left;
    margin: 3px;
    margin-bottom: 15px;

    /* background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAAAXNSR0IArs4c6QAAAW9JREFUOE/VlLsvhFEQxX9b6VDbxqNDY0NDQYfQ4B9Yj04jElEIIlGpRLRefwDReEQlQcNuKGipbO1R2YZ7krnJ5FaKb4u91Z17Zs73zcyZyZHxyTm+PNANXAM/yXf6gF+glLw3BP8h4Bl4FxYJRfYCNAHnwJgLnAH2zNb9wGEXwAjwCXQClUg4DFyao8BmFyQyEenoPucw+TaaLY6rSKhfPwEGgDVgxwX1AMeW8hTw5LCFkOUGcANMAlVfw0zaU1+Es6Go/cAu8OjyV9FXrYabwJfDCsA8cBu7H1OWzu7N8Q1od0FbwJLZui87TL6tZoujFAl7g/YeDHgFOv5JKN828xVH2Tdl2mSjlL00lPKKBSnl70RSMeVDPymZSKa+CDV6pyab9TDL24k0NHo6Gi8vqcUgJ/nfARPaUjVbDn59nQU9jbs/VPf3zS4GmRw5TKtuFPgAuvz6kk+LW7DVpO3SmBZsOXlXqQZtwVZq0uU/iptOFca+ys4AAAAASUVORK5CYII='); */
}

.poll-edit .poll-option-expand-down-icon::before {
    content: var(--expand-down-fa-icon-code);
    font-family: var(--font-icon);
    color: var(--color-secondary);
    width: 25px;
    height: 25px;
    float: left;
}

.poll-edit .poll-option-imageurl-indicator::before {
    content: var(--picture-fa-icon-code);
    font-family: var(--font-icon);
    color: gray;
    width: 25px;
    height: 25px;
    float: left;
}

.poll-edit .poll-option-imageurl-indicator.empty::before {
    color: gray;
}

.poll-edit .poll-option-imageurl-indicator.valid::before {
    color: green;
}

.poll-edit .poll-option-imageurl-indicator.invalid::before {
    color: red;
}

.poll-edit ul.poll-option-edit-list {
    padding: 0; /* Optionally remove the default padding */
    margin: 0; /* Optionally remove the default margin */
    list-style-type: none;
}

.poll-edit-MERGE label {
    display: block;
    margin-top: 20px;
}

.poll-edit-MERGE label[for='poll-text'] {
    display: inline-block;
}

.poll-option-edit-list-MERGE {
    margin-left: 0;
    padding-left: 0;
    list-style: none;
}

.poll-mod-section {
    background: white;
}

.poll-mod-section .draft-poll-button {
    background: var(--color-primary);
    text-decoration: none;
    border-radius: 40px;
    border-width: 0px;
    color: white;
    padding: 10px;
    margin: 8px;
    display: inline-flex;
    text-align: center;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    font-size: 10px;
    text-transform: uppercase;
}

.poll-mod-disp {
    background-color: rgba(212, 55, 49, 0.15); /* FIXME */
    border-radius: 10px;
    /* box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); */
    padding: 12px;
    margin-bottom: 10px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    font-family: 'Lato', sans-serif;
    /* transition: background-color 0.3s ease; */
}

/* Poll question styling */
.poll-mod-disp .poll-question {
    color: #333; /* FIXME */
    font-size: 18px;
    font-weight: 600;
    line-height: 1.5;
}

/* Poll options styling */
.poll-mod-disp .poll-option {
    background-color: #fff; /* FIXME */
    border: 1px solid #ddd; /* FIXME */
    padding: 3px 5px;
    border-radius: 6px;
    transition: transform 0.2s ease, background-color 0.2s ease;
    margin-bottom: 2px;
}

.poll-mod-disp .poll-option .poll-option-text {
    flex: none;
}

.poll-mod-disp .poll-option .poll-option-details {
    display: flex;
    flex-direction: column;
    margin-left: 10px;
    font-size: 12px;
    color: darkgray;
    text-align: left;
}

.poll-mod-disp .poll-option .poll-option-image-url,
.poll-mod-disp .poll-option .poll-option-custom-id {
    flex: none;
}

.poll-mod-disp .poll-option .poll-option-image-url::before {
    content: 'Image: ';
    font-weight: bold;
}

.poll-mod-disp .poll-option .poll-option-custom-id::before {
    content: 'Custom ID: ';
    font-weight: bold;
}

/* Styling individual metadata items with space */
.poll-mod-disp .poll-creator,
.poll-mod-disp .poll-creation-time,
.poll-mod-disp .poll-last-mod-time {
    color: #666; /* FIXME */
    font-weight: 400;
    justify-self: start;
    font-size: 10px;
}

.poll-meta {
    color: #666; /* FIXME */
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    /* gap: 10px; */
    font-size: 12px;
}

/* Style for all header elements */
.poll-meta [class$='-header'] {
    color: #555; /* FIXME */
    text-transform: uppercase;
    font-size: 8px;
    font-weight: 600;
    justify-self: start;
}

/* Create column groups */
.poll-meta .poll-creator-header,
.poll-meta .poll-creator {
    grid-column: 1;
}

.poll-meta .poll-creation-time-header,
.poll-meta .poll-creation-time {
    grid-column: 2;
}

.poll-meta .poll-last-mod-time-header,
.poll-meta .poll-last-mod-time {
    grid-column: 3;
}

/* Stack headers above values */
.poll-meta .poll-creator-header,
.poll-meta .poll-creation-time-header,
.poll-meta .poll-last-mod-time-header {
    grid-row: 1;
}

.poll-meta .poll-creator,
.poll-meta .poll-creation-time,
.poll-meta .poll-last-mod-time {
    grid-row: 2;
}

/* Style for secondary header elements */
.poll-meta2 {
    color: #666;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin: 15px 0;
    font-size: 12px;
}

.poll-meta2 .poll-meta-item {
    padding: 4px 8px;
    background: #f8f8f8;
    border: 1px solid #e0e0e0;
    border-radius: 3px;
    text-align: center;
    min-height: 32px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    line-height: 1.3;
}

.poll-meta2 .poll-meta-item::before {
    content: attr(data-label);
    font-size: 10px;
    color: #888;
    text-transform: uppercase;
    font-weight: 500;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
    display: block;
}

.poll-meta2 .poll-meta-item:empty::before {
    text-decoration: line-through;
    color: #bbb;
}

@media (max-width: 768px) {
    .poll-meta2 {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
        font-size: 11px;
    }

    .poll-meta2 .poll-meta-item {
        padding: 3px 6px;
        min-height: 28px;
    }

    .poll-meta2 .poll-meta-item::before {
        font-size: 9px;
    }
}


/* Special handling for status badge */
.poll-meta .poll-status {
    grid-column: 4;
    grid-row: 1 / span 2;
    justify-self: end;
    align-self: start;
}

/* General status badge style */
.poll-mod-disp .poll-status {
    background: #000; /* FIXME */
    display: inline-block;
    flex: 0 0 auto;
    margin-top: 10px;
    margin-left: auto;
    width: auto;
    max-width: 50px;
    padding: 3px 5px;
    border-radius: 40px;
    text-align: center;
    font-weight: bold;
    color: white;
    text-transform: uppercase;
}

.poll-status[data-status='published'] {
    background: #da6339; /* FIXME */
    max-width: 65px;
}

.poll-votes-sum {
    margin-block: 15px;
    text-align: center;
}

/* Buttons container */
.poll-mod-disp .action-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 10px;
}

/* Common button styling */
.poll-mod-disp .action-buttons button {
    background: var(--color-secondary);
    border: none;
    border-radius: 5px;
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.3s ease;
    padding: 10px 8px;
    color: white;
}

.poll-edit button,
.options-container button {
    background: var(--color-secondary);
    color: var(--button-text-color-primary);
    border: none;
    border-radius: 10px;
    padding: 10px 15px;
    margin-top: 5px;
    width: auto;
}

.poll-option-remove-button::before {
    content: var(--delete-fa-icon-code);
    font-family: var(--font-icon);
    font-weight: 900;
    z-index: 9;
    font-size: 18px;
}

.options-container button {
    padding: 3px 10px;
    margin-left: 10px;
}

.post.question-MERGE {
    border-bottom: 1px solid var(--color-secondary);
}
