/* ==========================================================================
   CSS Variables & Reset
   ========================================================================== */
:root {
    --color-bg: #f9fafb;
    --color-surface: #ffffff;
    --color-text: #1f2937;
    --color-text-muted: #6b7280;
    
    --color-primary: #5b21b6; /* Deep plum/purple */
    --color-primary-hover: #4c1d95;
    --color-accent: #f59e0b; /* Warm amber */
    
    --color-border: #e5e7eb;
    --color-error: #ef4444;
    --color-success: #10b981;

    --font-heading: 'Playfair Display', serif;
    --font-body: 'Inter', sans-serif;
    
    --radius-sm: 8px;
    --radius-md: 16px;
    --radius-lg: 24px;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-hover: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

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

body {
    font-family: var(--font-body);
    background-color: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
}

/* ==========================================================================
   Utilities
   ========================================================================== */
.hidden {
    display: none !important;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* ==========================================================================
   Layout
   ========================================================================== */
.hero {
    position: relative;
    min-height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 60px 20px 80px;
    background: #000;
    overflow: hidden;
}

.hero-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('https://offertabs.s3.amazonaws.com/offer/q9jkm4/site/media/6a6906f2919d53.47838522.jpg');
    background-size: cover;
    background-position: center;
    opacity: 0.5;
    z-index: 0;
}

.hero::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 150px;
    background: linear-gradient(to top, var(--color-bg), transparent);
    z-index: 1;
    pointer-events: none;
}

.hero-content {
    position: relative;
    z-index: 2;
    max-width: 800px;
}

.hero-tag {
    display: inline-block;
    padding: 6px 16px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #fff;
    font-size: 0.875rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    margin-bottom: 20px;
}

.hero-title {
    font-family: var(--font-heading);
    font-size: clamp(2.5rem, 5vw, 4.5rem);
    font-weight: 800;
    color: #fff;
    line-height: 1.1;
    margin-bottom: 24px;
    text-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.hero-subtitle {
    font-size: 1.05rem;
    color: rgba(255, 255, 255, 0.95);
    max-width: 800px;
    margin: 0 auto;
    background: rgba(0, 0, 0, 0.65);
    padding: 32px;
    border-radius: var(--radius-md);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.contest-description p {
    margin-bottom: 1rem;
}

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

.rules-section {
    margin-top: 2rem;
    background: rgba(255, 255, 255, 0.08);
    padding: 24px;
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 255, 255, 0.15);
    text-align: left;
}

.rules-title {
    margin-bottom: 12px !important;
    font-size: 1.1rem;
    color: #fff;
    text-align: center;
}

.rules-section ul {
    list-style-type: disc;
    padding-left: 20px;
    margin: 0 auto;
    max-width: 700px;
}

.rules-section li {
    margin-bottom: 8px;
    line-height: 1.5;
}

.rules-section li:last-child {
    margin-bottom: 0;
}

.main-container {
    max-width: 1200px;
    margin: -40px auto 60px;
    padding: 0 20px;
    position: relative;
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 40px;
}

/* ==========================================================================
   Cards & Panels
   ========================================================================== */
.card {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    padding: 40px;
    box-shadow: var(--shadow-lg);
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
}

.card-header {
    text-align: center;
    margin-bottom: 30px;
}

.card-header h2 {
    font-family: var(--font-heading);
    font-size: 2rem;
    color: var(--color-primary);
    margin-bottom: 8px;
}

.card-header p {
    color: var(--color-text-muted);
}

/* ==========================================================================
   Form Styles
   ========================================================================== */
form {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.form-row {
    display: flex;
    gap: 20px;
}

.form-row .form-group {
    flex: 1;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

label {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--color-text);
}

input[type="text"],
input[type="email"],
textarea,
select {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-family: inherit;
    background: var(--color-bg);
    transition: all 0.2s ease;
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(91, 33, 182, 0.1);
    background: #fff;
}

select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b7280' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    padding-right: 40px;
}

/* File Dropzone */
.file-label {
    display: block;
    border: 2px dashed var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-bg);
    cursor: pointer;
    overflow: hidden;
    transition: all 0.2s ease;
    position: relative;
    min-height: 200px;
}

.file-label:hover {
    border-color: var(--color-primary);
    background: rgba(91, 33, 182, 0.02);
}

.file-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    height: 100%;
    color: var(--color-text-muted);
    text-align: center;
}

.file-placeholder svg {
    margin-bottom: 16px;
    color: var(--color-primary);
}

.file-placeholder span {
    font-weight: 500;
    margin-bottom: 4px;
    color: var(--color-text);
}

.file-placeholder small {
    font-size: 0.8rem;
}

.file-preview {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
}

.file-preview img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.remove-file-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(0,0,0,0.6);
    color: #fff;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.remove-file-btn:hover {
    background: var(--color-error);
}

/* Buttons */
.btn-primary,
.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 16px 24px;
    font-size: 1rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
    width: 100%;
}

.btn-primary {
    background: linear-gradient(135deg, var(--color-primary) 0%, #7c3aed 100%);
    color: #fff;
    box-shadow: 0 4px 12px rgba(91, 33, 182, 0.2);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(91, 33, 182, 0.3);
}

.btn-primary:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: var(--color-bg);
    color: var(--color-text);
    border: 1px solid var(--color-border);
}

.btn-secondary:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
}

/* Spinner */
.spinner {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.error-box {
    background: #fef2f2;
    border: 1px solid #f87171;
    color: #b91c1c;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
}

/* ==========================================================================
   Success Panel
   ========================================================================== */
#success-panel {
    text-align: center;
}

.success-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: #ecfdf5;
    color: var(--color-success);
    margin-bottom: 24px;
}

#success-panel h2 {
    font-family: var(--font-heading);
    font-size: 2rem;
    color: var(--color-primary);
    margin-bottom: 12px;
}

.my-upload-preview {
    margin: 30px auto;
    max-width: 400px;
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.share-panel {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 24px;
    margin-top: 30px;
}

.share-panel h3 {
    margin-bottom: 8px;
    color: var(--color-primary);
}

.share-input-group {
    display: flex;
    gap: 12px;
    margin-top: 16px;
}

.share-input-group input {
    flex: 1;
}

.share-input-group button {
    width: auto;
    padding: 0 24px;
}

/* ==========================================================================
   Gallery Section
   ========================================================================== */
.gallery-section {
    padding-top: 40px;
}

.section-header {
    text-align: center;
    margin-bottom: 40px;
}

.section-header h2 {
    font-family: var(--font-heading);
    font-size: 2.5rem;
    color: var(--color-primary);
    margin-bottom: 12px;
}

.filter-container {
    max-width: 300px;
    margin: 0 auto 30px;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 30px;
    margin-bottom: 40px;
}

.gallery-card {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: all 0.3s ease;
    cursor: pointer;
    display: flex;
    flex-direction: column;
}

.gallery-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-hover);
}

.img-wrapper {
    position: relative;
    padding-top: 100%; /* 1:1 Aspect ratio */
    overflow: hidden;
    background: var(--color-bg);
}

.gallery-thumb {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.gallery-card:hover .gallery-thumb {
    transform: scale(1.05);
}

.view-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.view-overlay span {
    background: rgba(255,255,255,0.9);
    color: var(--color-text);
    padding: 8px 16px;
    border-radius: 999px;
    font-weight: 600;
    font-size: 0.85rem;
    transform: translateY(10px);
    transition: transform 0.3s ease;
}

.gallery-card:hover .view-overlay {
    opacity: 1;
}

.gallery-card:hover .view-overlay span {
    transform: translateY(0);
}

.category-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    background: rgba(0,0,0,0.6);
    color: #fff;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    backdrop-filter: blur(4px);
    z-index: 2;
}

.card-content {
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    flex: 1;
}

.card-text {
    flex: 1;
    min-width: 0;
}

.card-caption {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-author {
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

.grid-vote-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 999px;
    color: var(--color-text);
    font-weight: 600;
    font-size: 0.85rem;
    transition: all 0.2s;
    z-index: 2; /* keep clickable over card */
}

.grid-vote-btn:hover:not(:disabled) {
    background: #fee2e2;
    border-color: #fca5a5;
    color: #ef4444;
}

.grid-vote-btn svg {
    width: 16px;
    height: 16px;
}

.grid-vote-btn.voted {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
    cursor: default;
}

.grid-vote-btn.voted svg {
    fill: currentColor;
}

.grid-vote-btn.category-voted {
    background: #e5e7eb;
    border-color: #d1d5db;
    color: #9ca3af;
    cursor: not-allowed;
}
.grid-vote-btn.category-voted svg {
    fill: none;
    stroke: currentColor;
}

.gallery-actions {
    text-align: center;
}

.gallery-actions .btn-secondary {
    width: auto;
    min-width: 200px;
}

.gallery-empty {
    text-align: center;
    padding: 60px 20px;
    background: var(--color-surface);
    border-radius: var(--radius-md);
    color: var(--color-text-muted);
}

/* ==========================================================================
   Lightbox
   ========================================================================== */
.lightbox-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.lightbox-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.9);
    backdrop-filter: blur(5px);
}

.lightbox-content {
    position: relative;
    z-index: 101;
    max-width: 1200px;
    width: 100%;
    max-height: 90vh;
    background: #000;
    border-radius: var(--radius-md);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.lightbox-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(0,0,0,0.5);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 102;
    transition: background 0.2s;
}

.lightbox-close:hover {
    background: rgba(255,255,255,0.2);
}

.lightbox-body {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-height: 90vh;
}

#lightbox-img {
    width: 100%;
    height: 100%;
    max-height: calc(90vh - 100px);
    object-fit: contain;
    background: #111;
}

.lightbox-info {
    background: var(--color-surface);
    padding: 24px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.lightbox-text {
    flex: 1;
}

.lightbox-text h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.lightbox-text p {
    color: var(--color-text-muted);
}

#lightbox-vote-btn {
    width: auto;
    padding: 12px 24px;
    min-width: 160px;
}

#lightbox-vote-btn svg {
    width: 20px;
    height: 20px;
}

#lightbox-vote-btn.voted {
    background: var(--color-success);
    border-color: var(--color-success);
    color: #fff;
    cursor: default;
}

#lightbox-vote-btn.voted svg {
    fill: currentColor;
}

#lightbox-vote-btn.category-voted {
    background: #e5e7eb;
    border-color: #d1d5db;
    color: #9ca3af;
    cursor: not-allowed;
}

.vote-count-badge {
    background: rgba(0,0,0,0.2);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.85rem;
    margin-left: 4px;
}

/* ==========================================================================
   QR Code Panel
   ========================================================================== */
.qr-code-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 30px;
}
.qr-code-panel h3 {
    font-family: var(--font-heading);
    color: var(--color-primary);
    font-size: 1.5rem;
    margin-bottom: 8px;
}
.qr-code-wrapper {
    background: #fff;
    padding: 16px;
    border-radius: var(--radius-sm);
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    border: 1px solid var(--color-border);
    display: inline-block;
    margin: 16px 0;
}
.qr-code-wrapper img {
    width: 160px;
    height: 160px;
    display: block;
}
.qr-url-text {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--color-text-muted);
    word-break: break-all;
    max-width: 100%;
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 768px) {
    .form-row {
        flex-direction: column;
        gap: 24px;
    }
    
    .card {
        padding: 24px;
    }
    
    .lightbox-info {
        flex-direction: column;
        align-items: flex-start;
        padding: 16px;
    }
    
    #lightbox-vote-container,
    #lightbox-vote-btn {
        width: 100%;
    }
    
    #lightbox-img {
        max-height: calc(90vh - 160px);
    }
}
