/* 공통 변수 */
:root {
    --bg-color: #f2f2f2;
    --card-bg: #ffffff;
    --primary-color: #4aa3f8;
    --text-dark: #333333;
    --text-light: #666666;
    --border-radius: 8px;
    --box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Body */
body {
    background-image: url('../images/bg.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    background-color: var(--bg-color);
    color: var(--text-dark);
}

/* Header */
.header {
    background-image: url('../images/banner.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-color: rgba(255, 255, 255, 0.7);
    padding: 40px 20px;
    text-align: center;
    box-shadow: var(--box-shadow);
}

.header h1 {
    font-size: 36px;
    font-weight: 700;
    margin-bottom: 12px;
    background: linear-gradient(to right, #ff6b6b, #feca57, #48dbfb, #1dd1a1, #5f27cd, #341f97);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header .subtitle {
    font-size: 18px;
    background: linear-gradient(to right, #ff9ff3, #54a0ff, #00d2d3, #1dd1a1, #5f27cd, #2d3436);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Container */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 40px 20px;
    display: flex;
    gap: 30px;
}

.main-content {
    flex: 1;
}

/* Top Graphic */
.top-graphic {
    width: 100%;
    aspect-ratio: 16 / 5.5;
    background-color: #cccccc;
    border-radius: var(--border-radius);
    overflow: hidden;
    margin-bottom: 32px;
}

.top-graphic img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Card Grid */
.card-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
    margin-bottom: 40px;
}

.card {
    background-color: rgba(255, 255, 255, 0.7);
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    padding: 20px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.card-image {
    width: 100%;
    aspect-ratio: 1;
    background-color: #cccccc;
    border-radius: var(--border-radius);
    overflow: hidden;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.card h3 {
    font-size: 20px;
    font-weight: 600;
    text-align: center;
    color: var(--text-dark);
}

.card-desc {
    text-align: center;
    color: #ffffff;
    font-weight: 600;
    margin-top: 8px;
}

/* Sub Section */
.sub-section {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
}

.card-emphasis {
    border: 2px solid var(--primary-color);
}

/* Chatbot Container */
.chatbot-container {
    width: 480px;
    min-width: 480px;
    background-color: rgba(255, 255, 255, 0.7);
    border: 2px solid var(--primary-color);
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: sticky;
    top: 20px;
}

.chatbot-header {
    padding: 20px;
    border-bottom: 1px solid #e0e0e0;
    background-color: var(--primary-color);
    color: white;
    border-radius: var(--border-radius) var(--border-radius) 0 0;
}

.chatbot-header h2 {
    font-size: 18px;
    font-weight: 600;
}

.chatbot-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.bot-message,
.user-message {
    padding: 12px 16px;
    border-radius: 12px;
    max-width: 100%;
    word-wrap: break-word;
    line-height: 1.6;
}

.bot-message {
    background-color: #f0f0f0;
    align-self: flex-start;
}

/* 메시지 타입별 배경색 */
.bot-message.message-question {
    background-color: #0a2a0a;
    color: #ffffff;
    border-left: 5px solid #654321;
    box-shadow: 0 3px 10px rgba(10, 42, 10, 0.6);
}

.bot-message.message-question strong {
    color: #ffeb3b;
}

.bot-message.message-question .option {
    background-color: rgba(101, 67, 33, 0.2);
    border-left: 3px solid #654321;
    color: #ffffff;
}

.bot-message.message-answer {
    background-color: #f0f0f0;
    border-left: 4px solid #4caf50;
}

.bot-message.message-explanation {
    background-color: #f0f0f0;
    border-left: 4px solid #999;
}

/* 봇 메시지 내 마크다운 스타일 */
.bot-message strong {
    color: var(--primary-color);
    font-weight: 700;
}

.bot-message ul {
    margin: 8px 0;
    padding-left: 0;
    list-style: none;
}

.bot-message li {
    margin: 6px 0;
    padding-left: 20px;
    position: relative;
}

.bot-message li:before {
    content: "•";
    position: absolute;
    left: 0;
    color: var(--primary-color);
    font-weight: bold;
}

.bot-message .option {
    margin: 0;
    padding: 8px 12px;
    background-color: #ffffff;
    border-left: 3px solid var(--primary-color);
    border-radius: 4px;
}

.bot-message h4 {
    margin: 12px 0 8px 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-dark);
}

.bot-message hr {
    margin: 16px 0;
    border: none;
    border-top: 2px solid #e0e0e0;
}

.user-message {
    background-color: var(--primary-color);
    color: white;
    align-self: flex-end;
}

.chatbot-input {
    display: flex;
    gap: 8px;
    padding: 16px;
    border-top: 1px solid #e0e0e0;
}

.chatbot-input input {
    flex: 1;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 20px;
    font-size: 14px;
}

.chatbot-input input:disabled {
    background-color: #f5f5f5;
    color: #999;
    cursor: not-allowed;
    opacity: 0.6;
}

.chatbot-input button {
    padding: 12px 24px;
    background-color: var(--primary-color);
    color: white;
    border-radius: 20px;
    font-weight: 600;
    transition: background-color 0.2s;
}

.chatbot-input button:hover {
    background-color: #3a93e8;
}

.chatbot-input button:disabled {
    background-color: #ccc;
    cursor: not-allowed;
    opacity: 0.5;
}

.chatbot-input button:disabled:hover {
    background-color: #ccc;
}

.chatbot-loading {
    display: none;
    padding: 12px;
    text-align: center;
}

.chatbot-loading.active {
    display: block;
}

.chatbot-loading span {
    display: inline-block;
    width: 8px;
    height: 8px;
    background-color: var(--primary-color);
    border-radius: 50%;
    margin: 0 4px;
    animation: bounce 1.4s infinite ease-in-out both;
}

.chatbot-loading span:nth-child(1) {
    animation-delay: -0.32s;
}

.chatbot-loading span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes bounce {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1);
    }
}

/* Footer */
.footer {
    background-color: rgba(255, 255, 255, 0.7);
    padding: 24px;
    text-align: center;
    color: #000000;
    margin-top: 40px;
    box-shadow: var(--box-shadow);
}

/* Detail Page */
.detail-page {
    max-width: 1000px;
    margin: 0 auto;
    padding: 40px 20px;
}

.page-title {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 32px;
    color: var(--text-dark);
}

.content-section {
    background-color: var(--card-bg);
    padding: 32px;
    margin-bottom: 24px;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
}

.content-section h2 {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 20px;
    color: var(--text-dark);
}

.content-section p {
    font-size: 16px;
    line-height: 1.8;
    color: var(--text-dark);
    margin-bottom: 16px;
}

.content-section ul {
    padding-left: 20px;
}

.content-section ul li {
    font-size: 16px;
    line-height: 1.8;
    color: var(--text-dark);
    margin-bottom: 8px;
    list-style: disc;
}

.content-image {
    width: 100%;
    max-width: 400px;
    aspect-ratio: 1;
    background-color: #cccccc;
    border-radius: var(--border-radius);
    margin: 20px auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

.content-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.answer {
    background-color: #e8f4fd;
    padding: 16px;
    border-left: 4px solid var(--primary-color);
    border-radius: 4px;
    font-weight: 600;
}

/* Bottom Navigation */
.bottom-nav {
    display: flex;
    gap: 16px;
    justify-content: center;
    margin-top: 40px;
}

.nav-btn {
    padding: 12px 32px;
    background-color: var(--primary-color);
    color: white;
    border-radius: 24px;
    font-weight: 600;
    transition: background-color 0.2s;
}

.nav-btn:hover {
    background-color: #3a93e8;
}

/* 반응형: 태블릿 */
@media (max-width: 768px) {
    .container {
        flex-direction: column;
    }

    .card-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .chatbot-container {
        width: 100%;
        min-width: auto;
        height: 400px;
        position: static;
    }

    .header h1 {
        font-size: 28px;
    }

    .header .subtitle {
        font-size: 16px;
    }
}

/* 반응형: 모바일 */
@media (max-width: 480px) {
    .card-grid {
        grid-template-columns: 1fr;
    }

    .sub-section {
        grid-template-columns: 1fr;
    }

    .header h1 {
        font-size: 24px;
    }

    .header .subtitle {
        font-size: 14px;
    }

    .chatbot-container {
        height: 500px;
    }

    .bottom-nav {
        flex-direction: column;
    }

    .nav-btn {
        width: 100%;
    }
}

/* 마크다운 스타일 */
#post-content pre {
    background: #f5f2f0;
    padding: 15px;
    border-radius: 5px;
    overflow-x: auto;
    border-left: 4px solid #1a56db;
    color: inherit;
    font-weight: normal;
}

#post-content :not(pre)>code {
    background: #f0f0f0;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 14px;
}

#post-content pre code {
    background: none;
    padding: 0;
    color: inherit;
    font-size: 14px;
    font-weight: inherit;
}

#post-content a,
#write-preview a,
#edit-preview a {
    color: #1d4ed8;
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 3px;
    font-weight: 600;
    word-break: break-all;
}

#post-content a:hover,
#write-preview a:hover,
#edit-preview a:hover {
    color: #1e40af;
}

#post-content p a,
#write-preview p a,
#edit-preview p a,
#post-content li a,
#write-preview li a,
#edit-preview li a {
    display: inline-block;
    padding: 2px 4px;
    border-radius: 6px;
    background: rgba(29, 78, 216, 0.08);
}

#post-content img {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 16px auto;
    border-radius: 6px;
}

#post-content audio,
#post-content video {
    display: block;
    width: min(100%, 720px);
    max-width: 100%;
    margin: 16px auto;
    border-radius: 10px;
    background: #0f172a;
}

#write-preview,
#edit-preview,
#post-content {
    overflow-wrap: break-word;
}

#write-preview img,
#edit-preview img {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 16px auto;
    border-radius: 6px;
}

#write-preview audio,
#write-preview video,
#edit-preview audio,
#edit-preview video {
    display: block;
    width: min(100%, 720px);
    max-width: 100%;
    margin: 16px auto;
    border-radius: 10px;
    background: #0f172a;
}

#post-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
}

#post-content th,
#post-content td {
    border: 1px solid #d1d5db;
    padding: 10px 12px;
    text-align: left;
}

.main-nav ul {
    flex-wrap: wrap;
}

.board-controls {
    gap: 12px;
    flex-wrap: wrap;
}

.board-controls input[type="text"] {
    max-width: 100%;
    min-width: 0;
}

.admin-shell {
    max-width: 1440px;
    margin: 0 auto;
    padding: 32px 20px 48px;
}

.admin-topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
    padding: 18px 22px;
    background: rgba(255, 255, 255, 0.82);
    border-radius: 16px;
    box-shadow: var(--box-shadow);
    backdrop-filter: blur(12px);
}

.admin-nav-link,
.admin-logout-btn,
.admin-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 14px;
    border: none;
    border-radius: 10px;
    text-decoration: none;
    cursor: pointer;
    font-weight: 600;
}

.admin-nav-link {
    background: #1d4ed8;
    color: #fff;
}

.admin-logout-btn {
    background: #111827;
    color: #fff;
}

.admin-action-btn {
    background: #0f766e;
    color: #fff;
}

.admin-user-badge {
    padding: 10px 12px;
    background: #ede9fe;
    color: #5b21b6;
    border-radius: 999px;
    font-weight: 700;
}

.board-status,
.admin-feedback {
    margin-bottom: 18px;
    padding: 12px 14px;
    border-radius: 12px;
    font-weight: 600;
}

.board-status-info {
    background: #dbeafe;
    color: #1d4ed8;
    border: 1px solid #93c5fd;
}

.board-status-error,
.admin-feedback-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}

.board-status-success,
.admin-feedback-success {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #86efac;
}


.admin-summary-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
    margin-bottom: 24px;
}

.admin-stat-card {
    padding: 22px;
    background: linear-gradient(135deg, rgba(255,255,255,0.88), rgba(214,236,255,0.82));
    border-radius: 18px;
    box-shadow: var(--box-shadow);
}

.admin-stat-label {
    font-size: 14px;
    color: #475569;
    margin-bottom: 8px;
}

.admin-stat-value {
    font-size: 34px;
    font-weight: 800;
    color: #0f172a;
}

.admin-panel {
    margin-bottom: 24px;
    padding: 22px;
    background: rgba(255, 255, 255, 0.88);
    border-radius: 18px;
    box-shadow: var(--box-shadow);
    backdrop-filter: blur(12px);
}

.admin-panel-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}

.admin-panel-head h2 {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
}

.admin-table-wrap {
    overflow-x: auto;
}

.admin-filter-bar {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.admin-filter-select {
    width: auto;
    min-width: 150px;
}

.admin-filter-input {
    max-width: 320px;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 1080px;
}

.admin-table th,
.admin-table td {
    padding: 12px 10px;
    border-bottom: 1px solid #e5e7eb;
    text-align: left;
    vertical-align: middle;
    font-size: 14px;
}

.admin-table th {
    color: #334155;
    background: #f8fafc;
    font-weight: 700;
}

.admin-input,
.admin-select {
    width: 100%;
    padding: 9px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #fff;
}

.admin-input-small {
    min-width: 88px;
}

.admin-empty-state {
    max-width: 780px;
    margin: 80px auto;
    padding: 40px 28px;
    background: rgba(255,255,255,0.9);
    border-radius: 20px;
    text-align: center;
    box-shadow: var(--box-shadow);
}

@media (max-width: 768px) {
    .admin-summary-grid {
        grid-template-columns: 1fr;
    }

    .admin-topbar {
        flex-direction: column;
        align-items: stretch;
    }

    .admin-panel {
        padding: 18px 14px;
    }

    .admin-filter-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .admin-filter-select,
    .admin-filter-input,
    .admin-action-btn,
    .admin-nav-link,
    .admin-logout-btn {
        width: 100%;
        max-width: none;
    }

    .board-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .board-controls input[type="text"] {
        width: 100% !important;
    }

    .board-controls button {
        width: 100%;
    }

    #post-detail > div,
    #write-form-container > div {
        padding: 16px !important;
    }

    #comments-list > div {
        margin-left: 0 !important;
    }

    .main-nav ul {
        gap: 12px !important;
        padding: 0 12px !important;
    }

    .admin-table th,
    .admin-table td {
        padding: 10px 8px;
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .main-nav a {
        font-size: 14px !important;
    }

    #post-content pre {
        padding: 12px;
        font-size: 13px;
    }

    #post-content table {
        display: block;
        overflow-x: auto;
    }

    .admin-panel-head h2 {
        font-size: 18px;
    }

    .admin-user-badge {
        text-align: center;
    }
}
