/* ============================================================================
   Vote Page - Clean Minimal Design
   ============================================================================ */

.vote-page {
    max-width: 800px;
    margin: 0 auto;
    padding: 32px 24px;
}

/* Layout Consistency: Ensure no sidebar padding on vote page to match Refresh behavior */
@media (min-width: 1200px) {
    #main-content.vote-main {
        padding-left: 0 !important;
        padding-top: 0 !important;
    }
}

/* Header */
.vote-header {
    text-align: center;
    margin-bottom: 28px;
}

.vote-header h1 {
    font-size: 1.8rem;
    font-weight: 600;
    margin: 0 0 6px 0;
    color: var(--text);
}

.vote-subtitle {
    color: var(--secondary);
    font-size: 0.95rem;
    margin: 0;
}

/* Status Row */
.vote-status-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.vote-status {
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
}

.status-inactive {
    background: var(--surface);
    color: var(--secondary);
}

.status-waiting {
    background: rgba(124, 58, 237, 0.12);
    color: #a78bfa;
}

.status-countdown {
    background: rgba(245, 158, 11, 0.12);
    color: #fbbf24;
}

.status-voting {
    background: rgba(16, 185, 129, 0.12);
    color: #34d399;
}

.status-finalizing {
    background: var(--surface);
    color: var(--secondary);
}

.timer-display {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: var(--surface);
    border-radius: 6px;
}

.timer-label {
    font-size: 0.75rem;
    color: var(--secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.timer-value {
    font-size: 1rem;
    font-weight: 600;
    font-family: 'SF Mono', 'Monaco', monospace;
    color: var(--primary);
}

.timer-display.countdown-mode .timer-value {
    color: #f59e0b;
}

.rules-link {
    background: none;
    border: none;
    color: var(--secondary);
    font-size: 0.85rem;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.rules-link:hover {
    color: var(--text);
}

/* Submit Panel */
.submit-panel {
    background: var(--surface);
    border-radius: 12px;
    margin-bottom: 32px;
    padding: 20px;
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.submit-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 16px;
    flex-wrap: wrap;
}

.submit-content.centered-row {
    justify-content: center;
    gap: 24px;
}

.submit-done {
    display: flex;
    justify-content: center;
    width: 100%;
}

.submit-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 200px;
}

/* Add Image Button - White Modern */
.upload-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 24px;
    background: white;
    border: none;
    border-radius: 8px;
    color: #111;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(255, 255, 255, 0.15);
}

.upload-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 255, 255, 0.3);
}

.upload-btn:disabled {
    opacity: 0.6;
    cursor: default;
    background: #e5e7eb;
    color: #6b7280;
    box-shadow: none;
}

.upload-icon {
    display: none;
    /* Removed icon as per request for cleaner look */
}

/* Already Submitted Button */
.submitted-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 32px;
    background: linear-gradient(135deg, #10b981, #059669);
    border: none;
    border-radius: 30px;
    color: white;
    font-size: 1rem;
    font-weight: 600;
    cursor: default;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}

.submitted-btn::before {
    content: "✓";
    font-weight: 800;
}

.preview-box {
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: 8px;
    overflow: hidden;
    background: var(--bg);
}

.preview-box img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.clear-x {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    background: rgba(0, 0, 0, 0.6);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
}

.clear-x:hover {
    background: #ef4444;
}

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

.submit-info {
    text-align: right;
}

.cost-label {
    display: block;
    font-size: 0.7rem;
    color: var(--secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.cost-value {
    font-size: 0.9rem;
    font-weight: 600;
    color: #fbbf24;
}

.inline-error {
    width: 100%;
    margin-top: 8px;
    padding: 8px 12px;
    background: rgba(239, 68, 68, 0.1);
    border-radius: 6px;
    color: #ef4444;
    font-size: 0.85rem;
}

.inline-success {
    width: 100%;
    margin-top: 8px;
    padding: 8px 12px;
    background: rgba(16, 185, 129, 0.1);
    border-radius: 6px;
    color: #10b981;
    font-size: 0.85rem;
}

/* Ballot Panel */
/* Ballot Panel */
.ballot-panel {
    background: var(--surface);
    border-radius: 12px;
    margin-bottom: 32px;
    padding: 16px 20px;
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ballot-content {
    display: flex;
    align-items: center;
    width: 100%;
    gap: 16px;
    flex-wrap: wrap;
}

.ballot-done {
    display: flex;
    justify-content: center;
    width: 100%;
}

.ballot-header {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 500;
}

.cost-badge {
    font-size: 0.75rem;
    padding: 3px 8px;
    background: rgba(251, 191, 36, 0.15);
    color: #fbbf24;
    border-radius: 4px;
}

.btn-success {
    background: #10b981 !important;
    border-color: #10b981 !important;
}

/* Sections */
.submissions-section,
.gallery-section {
    margin-bottom: 40px;
}

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

.section-title h2 {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
}

.count-badge {
    font-size: 0.8rem;
    padding: 4px 10px;
    background: var(--surface);
    border-radius: 12px;
    color: var(--secondary);
}

/* Submissions Grid */
.submissions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
}

.empty-placeholder {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px 20px;
    background: var(--surface);
    border-radius: 10px;
    border: 1px dashed var(--border);
}

.empty-placeholder p {
    margin: 0;
    color: var(--secondary);
    font-size: 0.9rem;
}

.sub-card {
    background: var(--surface);
    border-radius: 10px;
    overflow: hidden;
    transition: transform 0.15s, box-shadow 0.15s;
}

.sub-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.sub-image {
    cursor: pointer;
}

.sub-image img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    display: block;
}

.sub-meta {
    padding: 8px 10px;
    font-size: 0.75rem;
    color: var(--secondary);
    text-align: center;
}

/* Voting Mode Rating */
.sub-card.voting {
    border: 1px solid var(--border);
}

.sub-rating {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 8px;
    background: var(--bg);
}

.star {
    background: none;
    border: none;
    font-size: 1rem;
    padding: 2px;
    cursor: pointer;
    color: #fbbf24;
    opacity: 0.25;
    transition: opacity 0.1s, transform 0.1s;
}

.star:hover:not(:disabled) {
    transform: scale(1.15);
    opacity: 0.6;
}

.star.on {
    opacity: 1;
}

.star:disabled {
    cursor: default;
}

.score-num {
    font-size: 0.75rem;
    color: var(--secondary);
    margin-left: 6px;
    min-width: 12px;
}

/* Gallery Grid */
/* Gallery Grid - Smart Dense Grid */
.gallery-grid {
    display: grid;
    /* Fine-grained grid for precise aspect ratio matching */
    grid-template-columns: repeat(auto-fill, minmax(25px, 1fr));
    grid-auto-rows: 25px;
    gap: 4px;
    grid-auto-flow: dense;
}

.gallery-card {
    background: var(--surface);
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.15s;
    position: relative;
    width: 100%;
    height: 100%;
    /* Spans will be set by JS */
}

.gallery-card:hover {
    transform: scale(1.02);
    z-index: 10;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
}

.gallery-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* Safe now that container matches aspect ratio */
    display: block;
}

/* Spans for Bento Layout */
.gallery-card.wide {
    grid-column: span 2;
}

.gallery-card.tall {
    grid-row: span 2;
}

.gallery-card.big {
    grid-column: span 2;
    grid-row: span 2;
}

/* Overlay Meta */
.gallery-meta {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 30px 10px 10px 10px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.9), transparent);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: #fff;
    pointer-events: none;
}

.gallery-meta .user-link {
    pointer-events: auto;
}

.badge {
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
    text-transform: uppercase;
    text-shadow: none;
}

.badge.win {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    color: #000;
}

.badge.tie {
    background: linear-gradient(135deg, #a855f7, #6366f1);
    color: white;
}

/* Modals */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.close-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 4px 10px;
    line-height: 1;
}

.close-btn:hover {
    color: white;
}

/* Image Viewer */
.image-viewer {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
}

.image-viewer img {
    max-width: 100%;
    max-height: 85vh;
    object-fit: contain;
    border-radius: 8px;
}

.image-viewer .close-btn {
    top: -35px;
    right: 0;
}

.image-caption {
    text-align: center;
    margin-top: 10px;
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.9rem;
}

.user-link,
.modal-user-link {
    cursor: pointer;
    font-weight: 600;
    color: var(--accent-cyan);
    transition: color 0.15s;
}

.user-link:hover,
.modal-user-link:hover {
    color: #fff;
    text-decoration: underline;
}

/* Rules Panel */
.rules-panel {
    position: relative;
    max-width: 420px;
    width: 100%;
    padding: 24px;
    border-radius: 12px;
}

.rules-panel h2 {
    margin: 0 0 20px 0;
    font-size: 1.2rem;
    text-align: center;
}

.rules-list {
    margin-bottom: 20px;
}

.rule-item {
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
    color: var(--secondary);
}

.rule-item:last-child {
    border-bottom: none;
}

.rule-item strong {
    color: var(--text);
}

/* Button Error Flash */
.btn-error-flash {
    background: #ef4444 !important;
    color: white !important;
    border-color: #ef4444 !important;
    animation: shake 0.4s cubic-bezier(.36, .07, .19, .97) both;
}

@keyframes shake {

    10%,
    90% {
        transform: translate3d(-1px, 0, 0);
    }

    20%,
    80% {
        transform: translate3d(2px, 0, 0);
    }

    30%,
    50%,
    70% {
        transform: translate3d(-4px, 0, 0);
    }

    40%,
    60% {
        transform: translate3d(4px, 0, 0);
    }
}

/* Responsive */
@media (max-width: 600px) {
    .vote-page {
        padding: 20px 16px;
    }

    .vote-header h1 {
        font-size: 1.5rem;
    }

    .submit-panel {
        flex-direction: column;
    }

    .submit-left {
        width: 100%;
    }

    .submit-right {
        width: 100%;
        justify-content: space-between;
    }

    .submissions-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Inline Spinner for loading state */
.spinner-inline {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(0, 0, 0, 0.2);
    border-top-color: #111;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    vertical-align: middle;
    margin-right: 6px;
}

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