/* style.css 전체 */
:root {
    --primary-color: #ff5e00;
    --bg-color: #fcf7f0;
    --text-color: #333;
}

body { font-family: 'Pretendard', sans-serif; background-color: var(--bg-color); color: var(--text-color); margin: 0; padding: 20px; }

/* -------------------------------------- */
/* 🚀 상단 네비게이션 바 */
/* -------------------------------------- */
.top-nav {
    display: flex; justify-content: space-between; align-items: center; width: 100%;
    box-sizing: border-box; padding: 12px 20px; background: #fff; border-radius: 12px;
    max-width: 1000px; margin: 0 auto 20px auto; box-shadow: 0 4px 15px rgba(0,0,0,0.04);
}
.nav-left { display: flex; align-items: center; }
.nav-right { display: flex; align-items: center; margin-left: auto; gap: 8px; }
.site-logo { display: flex; align-items: center; text-decoration: none; }
.logo-img { height: 60px; margin-top: -15px; margin-bottom: -15px; display: block; transition: transform 0.2s; }
.logo-img:hover { transform: scale(1.05); }
.site-logo:hover { color: #e05300; }
.nav-btn {
    display: inline-block; padding: 8px 16px; border-radius: 20px;
    font-size: 0.9rem; font-weight: bold; text-decoration: none;
    transition: all 0.2s ease-in-out; white-space: nowrap;
}
.nav-btn:active { transform: scale(0.95); } 
.btn-admin { background: #fee2e2; color: #dc2626; }
.btn-admin:hover { background: #fecaca; transform: translateY(-2px); }
.btn-logout { background: #f3f4f6; color: #4b5563; }
.btn-logout:hover { background: #e5e7eb; transform: translateY(-2px); }
.btn-login { background: var(--primary-color); color: #fff; box-shadow: 0 2px 8px rgba(255, 94, 0, 0.3); }
.btn-login:hover { background: #e05300; transform: translateY(-2px); box-shadow: 0 4px 12px rgba(255, 94, 0, 0.4); }
.welcome-msg { font-size: 0.95rem; color: #444; margin-right: 5px; white-space: nowrap; }

/* -------------------------------------- */
/* 1. 하단/메인 투표 카드 리스트 UI */
/* -------------------------------------- */
.main-container { max-width: 1000px; margin: 0 auto; }
.hero-section { text-align: center; margin-bottom: 40px; }
.hero-section h1 { font-size: 2.5rem; color: var(--primary-color); margin-bottom: 10px; }
.hero-section p { font-size: 1.1rem; color: #666; }
.poll-list-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 20px; }
.poll-card { display: block; background: #fff; border-radius: 12px; overflow: hidden; text-decoration: none; color: inherit; box-shadow: 0 4px 10px rgba(0,0,0,0.05); transition: transform 0.3s, box-shadow 0.3s; }
.poll-card:hover { transform: translateY(-5px); box-shadow: 0 10px 20px rgba(0,0,0,0.1); }
.poll-card-img { position: relative; width: 100%; height: 150px; overflow: hidden; background: #eee; }
.poll-card-img img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.5s; }
.poll-card:hover .poll-card-img img { transform: scale(1.1); } 
.img-category-badge { 
    position: absolute; top: 8px; left: 8px; background: rgba(255, 255, 255, 0.95); 
    color: var(--primary-color); padding: 5px 12px; border-radius: 15px; 
    font-size: 0.75rem; font-weight: 800; box-shadow: 0 2px 6px rgba(0,0,0,0.15); 
    backdrop-filter: blur(2px); border: 1px solid rgba(255, 94, 0, 0.1);
}
.poll-card-content { padding: 15px; }
.card-title-wrap { margin-bottom: 8px; }
.card-category { font-size: 0.7rem; color: var(--primary-color); background: #fff0e6; padding: 3px 8px; border-radius: 10px; font-weight: bold; white-space: nowrap; flex-shrink: 0; margin-top: 2px; }
.card-title-wrap h3 { font-size: 1.05rem; margin: 0; line-height: 1.4; color: #222; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; text-overflow: ellipsis; white-space: normal; word-break: keep-all; }
.poll-card-meta { font-size: 0.85rem; color: #888; margin: 0; }

/* -------------------------------------- */
/* 🔥 메인 화면 카테고리 네비게이션 버튼 */
/* -------------------------------------- */
.category-nav {
    display: flex;
    gap: 10px;
    margin-bottom: 25px;
    overflow-x: auto; /* 내용이 길면 가로 스크롤 허용 */
    padding: 5px 0px;
    white-space: nowrap;
    -ms-overflow-style: none;  /* IE/Edge 스크롤바 숨김 */
    scrollbar-width: none;  /* 파이어폭스 스크롤바 숨김 */
}
.category-nav::-webkit-scrollbar {
    display: none; /* 크롬/사파리 스크롤바 숨김 (깔끔하게 버튼만 보이게) */
}
.cat-btn {
    padding: 8px 18px;
    background: #ffffff;
    border: 1px solid #ddd;
    border-radius: 20px;
    color: #555;
    font-size: 0.95rem;
    font-weight: bold;
    text-decoration: none;
    transition: all 0.2s ease-in-out;
    box-shadow: 0 2px 5px rgba(0,0,0,0.02);
}
.cat-btn:hover {
    background: #f8f8f8;
    transform: translateY(-2px);
}
.cat-btn.active {
    background: var(--primary-color);
    color: #ffffff;
    border-color: var(--primary-color);
    box-shadow: 0 4px 10px rgba(255, 94, 0, 0.3);
}

/* -------------------------------------- */
/* 2. 개별 투표 화면 UI */
/* -------------------------------------- */
.poll-container { max-width: 940px; margin: 0 auto; background: #fff; padding: 30px; border-radius: 15px; box-shadow: 0 5px 20px rgba(0,0,0,0.05); }
.poll-title { text-align: center; margin-bottom: 25px; font-size: 1.7rem; line-height: 1.3; }
.poll-grid { display: grid; grid-template-columns: repeat(var(--cols, 3), 1fr); gap: 15px; margin-bottom: 20px; }
.poll-item { overflow: visible !important; display: flex; flex-direction: column; height: 100%; min-width: 0; }
.poll-item:hover { transform: translateY(-3px); box-shadow: 0 8px 15px rgba(0,0,0,0.1); }
.poll-item img { order: 1; border-radius: 8px 8px 0 0; width: 100%; flex-shrink: 0; }
.poll-item .item-label { order: 2; flex-grow: 1; display: flex; align-items: center; justify-content: center; padding: 12px 10px; text-align: center; word-break: keep-all; }
.poll-item.selected { border-color: var(--primary-color); transform: scale(0.97); }
.poll-item .check-overlay { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%) scale(0); font-size: 4rem; color: var(--primary-color); font-weight: bold; opacity: 0; transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275); text-shadow: 0 0 10px rgba(255,255,255,0.8); }
.poll-item.selected .check-overlay { transform: translate(-50%, -50%) scale(1); opacity: 1; }

/* 투표 바 */
.vote-bar-container { display: none !important; }
.poll-container.voted .vote-bar-container { display: block !important; position: relative !important; order: 3; border-radius: 0 0 8px 8px; background: rgba(0, 0, 0, 0.15); overflow: hidden; width: 100%; height: 35px !important; flex-shrink: 0; }
.poll-container.voted .vote-percent { position: absolute !important; top: 0 !important; left: 0 !important; width: 100% !important; height: 100% !important; line-height: 35px !important; text-align: center !important; color: #fff !important; font-weight: bold !important; font-size: 0.9rem !important; z-index: 10 !important; pointer-events: none; }
.poll-container.voted .vote-bar { position: absolute !important; top: 0 !important; left: 0 !important; height: 100% !important; background: var(--primary-color) !important; z-index: 1 !important; }
.vote-bar { height: 100%; background: var(--primary-color); transition: width 1s ease-in-out; width: 0; }
.vote-percent { color: #fff; z-index: 2; }
.voted .vote-bar-container { display: block; }

.submit-btn { display: block; width: 100%; padding: 15px; background: var(--primary-color); color: #fff; border: none; border-radius: 8px; font-size: 1.1rem; font-weight: bold; cursor: pointer; transition: background 0.3s; }
.submit-btn:hover { background: #e05300; }

/* -------------------------------------- */
/* 🔥 내가 투표한 항목(MY PICK) 뱃지 */
/* -------------------------------------- */
.poll-item.my-pick-active { border-color: var(--primary-color); box-shadow: 0 0 15px rgba(255, 94, 0, 0.4); transform: scale(0.98); z-index: 50 !important; }
.my-pick-badge { position: absolute; top: -8px; right: -8px; background: #ff5e00; color: #fff; font-weight: 900; font-size: 0.8rem; padding: 5px 12px; border-radius: 20px; box-shadow: 0 4px 10px rgba(0,0,0,0.3); z-index: 10; transform: rotate(10deg); animation: popPick 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
@keyframes popPick { 0% { transform: scale(0) rotate(0deg); } 100% { transform: scale(1) rotate(10deg); } }


/* -------------------------------------- */
/* 🌟 완벽하게 크기를 맞춘 하단 3개 버튼 🌟 */
/* -------------------------------------- */

/* 1. 부모 컨테이너의 높이를 고정하고 위쪽으로 정렬 */
.action-buttons-wrap {
    display: flex;
    justify-content: space-between;
    align-items: flex-start; /* 🔥 flex-start로 윗선을 완전히 맞춰버립니다 */
    gap: 10px;
    margin: 30px 0;
    width: 100%;
    height: 55px; /* 🔥 부모 높이 고정 */
    flex-wrap: nowrap;
}

/* 2. share.php 안에 숨겨진 모든 껍데기의 마진을 파괴 */
.share-wrapper,
.share-wrapper > div,
.share-wrapper > form {
    display: flex !important;
    flex: 1 !important;
    height: 100% !important;
    margin: 0 !important; /* 🔥 이 부분이 핵심! 숨은 여백 제거 */
    padding: 0 !important;
    border: none !important;
    background: transparent !important;
    vertical-align: top !important;
}
.share-wrapper script { display: none !important; }

/* 3. 진짜 알맹이 버튼들 강제 규격 통일 */
.action-btn, 
.share-wrapper button, 
.share-wrapper a, 
.share-btn {
    display: flex !important;
    flex: 1 !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100% !important;
    height: 55px !important; /* 🔥 모든 버튼 높이 55px로 멱살잡고 고정 */
    margin: 0 !important; /* 위아래로 밀리는 현상 완벽 차단 */
    padding: 0 10px !important;
    border-radius: 12px !important;
    font-family: 'Pretendard', sans-serif !important;
    font-weight: 800 !important;
    font-size: 1rem !important;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    box-sizing: border-box !important;
    white-space: nowrap;
    outline: none !important;
    vertical-align: top !important;
}
.action-btn i { margin-right: 6px !important; font-style: normal; font-size: 1.1rem; }

/* 🎨 버튼 색상 테마 */
.share-wrapper button,
.share-wrapper a,
.share-btn { /* 공유 버튼 */
    background-color: #ffffff !important; color: #444 !important;
    border: 2px solid #ddd !important; box-shadow: 0 4px 10px rgba(0,0,0,0.03) !important;
}
.share-wrapper button:hover,
.share-wrapper a:hover,
.share-btn:hover { background-color: #f8f9fa !important; transform: translateY(-3px); }

.btn-save-custom { /* 저장 버튼 */
    background-color: #ffffff !important; color: var(--primary-color) !important;
    border: 2px solid var(--primary-color) !important; box-shadow: 0 4px 10px rgba(255, 94, 0, 0.05) !important;
}
.btn-save-custom:hover { background-color: #fff5f0 !important; transform: translateY(-3px); }

.btn-next-custom { /* 다음 버튼 */
    background-color: var(--primary-color) !important; color: #ffffff !important;
    border: 2px solid var(--primary-color) !important; box-shadow: 0 4px 10px rgba(255, 94, 0, 0.25) !important;
}
.btn-next-custom:hover { background-color: #e05300 !important; transform: translateY(-3px); }

/* -------------------------------------- */
/* 3. 댓글 및 팝업 (기존 디자인 유지) */
/* -------------------------------------- */
.comments-section { margin-top: 30px; border-top: 2px dashed #eee; padding-top: 20px; }
.comments-section h2 { font-size: 1.3rem; margin-bottom: 15px; }
.comment-box { background: #f9f9f9; padding: 12px 15px; border-radius: 8px; margin-bottom: 10px; }
.comment-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 5px; font-weight: bold; }
.comment-content { font-size: 0.95rem; line-height: 1.4; color: #222; }
.comment-actions { margin-top: 8px; text-align: right; }
.comment-actions button { border: none; background: #eaeaea; padding: 5px 8px; border-radius: 5px; cursor: pointer; margin-left: 5px; font-size: 0.8rem; font-weight: 600; color: #555; transition: background 0.2s; }
.comment-actions button:hover { background: #ddd; }
.btn-voted-up { background-color: var(--primary-color) !important; color: #fff !important; border: 1px solid var(--primary-color); }
.btn-voted-down { background-color: #007bff !important; color: #fff !important; border: 1px solid #007bff; }
.comment-form-container { margin-top: 25px; background: #fdfdfd; padding: 15px; border-radius: 8px; border: 1px solid #eaeaea; }
.comment-form-container h3 { font-size: 1.1rem; margin-top: 0; margin-bottom: 10px; }
.comment-form input[type="text"], .comment-form textarea { width: 100%; padding: 10px; margin-bottom: 8px; border: 1px solid #ccc; border-radius: 5px; box-sizing: border-box; font-family: inherit; font-size: 0.95rem; }
.comment-form input[type="text"]:focus, .comment-form textarea:focus { border-color: var(--primary-color); outline: none; }
.comment-form textarea { resize: vertical; min-height: 60px; }
.logged-in-user-box { padding: 10px; background: #f1f8ff; border: 1px solid #cce5ff; border-radius: 5px; margin-bottom: 8px; color: #004085; font-size: 0.9rem; }

/* 커스텀 알림 */
#custom-alert-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.4); z-index: 10000; display: flex; justify-content: center; align-items: center; opacity: 0; visibility: hidden; transition: all 0.3s ease; backdrop-filter: blur(2px); }
#custom-alert-overlay.show { opacity: 1; visibility: visible; }
.custom-alert-box { background: #fff; width: 85%; max-width: 320px; padding: 30px 20px; border-radius: 25px; text-align: center; box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2); transform: scale(0.8) translateY(20px); transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
#custom-alert-overlay.show .custom-alert-box { transform: scale(1) translateY(0); }
.custom-alert-icon { font-size: 3.5rem; margin-bottom: 10px; display: inline-block; animation: floatIcon 1.5s infinite alternate ease-in-out; }
.custom-alert-msg { font-size: 1.05rem; color: #444; margin-bottom: 25px; line-height: 1.6; font-weight: 700; word-break: keep-all; }
.custom-alert-btn { background: var(--primary-color); color: #fff; border: none; padding: 12px 40px; border-radius: 25px; font-size: 1.1rem; font-weight: bold; cursor: pointer; transition: 0.2s; box-shadow: 0 4px 10px rgba(255, 94, 0, 0.3); }
.custom-alert-btn:hover { background: #e05300; transform: translateY(-3px); box-shadow: 0 6px 15px rgba(255, 94, 0, 0.4); }
@keyframes floatIcon { 0% { transform: translateY(0) rotate(-5deg); } 100% { transform: translateY(-10px) rotate(5deg); } }

/* -------------------------------------- */
/* 📱 모바일 화면 최적화 */
/* -------------------------------------- */
@media (max-width: 768px) {
    body { padding: 10px; } 
    .poll-container { padding: 10px;}
    .top-nav { padding: 10px 15px; }
    .nav-btn { padding: 6px 12px; font-size: 0.8rem; margin-left: 4px; }
    .welcome-msg { display: none; } 
    
    .hero-section { margin-bottom: 25px; }
    .hero-section h1 { font-size: 1.6rem; margin-bottom: 5px; }
    .poll-list-grid { gap: 10px; grid-template-columns: repeat(2, 1fr); }
    .poll-card-img { height: 110px; } 
    .poll-card-content { padding: 10px; }
    .card-title-wrap h3 { font-size: 0.9rem; }

    .poll-container[style*="--cols: 2"] .poll-item img { height: auto !important; aspect-ratio: 1 / 1; object-fit: cover; }
    .poll-title { font-size: 1.3rem; margin-bottom: 15px; }
    .poll-grid { gap: 8px; margin-bottom: 15px; }
    .poll-item { border-radius: 8px; }
    .poll-item img { height: 110px; } 
    .poll-item .item-label { padding: 6px; font-size: 0.85rem; }
    .vote-bar-container { height: 28px; }
    .vote-percent { line-height: 28px; font-size: 0.8rem; }
    .submit-btn { padding: 12px; font-size: 1rem; }
    
    .comments-section { margin-top: 20px; padding-top: 15px; }
    .comments-section h2 { font-size: 1.1rem; margin-bottom: 10px; }
    .comment-box { padding: 10px; margin-bottom: 8px; border-radius: 6px; }
    .comment-form-container { padding: 12px; margin-top: 15px; }

    .my-pick-badge { top: -10px !important; right: -5px !important; font-size: 0.7rem !important; padding: 4px 8px !important; }

/* 모바일에서 3개 버튼 레이아웃 (기존 코드 덮어쓰기) */
    .action-buttons-wrap { 
        height: 65px !important; /* 모바일 부모 높이 변경 */
        gap: 6px !important; 
        margin: 20px 0 !important; 
    }
    
    .action-btn, 
    .share-wrapper button, 
    .share-wrapper a, 
    .share-btn { 
        height: 65px !important; /* 모바일 알맹이 높이 변경 */
        padding: 5px 4px !important; 
        font-size: 0.75rem !important; 
        flex-direction: column !important; 
        justify-content: center !important;
        border-radius: 10px !important;
    }
    .action-btn i { margin-right: 0 !important; margin-bottom: 4px !important; font-size: 1.2rem !important; }
}