/* ==================== Global Styles ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #2d3748;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* ==================== Navbar ==================== */
.navbar {
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    padding: 15px 0;
    margin-bottom: 30px;
    position: sticky;
    top: 0;
    z-index: 1000;
    backdrop-filter: blur(10px);
}

.navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.nav-brand {
    font-size: 26px;
    font-weight: bold;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nav-menu {
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: wrap;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.user-name {
    font-weight: 500;
    color: #2d3748;
}

/* ==================== Flower Badges (เมนูบน) ==================== */
.flower-badge-group {
    display: flex;
    gap: 8px;
}

.flower-badge {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}

.flower-badge.total {
    background: linear-gradient(135deg, #ffeaa7 0%, #fdcb6e 100%);
    color: #2d3436;
}

.flower-badge.used {
    background: linear-gradient(135deg, #a29bfe 0%, #6c5ce7 100%);
    color: white;
}

.flower-badge.remaining {
    background: linear-gradient(135deg, #55efc4 0%, #00b894 100%);
    color: white;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

/* ==================== Buttons ==================== */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s;
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #e2e8f0;
    color: #2d3748;
}

.btn-secondary:hover {
    background: #cbd5e0;
}

.btn-success {
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    color: white;
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(72, 187, 120, 0.4);
}

.btn-admin {
    background: linear-gradient(135deg, #ed8936 0%, #dd6b20 100%);
    color: white;
}

.btn-admin:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(237, 137, 54, 0.4);
}

.btn-outline {
    background: transparent;
    border: 2px solid #667eea;
    color: #667eea;
}

.btn-outline:hover {
    background: #667eea;
    color: white;
}

.btn-danger {
    background: linear-gradient(135deg, #f56565 0%, #e53e3e 100%);
    color: white;
}

.btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(245, 101, 101, 0.4);
}

/* ==================== Alerts ==================== */
.alert {
    padding: 16px 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    animation: slideDown 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 500;
}

.alert-success {
    background: linear-gradient(135deg, #c6f6d5 0%, #9ae6b4 100%);
    color: #22543d;
    border-left: 4px solid #38a169;
}

.alert-error {
    background: linear-gradient(135deg, #fed7d7 0%, #fc8181 100%);
    color: #742a2a;
    border-left: 4px solid #e53e3e;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==================== Section Headers ==================== */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    flex-wrap: wrap;
    gap: 15px;
}

.section-header h2 {
    font-size: 28px;
    color: white;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
}

/* ==================== Photo Gallery (ปรับใหม่) ==================== */
.activity-section {
    background: white;
    padding: 30px;
    border-radius: 15px;
    margin-bottom: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

.photo-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.photo-card {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
    transition: all 0.3s ease;
}

.photo-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}

.photo-image {
    position: relative;
    width: 100%;
    height: 220px; /* ขนาดคงที่ */
    overflow: hidden;
    background: #f7fafc;
    cursor: pointer;
}

.photo-image img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* ครอบคลุมพื้นที่โดยไม่บิดเบือน */
    transition: transform 0.3s ease;
}

.photo-image:hover img {
    transform: scale(1.05);
}

.photo-controls {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    gap: 8px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.photo-card:hover .photo-controls {
    opacity: 1;
}

.control-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,0.95);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    transition: all 0.3s ease;
}

.control-btn:hover {
    transform: scale(1.1);
}

.control-btn.edit:hover {
    background: #fef5e7;
}

.control-btn.delete:hover {
    background: #fadbd8;
}

.photo-info {
    padding: 15px;
}

.photo-caption {
    color: #2d3748;
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 10px;
    word-wrap: break-word;
    max-height: 60px; /* จำกัดความสูง */
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 3; /* แสดงสูงสุด 3 บรรทัด */
    -webkit-box-orient: vertical;
}

.photo-meta {
    display: flex;
    flex-direction: column;
    gap: 5px;
    font-size: 12px;
    color: #718096;
}

.meta-author {
    font-weight: 500;
    color: #4a5568;
}

/* ==================== Contest Section (ปรับใหม่) ==================== */
.contest-section {
    margin-bottom: 30px;
}

.category-container {
    background: white;
    border-radius: 15px;
    padding: 30px;
    margin-bottom: 25px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

.category-header {
    margin-bottom: 25px;
}

.category-title {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 10px;
}

.category-number {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: bold;
    flex-shrink: 0;
}

.category-title h3 {
    font-size: 24px;
    color: #2d3748;
    margin: 0;
}

.category-description {
    color: #718096;
    margin-bottom: 20px;
    line-height: 1.6;
}

/* ==================== Category Flower Info (ใหม่) ==================== */
.category-flower-info {
    background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    justify-content: space-around;
    gap: 20px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.flower-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.stat-label {
    font-size: 13px;
    color: #718096;
    font-weight: 500;
}

.stat-value {
    font-size: 24px;
    font-weight: bold;
    padding: 8px 16px;
    border-radius: 20px;
}

.stat-value.total {
    background: linear-gradient(135deg, #ffeaa7 0%, #fdcb6e 100%);
    color: #2d3436;
}

.stat-value.used {
    background: linear-gradient(135deg, #a29bfe 0%, #6c5ce7 100%);
    color: white;
}

.stat-value.remaining {
    background: linear-gradient(135deg, #55efc4 0%, #00b894 100%);
    color: white;
    animation: pulse 2s infinite;
}

/* ==================== Contestants Grid (ปรับใหม่) ==================== */
.contestants-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
}

.contestant-card {
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    padding: 15px;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
}

.contestant-card:hover {
    border-color: #667eea;
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.15);
    transform: translateY(-3px);
}

.contestant-badge {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    display: inline-block;
    align-self: center;
    margin-bottom: 12px;
}

.contestant-photo {
    width: 100%;
    height: 200px; /* ขนาดคงที่ */
    border-radius: 10px;
    overflow: hidden;
    background: #f7fafc;
    margin-bottom: 15px;
}

.contestant-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* ครอบคลุมพื้นที่ */
    transition: transform 0.3s ease;
}

.contestant-card:hover .contestant-photo img {
    transform: scale(1.05);
}

.no-photo-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #cbd5e0;
}

.no-photo-placeholder span {
    font-size: 48px;
    margin-bottom: 10px;
}

.no-photo-placeholder p {
    font-size: 14px;
}

.contestant-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.contestant-name {
    font-size: 16px;
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 12px;
    text-align: center;
}

/* ==================== Vote Button (ปรับใหม่ - ชัดเจนขึ้น) ==================== */
.btn-vote {
    width: 100%;
    padding: 12px 20px;
    background: linear-gradient(135deg, #ed64a6 0%, #d53f8c 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(237, 100, 166, 0.3);
}

.btn-vote:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(237, 100, 166, 0.5);
    background: linear-gradient(135deg, #f687b3 0%, #ed64a6 100%);
}

.btn-vote .vote-icon {
    font-size: 20px;
    animation: bounce 1s infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
}

.vote-disabled {
    width: 100%;
    padding: 10px;
    background: #f7fafc;
    color: #a0aec0;
    border: 2px dashed #e2e8f0;
    border-radius: 8px;
    text-align: center;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

/* ==================== Admin Score Display ==================== */
.admin-score {
    display: flex;
    gap: 15px;
    margin-bottom: 12px;
    padding: 10px;
    background: #f7fafc;
    border-radius: 8px;
}

.score-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.score-icon {
    font-size: 20px;
}

.score-number {
    font-size: 20px;
    font-weight: bold;
    color: #667eea;
}

.score-label {
    font-size: 11px;
    color: #718096;
}

/* ==================== Vote Modal (ปรับใหม่) ==================== */
.vote-modal {
    max-width: 450px;
}

.vote-modal-header {
    text-align: center;
    margin-bottom: 25px;
}

.vote-icon-large {
    font-size: 64px;
    margin-bottom: 15px;
    animation: bounce 1s infinite;
}

.vote-remaining-info {
    background: linear-gradient(135deg, #fef5e7 0%, #ffeaa7 100%);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    margin-bottom: 25px;
}

.vote-remaining-info p {
    margin: 0;
    color: #2d3436;
    font-weight: 500;
}

.remaining-number {
    font-size: 48px;
    font-weight: bold;
    color: #f39c12;
    margin: 10px 0;
}

.flower-input-group {
    display: flex;
    align-items: center;
    gap: 15px;
    justify-content: center;
}

.flower-btn {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    border: 2px solid #667eea;
    background: white;
    color: #667eea;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.flower-btn:hover {
    background: #667eea;
    color: white;
    transform: scale(1.1);
}

.flower-input-group input {
    width: 80px;
    height: 50px;
    text-align: center;
    font-size: 24px;
    font-weight: bold;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    color: #667eea;
}

.btn-vote-submit {
    width: 100%;
    font-size: 18px;
    padding: 14px;
}

/* ==================== Empty States ==================== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #718096;
}

.empty-icon {
    font-size: 64px;
    margin-bottom: 15px;
    opacity: 0.5;
}

.empty-state p {
    font-size: 18px;
    margin-bottom: 20px;
}

.empty-state-small {
    text-align: center;
    padding: 40px 20px;
    color: #a0aec0;
    font-style: italic;
}

/* ==================== Modal Styles ==================== */
.modal {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.6);
    backdrop-filter: blur(5px);
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 35px;
    border-radius: 15px;
    width: 90%;
    max-width: 550px;
    position: relative;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.close {
    position: absolute;
    right: 20px;
    top: 15px;
    font-size: 32px;
    font-weight: bold;
    color: #a0aec0;
    cursor: pointer;
    transition: color 0.3s;
    line-height: 1;
}

.close:hover {
    color: #2d3748;
}

.modal-fullscreen {
    display: none;
    background-color: rgba(0,0,0,0.95);
    align-items: center;
    justify-content: center;
}

.modal-image-container {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
}

.modal-image-container img {
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 8px;
}

.modal-confirm {
    text-align: center;
    max-width: 450px;
}

.confirm-icon {
    font-size: 64px;
    margin-bottom: 20px;
}

/* ==================== Form Elements ==================== */
.form-group {
    margin-bottom: 25px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: #2d3748;
    font-weight: 500;
    font-size: 14px;
}

.form-group input[type="file"],
.form-group input[type="text"],
.form-group input[type="number"],
.form-group textarea {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.3s;
    font-family: inherit;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.form-hint {
    display: block;
    margin-top: 6px;
    font-size: 12px;
    color: #a0aec0;
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 30px;
}

.modal-actions .btn {
    min-width: 120px;
}

/* ==================== Spinner ==================== */
.spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.6s linear infinite;
    margin-right: 8px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ==================== Responsive ==================== */
@media (max-width: 1024px) {
    .contestants-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    }
}

@media (max-width: 768px) {
    .navbar .container {
        flex-direction: column;
        gap: 15px;
    }

    .nav-menu {
        width: 100%;
        justify-content: center;
    }

    .user-info {
        flex-direction: column;
        align-items: center;
        width: 100%;
    }

    .flower-badge-group {
        flex-wrap: wrap;
        justify-content: center;
    }

    .photo-gallery {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }

    .contestants-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    }

    .category-flower-info {
        flex-direction: column;
        gap: 15px;
    }

    .photo-controls {
        opacity: 1; /* แสดงตลอดบนมือถือ */
    }

    .modal-actions {
        flex-direction: column-reverse;
    }

    .modal-actions .btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .photo-gallery {
        grid-template-columns: 1fr;
    }

    .contestants-grid {
        grid-template-columns: 1fr;
    }

    .section-header h2 {
        font-size: 22px;
    }
}
