/* ========================================
   아파트 분양 테마 v3.0
   ======================================== */

:root {
    --apt-primary: #667eea;
    --apt-secondary: #764ba2;
    --apt-text: #333;
    --apt-bg: #f8f9fa;
    --apt-white: #fff;
    --apt-border: #e8eef5;
    --apt-shadow: 0 2px 12px rgba(0,0,0,0.08);
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body { font-family: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, sans-serif; background: var(--apt-bg); color: var(--apt-text); line-height: 1.6; }
a { text-decoration: none; color: inherit; }
img { max-width: 100%; height: auto; display: block; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; font-size: inherit; }

/* Layout */
.apt-wrap { max-width: 970px; margin: 30px auto; padding: 0 15px; display: flex; gap: 30px; }
.apt-sidebar { width: 320px; flex-shrink: 0; }
.apt-main { flex: 1; min-width: 0; }

/* Responsive */
@media (max-width: 820px) {
    .apt-wrap { flex-direction: column; margin: 0; padding: 15px; gap: 20px; }
    .apt-sidebar { width: 100%; display: none; }
    .apt-sidebar.mobile-visible { display: block; }
    .apt-main { width: 100%; }
    body { padding-bottom: 70px; }
}

/* ========== Sidebar ========== */
.apt-sidebar .sticky { position: sticky; top: 20px; }
.sidebar-card { background: var(--apt-white); border-radius: 12px; box-shadow: var(--apt-shadow); overflow: hidden; position: relative; }
.sidebar-header { height: 160px; background: linear-gradient(-45deg, var(--apt-primary), var(--apt-secondary)); background-size: cover; background-position: center; position: relative; }
.sidebar-logo { position: absolute; top: 20px; left: 25px; width: 70px; height: 70px; background: var(--apt-white); border-radius: 50%; box-shadow: 0 4px 12px rgba(0,0,0,0.1); display: flex; align-items: center; justify-content: center; overflow: hidden; font-weight: 700; font-size: 24px; color: var(--apt-primary); }
.sidebar-logo img { width: 100%; height: 100%; object-fit: cover; }
.sidebar-body { padding: 100px 25px 0; }
.sidebar-title { font-size: 13px; font-weight: 600; color: #666; }
.sidebar-name { font-size: 36px; font-weight: 700; margin-top: 5px; line-height: 1.2; }
.sidebar-name .pos { font-size: 16px; font-weight: 500; color: #999; margin-left: 8px; }
.sidebar-addr { font-size: 14px; color: #555; margin-top: 10px; }
.sidebar-phone { display: flex; align-items: center; background: #001b42; color: #fff; border-radius: 8px; margin-top: 20px; height: 48px; cursor: pointer; transition: background 0.2s; }
.sidebar-phone:hover { background: #003366; }
.sidebar-phone .icon { width: 48px; text-align: center; border-right: 1px solid rgba(255,255,255,0.2); font-size: 18px; }
.sidebar-phone .num { flex: 1; text-align: center; font-weight: 700; font-size: 18px; }
.sidebar-info { margin: 25px 0; }
.sidebar-info-row { display: flex; padding: 10px 0; border-bottom: 1px solid #f0f0f0; font-size: 13px; }
.sidebar-info-label { width: 55px; color: #999; flex-shrink: 0; }
.sidebar-info-value { flex: 1; color: #333; }
.sidebar-notice { background: #164439; color: #fff; padding: 20px; text-align: center; font-weight: 600; font-size: 14px; line-height: 1.7; white-space: pre-line; border-radius: 0 0 12px 12px; margin-top: 30px; }

/* Action Buttons */
.sidebar-actions { display: flex; gap: 10px; margin-top: 15px; }
.sidebar-actions .btn { flex: 1; height: 48px; border-radius: 8px; border: none; color: #fff; font-weight: 600; font-size: 14px; display: flex; align-items: center; justify-content: center; gap: 8px; }
@media (max-width: 820px) { .sidebar-actions { display: none; } }

/* ========== Gallery ========== */
.apt-card { background: var(--apt-white); border-radius: 12px; box-shadow: var(--apt-shadow); padding: 20px; margin-bottom: 20px; }
.gallery-list { display: flex; flex-direction: column; gap: 15px; }
.gallery-item { position: relative; border-radius: 10px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: #f5f5f5; }
.gallery-item img { width: 100%; height: auto; max-height: 500px; object-fit: contain; background: #f5f5f5; }
.gallery-caption { padding: 12px 15px; background: #fafafa; font-size: 13px; color: #666; text-align: center; border-top: 1px solid #eee; }
.gallery-admin { position: absolute; top: 10px; right: 10px; display: none; gap: 5px; }
.gallery-admin-btn { width: 34px; height: 34px; border-radius: 50%; border: none; color: #fff; display: flex; align-items: center; justify-content: center; font-size: 14px; box-shadow: 0 2px 6px rgba(0,0,0,0.3); }
.gallery-admin-btn.move { background: #3498db; }
.gallery-admin-btn.del { background: #e74c3c; }
body.edit-mode .gallery-admin { display: flex; }

/* Gallery Add */
.gallery-add { display: none; margin-top: 15px; padding: 20px; background: #f8f9fa; border-radius: 10px; border: 2px dashed #ddd; }
body.edit-mode .gallery-add { display: block; }
.gallery-add-tabs { display: flex; gap: 10px; margin-bottom: 15px; }
.gallery-add-tab { padding: 8px 16px; border: none; background: #e9ecef; border-radius: 6px; font-weight: 500; font-size: 13px; }
.gallery-add-tab.active { background: var(--apt-primary); color: #fff; }
.gallery-add-panel { display: none; }
.gallery-add-panel.active { display: block; }
.gallery-add-panel input[type="text"] { width: 100%; padding: 12px; border: 1px solid #ddd; border-radius: 6px; margin-bottom: 10px; }
.gallery-add-panel button { padding: 10px 20px; background: var(--apt-primary); color: #fff; border: none; border-radius: 6px; font-weight: 600; }
.gallery-upload-zone { padding: 40px; text-align: center; cursor: pointer; }
.gallery-upload-zone i { font-size: 40px; color: #aaa; }
.gallery-upload-zone p { margin-top: 10px; color: #666; font-size: 13px; }

/* ========== Form ========== */
.form-card { background: var(--apt-white); border-radius: 12px; box-shadow: var(--apt-shadow); overflow: hidden; }
.form-header { background: linear-gradient(135deg, var(--apt-primary), var(--apt-secondary)); color: #fff; padding: 25px; }
.form-header h2 { font-size: 20px; display: flex; align-items: center; gap: 10px; }
.form-body { padding: 25px; }
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 8px; }
.form-label .req { color: #e74c3c; }
.form-input, .form-select { width: 100%; padding: 12px 14px; border: 2px solid var(--apt-border); border-radius: 8px; font-size: 15px; transition: border-color 0.2s; }
.form-input:focus, .form-select:focus { outline: none; border-color: var(--apt-primary); }
.form-row { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 10px; }
.form-check { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; font-size: 14px; }
.form-check input { width: 18px; height: 18px; }
.form-submit { width: 100%; padding: 14px; background: linear-gradient(135deg, var(--apt-primary), var(--apt-secondary)); color: #fff; border: none; border-radius: 8px; font-size: 16px; font-weight: 700; }

/* ========== Mobile Quick Buttons ========== */
.mobile-quick { position: fixed; bottom: 0; left: 0; right: 0; display: none; z-index: 100; }
@media (max-width: 820px) { .mobile-quick { display: flex; } }
.mobile-quick-btn { flex: 1; height: 58px; display: flex; align-items: center; justify-content: center; gap: 8px; color: #fff; font-weight: 600; font-size: 15px; border: none; text-decoration: none; background-size: 300% 300%; animation: gradientBg 5s ease infinite; }
@keyframes gradientBg { 0%,100%{background-position:0 50%} 50%{background-position:100% 50%} }
.mobile-quick-btn i { font-size: 20px; }

/* ========== Admin ========== */
.admin-bar { position: fixed; top: 10px; right: 10px; display: flex; gap: 10px; z-index: 999; }
.admin-btn { background: linear-gradient(135deg, #667eea, #764ba2); color: #fff; padding: 10px 16px; border-radius: 20px; font-size: 13px; font-weight: 600; border: none; display: flex; align-items: center; gap: 6px; box-shadow: 0 3px 10px rgba(0,0,0,0.2); position: relative; }
.admin-btn:hover { opacity: 0.9; }
.admin-btn .badge { position: absolute; top: -5px; right: -5px; background: #e74c3c; color: #fff; font-size: 11px; padding: 2px 6px; border-radius: 10px; }
.admin-btn.active { background: linear-gradient(135deg, #28a745, #20c997); }
.save-toast { position: fixed; top: 60px; right: 10px; background: #28a745; color: #fff; padding: 10px 20px; border-radius: 6px; font-size: 14px; z-index: 999; display: none; }
.save-toast.show { display: block; animation: fadeIn 0.3s; }
@keyframes fadeIn { from{opacity:0;transform:translateY(-10px)} to{opacity:1;transform:translateY(0)} }

/* Editable */
.editable { cursor: pointer; border-radius: 4px; transition: background 0.2s; }
body.edit-mode .editable:hover { background: rgba(102,126,234,0.1); outline: 2px dashed var(--apt-primary); }
.editable-input { width: 100%; padding: 4px 8px; border: 2px solid var(--apt-primary); border-radius: 4px; font-size: inherit; font-weight: inherit; }

/* Upload Overlay */
.upload-overlay { position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.5); display: none; align-items: center; justify-content: center; cursor: pointer; flex-direction: column; color: #fff; font-size: 12px; }
body.edit-mode .upload-overlay { display: flex; }
.upload-overlay i { font-size: 24px; margin-bottom: 5px; }

/* Mobile Option */
.mobile-opt { position: absolute; top: 8px; right: 8px; z-index: 20; display: none; }
body.edit-mode .mobile-opt { display: block; }
.mobile-opt label { display: flex; align-items: center; gap: 5px; background: rgba(0,0,0,0.7); color: #fff; padding: 5px 10px; border-radius: 15px; font-size: 11px; cursor: pointer; }
.mobile-opt input { width: 14px; height: 14px; }

/* ========== Modal ========== */
.modal { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.6); z-index: 1000; display: none; align-items: center; justify-content: center; padding: 15px; }
.modal.active { display: flex; }
.modal-box { background: #fff; border-radius: 12px; width: 100%; max-width: 600px; max-height: 90vh; overflow: hidden; display: flex; flex-direction: column; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 20px; border-bottom: 1px solid #eee; }
.modal-head h3 { font-size: 17px; display: flex; align-items: center; gap: 8px; }
.modal-close { background: none; border: none; font-size: 20px; color: #999; }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-foot { padding: 15px 20px; border-top: 1px solid #eee; text-align: right; }
.modal-btn { padding: 10px 20px; background: var(--apt-primary); color: #fff; border: none; border-radius: 6px; font-weight: 600; }

/* Stats */
.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 20px; }
.stat-box { padding: 18px; border-radius: 10px; text-align: center; color: #fff; }
.stat-box.purple { background: linear-gradient(135deg, #667eea, #764ba2); }
.stat-box.green { background: linear-gradient(135deg, #11998e, #38ef7d); }
.stat-box.orange { background: linear-gradient(135deg, #eb3349, #f45c43); }
.stat-num { font-size: 28px; font-weight: 700; }
.stat-label { font-size: 12px; opacity: 0.9; margin-top: 3px; }
.stats-filter { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 15px; padding: 12px; background: #f0f4ff; border-radius: 8px; }
.stats-filter input { padding: 8px 10px; border: 1px solid #ddd; border-radius: 6px; font-size: 13px; }
.stats-filter button { padding: 8px 14px; border: none; border-radius: 6px; font-size: 13px; font-weight: 500; cursor: pointer; }
.stats-filter .apply { background: #667eea; color: #fff; }
.stats-filter .reset { background: #6c757d; color: #fff; }
.chart-wrap { background: #f8f9fa; border-radius: 10px; padding: 15px; margin-bottom: 15px; }

/* Reservations */
.res-list { max-height: 280px; overflow-y: auto; }
.res-item { display: flex; justify-content: space-between; align-items: center; padding: 12px; border-bottom: 1px solid #eee; }
.res-item.unread { background: #fffbeb; }
.res-name { font-weight: 600; font-size: 14px; }
.res-name .new { background: #e74c3c; color: #fff; font-size: 10px; padding: 2px 5px; border-radius: 8px; margin-left: 5px; }
.res-info { font-size: 12px; color: #666; margin-top: 3px; }
.res-actions button { padding: 5px 10px; border: none; border-radius: 4px; font-size: 11px; margin-left: 5px; cursor: pointer; }
.res-actions .read { background: #3498db; color: #fff; }
.res-actions .del { background: #e74c3c; color: #fff; }

/* Icon Picker */
.icon-picker { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); background: #fff; padding: 20px; border-radius: 12px; box-shadow: 0 10px 40px rgba(0,0,0,0.3); z-index: 1100; display: none; max-width: 350px; }
.icon-picker.active { display: block; }
.icon-picker h4 { margin-bottom: 15px; }
.icon-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.icon-item { width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; border: 2px solid #eee; border-radius: 8px; cursor: pointer; font-size: 18px; }
.icon-item:hover { border-color: var(--apt-primary); background: #f0f4ff; }

/* Toast Popup */
.toast-popup { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%) scale(0.8); background: #fff; padding: 40px 50px; border-radius: 16px; box-shadow: 0 15px 50px rgba(0,0,0,0.3); z-index: 2000; text-align: center; opacity: 0; visibility: hidden; transition: all 0.3s; }
.toast-popup.show { opacity: 1; visibility: visible; transform: translate(-50%, -50%) scale(1); }
.toast-popup .icon { font-size: 56px; color: #28a745; margin-bottom: 15px; }
.toast-popup .msg { font-size: 17px; line-height: 1.7; }

/* Preset Selector */
.preset-btn { position: absolute; top: -8px; left: 50%; transform: translateX(-50%); width: 24px; height: 24px; background: #fff; border-radius: 50%; display: none; align-items: center; justify-content: center; cursor: pointer; box-shadow: 0 2px 6px rgba(0,0,0,0.2); font-size: 12px; z-index: 10; }
body.edit-mode .preset-btn { display: flex; }
.preset-list { position: absolute; bottom: calc(100% + 10px); left: 50%; transform: translateX(-50%); background: #fff; padding: 10px; border-radius: 8px; box-shadow: 0 3px 15px rgba(0,0,0,0.2); display: none; gap: 8px; }
.preset-list.active { display: flex; }
.preset-dot { width: 28px; height: 28px; border-radius: 50%; cursor: pointer; border: 2px solid #fff; box-shadow: 0 2px 5px rgba(0,0,0,0.2); }

/* 방문 알림 (우측 하단) */
.visit-alert { position: fixed; bottom: 90px; right: 20px; background: #1a1a2e; color: #fff; padding: 10px 18px; border-radius: 25px; font-size: 13px; font-weight: 500; display: flex; align-items: center; gap: 8px; box-shadow: 0 4px 20px rgba(0,0,0,0.3); z-index: 90; animation: slideIn 0.5s ease; }
@keyframes slideIn { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: translateX(0); } }
.visit-alert .fire { font-size: 16px; }
.visit-alert .num { color: #ffd700; font-weight: 700; font-size: 15px; }
.visit-alert-admin { position: absolute; top: -8px; right: -8px; width: 22px; height: 22px; background: #e74c3c; color: #fff; border: none; border-radius: 50%; font-size: 10px; cursor: pointer; display: none; align-items: center; justify-content: center; }
body.edit-mode .visit-alert-admin { display: flex; }
@media (max-width: 820px) { .visit-alert { bottom: 75px; right: 15px; font-size: 12px; padding: 8px 14px; } }

/* 약관 모달 개선 */
#termsModal .modal-box { max-height: 85vh; display: flex; flex-direction: column; }
#termsModal .modal-body { flex: 1; overflow-y: auto; padding-bottom: 80px; }
#termsModal .modal-foot { position: sticky; bottom: 0; background: #fff; border-top: 1px solid #eee; padding: 15px 20px; }
.terms-edit { margin-top: 15px; padding: 15px; background: #f8f9fa; border-radius: 8px; display: none; }
body.edit-mode .terms-edit { display: block; }
.terms-edit textarea { width: 100%; height: 150px; padding: 10px; border: 1px solid #ddd; border-radius: 6px; resize: vertical; }
.terms-edit button { margin-top: 10px; padding: 8px 16px; background: var(--apt-primary); color: #fff; border: none; border-radius: 6px; cursor: pointer; }

/* Admin Edit Section */
.admin-section { margin-top: 20px; padding: 15px; background: #f8f9fa; border-radius: 8px; display: none; }
body.edit-mode .admin-section { display: block; }
.admin-section h4 { font-size: 14px; margin-bottom: 10px; }
.admin-section textarea { width: 100%; height: 80px; padding: 10px; border: 1px solid #ddd; border-radius: 6px; resize: vertical; }
.admin-section button { margin-top: 10px; padding: 8px 16px; background: var(--apt-primary); color: #fff; border: none; border-radius: 6px; font-weight: 500; }
