/* Voty CSS - Dark Professional Theme */

:root {
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --bg-tertiary: #3d3d3d;
    --bg-hover: #4d4d4d;
    --text-primary: #ffffff;
    --text-secondary: #b0b0b0;
    --accent-primary: #4a9eff;
    --accent-hover: #3a8eef;
    --success: #4caf50;
    --danger: #f44336;
    --warning: #ff9800;
    --border-color: #404040;
    --shadow: rgba(0, 0, 0, 0.3);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
}

/* Admin Body */
.admin-body {
    min-height: 100vh;
    padding: 20px;
}

.admin-container {
    max-width: 1200px;
    margin: 0 auto;
}

/* Header */
.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--border-color);
}

.admin-header h1 {
    font-size: 2rem;
    font-weight: 600;
}

.header-actions {
    display: flex;
    gap: 10px;
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.btn:hover {
    background: var(--bg-hover);
    transform: translateY(-1px);
}

.btn-primary {
    background: var(--accent-primary);
    color: white;
}

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

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

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #d32f2f;
}

.btn-warning {
    background: #ff9800;
    color: white;
}

.btn-warning:hover {
    background: #f57c00;
}

.btn-small {
    padding: 6px 12px;
    font-size: 0.85rem;
}

.btn-large {
    padding: 15px 40px;
    font-size: 1.1rem;
}

/* Lobby Control */
.lobby-control {
    background: var(--bg-secondary);
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 30px;
}

.lobby-status {
    display: flex;
    align-items: center;
}

.toggle-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    gap: 15px;
}

.toggle-input {
    display: none;
}

.toggle-slider {
    position: relative;
    width: 60px;
    height: 30px;
    background: var(--bg-tertiary);
    border-radius: 30px;
    transition: background 0.3s;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: white;
    top: 3px;
    left: 3px;
    transition: transform 0.3s;
}

.toggle-input:checked + .toggle-slider {
    background: var(--success);
}

.toggle-input:checked + .toggle-slider::before {
    transform: translateX(30px);
}

.toggle-text {
    font-size: 1rem;
    font-weight: 500;
}

.lobby-code-box {
    margin-top: 15px;
    display: flex;
    align-items: center;
    gap: 15px;
}

.lobby-actions {
    display: flex;
    gap: 10px;
}

.code-display {
    background: var(--bg-primary);
    padding: 15px 25px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.code-label {
    color: var(--text-secondary);
}

.code-value {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 0.2em;
    color: var(--accent-primary);
}

/* Question Sets */
.question-sets-section {
    margin-bottom: 30px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.section-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
}

.question-sets-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.question-set-item {
    background: var(--bg-secondary);
    padding: 20px;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.2s;
}

.question-set-item:hover {
    background: var(--bg-tertiary);
}

.question-set-info {
    flex: 1;
}

.question-set-name {
    font-size: 1.1rem;
    font-weight: 500;
    margin-bottom: 5px;
}

.question-count {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.question-set-actions {
    display: flex;
    gap: 10px;
}

/* Questions List */
.questions-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 20px 0 15px;
}

.questions-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 400px;
    overflow-y: auto;
    padding-right: 10px;
}

.question-item {
    background: var(--bg-tertiary);
    padding: 15px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 15px;
    cursor: move;
}

.question-item:hover {
    background: var(--bg-hover);
}

.drag-handle {
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: grab;
    flex-shrink: 0;
}

.question-item-info {
    flex: 1;
    min-width: 0; /* Allow text to shrink */
}

.question-item-text {
    font-weight: 500;
    margin-bottom: 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.question-item-options {
    color: var(--text-secondary);
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.question-item-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0; /* Prevent buttons from shrinking */
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: 12px;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-sizing: border-box; /* Include padding in width calculation */
}

.modal-large {
    max-width: 800px;
}

.modal-header {
    padding: 20px 25px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0; /* Prevent header from shrinking */
    box-sizing: border-box; /* Include padding in width calculation */
    width: 100%; /* Ensure header stays within modal bounds */
}

.modal-header h2 {
    font-size: 1.4rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 2rem;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    line-height: 1;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 25px;
    overflow-y: auto;
    flex: 1;
    min-height: 0; /* Important: allows flex item to shrink below content size */
    box-sizing: border-box; /* Include padding in width calculation */
    width: 100%; /* Ensure body stays within modal bounds */
}

.modal-footer {
    padding: 20px 25px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    flex-shrink: 0; /* Prevent footer from shrinking */
    gap: 10px;
    flex-wrap: wrap; /* Allow buttons to wrap on small screens */
    box-sizing: border-box; /* Include padding in width calculation */
    width: 100%; /* Ensure footer stays within modal bounds */
}

.modal-footer .btn {
    flex-shrink: 1; /* Allow buttons to shrink if needed */
    min-width: 80px; /* Minimum button width */
}

/* Form Elements */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-input {
    width: 100%;
    padding: 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.form-input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

textarea.form-input {
    resize: vertical;
    font-family: inherit;
}

/* Image Upload */
.image-upload-area {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.paste-area {
    border: 2px dashed var(--border-color);
    padding: 30px;
    text-align: center;
    border-radius: 8px;
    cursor: text;
    transition: all 0.3s ease;
    background: var(--bg-primary);
}

.paste-area:hover {
    border-color: var(--accent-primary);
    background: rgba(74, 158, 255, 0.05);
}

.paste-area:focus-within {
    border-color: var(--accent-primary);
    outline: 2px solid rgba(74, 158, 255, 0.3);
}

.paste-area p {
    margin: 0 0 15px 0;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.paste-area.paste-active {
    border-color: var(--success);
    background: rgba(76, 175, 80, 0.05);
}

.image-preview {
    position: relative;
    max-width: 400px;
    margin-top: 10px;
}

.image-preview img {
    width: 100%;
    border-radius: 6px;
    display: block;
}

.image-preview .btn-danger {
    position: absolute;
    top: 10px;
    right: 10px;
}

/* Options Container */
.options-container {
    margin-top: 20px;
}

.options-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 10px;
}

.option-item {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-tertiary);
    padding: 10px;
    border-radius: 6px;
}

.option-item .drag-handle {
    cursor: grab;
}

.option-item input[type="text"] {
    flex: 1;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    padding: 8px;
    border-radius: 4px;
    color: var(--text-primary);
}

.option-item button {
    padding: 6px 10px;
}

.option-item .correct-checkbox {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.option-item .correct-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* Checkbox styling */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* Preview Section */
.preview-section {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

/* Fullscreen Modals */
.modal-fullscreen {
    background: rgb(0, 0, 0) !important; /* Solid black background for fullscreen modals */
}

.modal-fullscreen .fullscreen-content {
    width: 100%;
    height: 100%;
    padding: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start; /* Changed from center to allow natural flow */
    position: relative;
    overflow-y: auto; /* Enable vertical scrolling */
    overflow-x: hidden; /* Prevent horizontal scrolling */
}

.fullscreen-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 3rem;
    cursor: pointer;
    z-index: 10;
}

.fullscreen-close:hover {
    color: var(--text-primary);
}

.preview-label {
    position: absolute;
    top: 20px;
    left: 20px;
    background: var(--warning);
    color: var(--bg-primary);
    padding: 8px 16px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.9rem;
}

/* Question Display */
.question-display {
    max-width: 900px;
    width: 100%;
    text-align: center;
}

.question-image {
    margin-bottom: 30px;
}

.question-image.hidden {
    margin: 0;
}

.question-image img {
    max-width: 100%;
    max-height: 50vh; /* Limit image height to 50% of viewport height */
    object-fit: contain;
    max-height: 400px;
    border-radius: 12px;
    object-fit: contain;
}

/* Hide img elements without valid src */
.question-image img[src=""],
.question-image img[src]:not([src*="."]),
.question-image img:not([src]),
.question-image.hidden img {
    display: none !important;
    visibility: hidden !important;
    width: 0 !important;
    height: 0 !important;
}

.question-text {
    font-size: 2.5rem;
    font-weight: 600;
    margin-bottom: 40px;
    line-height: 1.3;
}

.answer-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.answer-option {
    background: var(--bg-secondary);
    padding: 30px;
    border-radius: 12px;
    font-size: 1.3rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: 3px solid transparent;
}

.answer-option:hover {
    background: var(--bg-tertiary);
    transform: translateY(-3px);
}

.answer-option.selected {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
}

.play-input-area, .answer-input-area {
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-width: 500px;
    margin: 0 auto;
}

.answer-input, .play-input-area input {
    padding: 20px;
    font-size: 1.2rem;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-primary);
    text-align: center;
}

.answer-input:focus, .play-input-area input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

/* Response Counter */
.response-counter {
    margin-top: 40px;
    font-size: 1.5rem;
    color: var(--text-secondary);
}

.response-counter span {
    color: var(--accent-primary);
    font-weight: 700;
    font-size: 2rem;
}

.play-actions {
    margin-top: 40px;
    margin-bottom: 40px; /* Add space at bottom for easier scrolling */
}

/* Results Display */
.results-display {
    max-width: 1000px;
    width: 100%;
    text-align: center;
}

.results-chart {
    margin-top: 40px;
    background: var(--bg-secondary);
    padding: 40px;
    border-radius: 12px;
}

#chartCanvas {
    max-height: 500px;
}

#wordCloudContainer {
    width: 100%;
    min-height: 500px;
    position: relative;
}

.results-actions {
    margin-top: 40px;
    display: flex;
    gap: 20px;
    justify-content: center;
}

/* User Body */
.user-body {
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

.user-container {
    width: 100%;
    height: 100%;
    position: relative;
}

.screen {
    display: none;
    width: 100%;
    height: 100%;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.screen.active {
    display: flex;
}

/* Code Entry */
.voty-logo h1 {
    font-size: 4rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 40px;
    background: linear-gradient(135deg, var(--accent-primary), var(--success));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.lobby-message {
    text-align: center;
}

.lobby-message p {
    font-size: 1.5rem;
    color: var(--text-secondary);
}

.code-entry-form {
    text-align: center;
}

.instruction {
    font-size: 1.2rem;
    margin-bottom: 20px;
    color: var(--text-secondary);
}

.code-input-group {
    display: flex;
    gap: 15px;
    justify-content: center;
    align-items: center;
}

#codeInput {
    width: 150px;
    padding: 20px;
    font-size: 2rem;
    text-align: center;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-primary);
    letter-spacing: 0.3em;
}

#codeInput:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.error-message {
    margin-top: 15px;
    color: var(--danger);
    font-weight: 500;
}

/* Lobby Screen */
.lobby-content {
    text-align: center;
}

.voty-logo-small h2 {
    font-size: 2rem;
    margin-bottom: 40px;
    color: var(--text-secondary);
}

.waiting-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--bg-tertiary);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.waiting-message p {
    font-size: 1.3rem;
    color: var(--text-secondary);
}

/* Question Screen */
.question-content {
    max-width: 800px;
    width: 100%;
}

/* Waiting Screen */
.waiting-content {
    text-align: center;
}

.checkmark-animation {
    margin-bottom: 30px;
}

.checkmark {
    width: 100px;
    height: 100px;
    margin: 0 auto;
}

.checkmark-circle {
    stroke: var(--success);
    stroke-width: 2;
    stroke-dasharray: 166;
    stroke-dashoffset: 166;
    animation: stroke 0.6s cubic-bezier(0.65, 0, 0.45, 1) forwards;
}

.checkmark-check {
    stroke: var(--success);
    stroke-width: 2;
    stroke-linecap: round;
    stroke-dasharray: 48;
    stroke-dashoffset: 48;
    animation: stroke 0.3s cubic-bezier(0.65, 0, 0.45, 1) 0.6s forwards;
}

@keyframes stroke {
    to {
        stroke-dashoffset: 0;
    }
}

.waiting-text {
    font-size: 1.8rem;
    font-weight: 600;
    margin-bottom: 10px;
}

.waiting-subtext {
    font-size: 1.2rem;
    color: var(--text-secondary);
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.sortable-ghost {
    opacity: 0.4;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--bg-hover);
}

/* Responsive */
@media (max-width: 768px) {
    .question-text {
        font-size: 1.8rem;
    }
    
    .answer-options {
        grid-template-columns: 1fr;
    }
    
    .answer-option {
        padding: 20px;
        font-size: 1.1rem;
    }
    
    .voty-logo h1 {
        font-size: 3rem;
    }
    
    .admin-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
}
