/* ============================================================================
   GLOBAL STYLES
   ============================================================================ */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #2c3e50;
}

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

/* ============================================================================
   BUTTONS
   ============================================================================ */

.btn {
    display: inline-block;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    text-align: center;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background-color: #3498db;
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background-color: #2980b9;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.btn-secondary {
    background-color: #95a5a6;
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background-color: #7f8c8d;
}

.btn-success {
    background-color: #2ecc71;
    color: white;
}

.btn-success:hover:not(:disabled) {
    background-color: #27ae60;
}

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

.btn-warning:hover:not(:disabled) {
    background-color: #e67e22;
}

.btn-danger {
    background-color: #e74c3c;
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background-color: #c0392b;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.875rem;
}

.btn-large {
    padding: 15px 30px;
    font-size: 1.125rem;
}

/* ============================================================================
   ADMIN PAGE
   ============================================================================ */

.admin-page {
    background: white;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid #ecf0f1;
}

.admin-header h1 {
    font-size: 2rem;
    color: #2c3e50;
}

/* Tabs */
.admin-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
    border-bottom: 2px solid #ecf0f1;
}

.tab-btn {
    padding: 12px 24px;
    border: none;
    background: none;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    color: #7f8c8d;
    border-bottom: 3px solid transparent;
    transition: all 0.3s ease;
}

.tab-btn:hover {
    color: #3498db;
}

.tab-btn.active {
    color: #3498db;
    border-bottom-color: #3498db;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Images Grid */
.images-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.image-card {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease;
}

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

.image-card img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    display: block;
}

.image-card .image-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.image-card .filename {
    font-size: 0.875rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.toggle-btn {
    padding: 5px 10px;
    border: none;
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: pointer;
    font-weight: 600;
}

.toggle-btn.active {
    background-color: #2ecc71;
    color: white;
}

.toggle-btn.inactive {
    background-color: #e74c3c;
    color: white;
}

/* Poll Control */
.poll-control {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.qr-section {
    text-align: center;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
}

#qr-display {
    margin-top: 20px;
}

#qr-image {
    max-width: 300px;
    height: auto;
    margin: 20px auto;
    display: block;
}

#qr-url {
    font-size: 1.125rem;
    font-weight: 600;
    color: #3498db;
    word-break: break-all;
}

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

.poll-status {
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
}

#status-info {
    margin-top: 10px;
    font-size: 1rem;
}

.current-group {
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
}

#group-images {
    display: flex;
    gap: 15px;
    margin-top: 15px;
    flex-wrap: wrap;
}

.group-image-preview {
    width: 150px;
    height: 150px;
    object-fit: cover;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

#group-submissions {
    margin-top: 15px;
    font-weight: 600;
    font-size: 1.125rem;
    color: #2c3e50;
}

/* Results */
.results-toggle {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.result-btn {
    padding: 10px 20px;
    border: 2px solid #3498db;
    background: white;
    color: #3498db;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.result-btn:hover {
    background: #3498db;
    color: white;
}

.result-btn.active {
    background: #3498db;
    color: white;
}

.results-section {
    display: none;
}

.results-section.active {
    display: block;
}

.result-item {
    margin-bottom: 30px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
}

.result-item-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
}

.result-item-header img {
    width: 100px;
    height: 100px;
    object-fit: cover;
    border-radius: 8px;
}

.result-bars {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.result-bar {
    display: flex;
    align-items: center;
    gap: 10px;
}

.result-label {
    min-width: 60px;
    font-weight: 600;
}

.bar-container {
    flex: 1;
    height: 30px;
    background: #ecf0f1;
    border-radius: 15px;
    overflow: hidden;
    position: relative;
}

.bar-fill {
    height: 100%;
    border-radius: 15px;
    transition: width 0.5s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 0.875rem;
}

.bar-fill.marry {
    background: linear-gradient(90deg, #2ecc71, #27ae60);
}

.bar-fill.f {
    background: linear-gradient(90deg, #e74c3c, #c0392b);
}

.bar-fill.kill {
    background: linear-gradient(90deg, #34495e, #2c3e50);
}

/* ============================================================================
   POLL PAGE (USER INTERFACE)
   ============================================================================ */

.poll-page {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    max-width: 800px;
    margin: 0 auto;
}

.poll-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #ecf0f1;
}

.poll-header h1 {
    font-size: 1.75rem;
    color: #2c3e50;
}

.status-message {
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    text-align: center;
    font-weight: 600;
}

.status-message.info {
    background: #d4edff;
    color: #0066cc;
}

.status-message.success {
    background: #d4edda;
    color: #155724;
}

.status-message.error {
    background: #f8d7da;
    color: #721c24;
}

.waiting-screen {
    text-align: center;
    padding: 60px 20px;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 6px solid #ecf0f1;
    border-top-color: #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

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

.poll-active {
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.instructions {
    text-align: center;
    margin-bottom: 30px;
    font-size: 1.125rem;
    color: #555;
}

.drop-zones {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-bottom: 30px;
}

.drop-zone {
    text-align: center;
}

.drop-zone h3 {
    margin-bottom: 10px;
    font-size: 1.25rem;
}

.drop-area {
    min-height: 200px;
    border: 3px dashed #bdc3c7;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
    transition: all 0.3s ease;
    position: relative;
}

.drop-area.drag-over {
    border-color: #3498db;
    background: #e3f2fd;
    transform: scale(1.05);
}

.drop-placeholder {
    color: #95a5a6;
    font-style: italic;
}

.drop-area img {
    max-width: 100%;
    max-height: 180px;
    object-fit: contain;
    border-radius: 8px;
}

.images-pool {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.draggable-image {
    width: 150px;
    height: 150px;
    object-fit: cover;
    border-radius: 12px;
    cursor: grab;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.draggable-image:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
}

.draggable-image.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

#submit-btn {
    width: 100%;
    margin-top: 20px;
}

.poll-results {
    animation: fadeIn 0.5s ease;
}

.waiting-next {
    text-align: center;
    margin-top: 30px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
}

/* ============================================================================
   RESPONSIVE DESIGN
   ============================================================================ */

@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    .admin-page,
    .poll-page {
        padding: 15px;
    }

    .admin-header h1,
    .poll-header h1 {
        font-size: 1.5rem;
    }

    .images-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 10px;
    }

    .drop-zones {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .drop-area {
        min-height: 150px;
    }

    .images-pool {
        gap: 10px;
    }

    .draggable-image {
        width: 120px;
        height: 120px;
    }

    .admin-tabs {
        overflow-x: auto;
    }

    .tab-btn {
        white-space: nowrap;
    }

    .poll-actions {
        flex-direction: column;
    }

    .poll-actions .btn {
        width: 100%;
    }

    #group-images {
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .draggable-image {
        width: 100px;
        height: 100px;
    }

    .drop-area {
        min-height: 120px;
    }
}
