/* 게시판 테마 CSS - shadcn/ui 기반 디자인 시스템 */

/* CSS 변수 - shadcn/ui 기본 (shadcn.css의 토큰 사용, fallback 제공) */
:root {
    /* shadcn/ui 와 호환되는 기본값 설정 */
    --primary-color: hsl(240 5.9% 10%);
    --secondary-color: hsl(240 4.8% 95.9%);
    --accent-color: hsl(240 4.8% 95.9%);
    --text-primary: hsl(240 10% 3.9%);
    --text-secondary: hsl(240 3.8% 46.1%);
    --background: hsl(0 0% 100%);
    --border-color: hsl(240 5.9% 90%);
    --font-size: 1rem;
    --line-height: 1.5;
    --container-width: 1200px;
    --section-spacing: 3.75rem;
    --border-radius: 0.75rem;
}

.board-surface {
    /* 배경색 - shadcn 토큰 */
    --theme-bg-primary: hsl(var(--background, 0 0% 100%));
    --theme-bg-secondary: hsl(var(--muted, 240 4.8% 95.9%) / 0.5);
    --theme-bg-accent: hsl(var(--accent, 240 4.8% 95.9%));

    /* 테두리 색상 */
    --theme-border-light: hsl(var(--border, 240 5.9% 90%));
    --theme-border-medium: hsl(var(--border, 240 5.9% 90%));
    --theme-border-strong: hsl(240 5.9% 80%);
    --theme-border-primary: hsl(var(--primary, 240 5.9% 10%));

    /* 텍스트 색상 */
    --theme-text-primary: hsl(var(--foreground, 240 10% 3.9%));
    --theme-text-secondary: hsl(var(--muted-foreground, 240 3.8% 46.1%));
    --theme-text-muted: hsl(var(--muted-foreground, 240 3.8% 46.1%));

    /* 상태 색상 */
    --theme-success: hsl(var(--success, 142 76% 36%));
    --theme-warning: hsl(var(--warning, 38 92% 50%));
    --theme-error: hsl(var(--destructive, 0 84.2% 60.2%));
    --theme-info: hsl(var(--info, 221 83% 53%));

    /* 프라이머리 색상 */
    --theme-primary: hsl(var(--primary, 240 5.9% 10%));
    --theme-primary-light: hsl(var(--secondary, 240 4.8% 95.9%));
    --theme-primary-dark: hsl(240 5.9% 5%);

    /* 세컨더리 색상 */
    --theme-secondary: hsl(var(--secondary, 240 4.8% 95.9%));
    --theme-secondary-light: hsl(var(--muted, 240 4.8% 95.9%));
    --theme-secondary-dark: hsl(240 4.8% 85%);

    /* 그림자 (shadcn 스타일 - 매우 미묘) */
    --theme-shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --theme-shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --theme-shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);

    /* 둥근 모서리 */
    --theme-radius: var(--radius-lg, 0.75rem);
    --theme-radius-sm: var(--radius-sm, 0.25rem);
    --theme-radius-lg: var(--radius-xl, 1rem);
}

/* 게시판 기본 스타일 - shadcn 테마 적용 */
.board-surface {
    background-color: var(--theme-bg-primary);
    border: 1px solid var(--theme-border-light);
    border-radius: var(--theme-radius);
    box-shadow: var(--theme-shadow-sm);
}

/* 헤더 스타일 */
.board-surface .board-header {
    border-bottom: 1px solid var(--theme-border-light) !important;
    background-color: var(--theme-bg-primary) !important;
    padding: 1.5rem !important;
}

.board-surface .board-title {
    color: var(--theme-text-primary) !important;
    font-size: 1.5rem !important;
    font-weight: 700 !important;
    letter-spacing: -0.02em !important;
}

.board-surface .board-description {
    color: var(--theme-text-secondary) !important;
    font-size: 0.875rem !important;
    margin-top: 0.25rem !important;
}

/* 버튼 스타일 재정의 - shadcn 스타일 */
.board-surface .btn-primary {
    background-color: var(--theme-primary) !important;
    border-color: var(--theme-primary) !important;
    color: hsl(var(--primary-foreground, 0 0% 98%)) !important;
    border-radius: var(--radius-md, 0.5rem) !important;
    font-size: 0.875rem !important;
    font-weight: 500 !important;
    height: 2.25rem !important;
    padding: 0.5rem 1rem !important;
    line-height: 1 !important;
    transition: background-color 0.15s ease !important;
}

.board-surface .btn-primary:hover {
    background-color: var(--theme-primary-dark) !important;
    border-color: var(--theme-primary-dark) !important;
}

.board-surface .btn-secondary {
    background-color: var(--theme-bg-secondary) !important;
    border-color: var(--theme-border-light) !important;
    color: var(--theme-text-primary) !important;
    border-radius: var(--radius-md, 0.5rem) !important;
    font-size: 0.875rem !important;
    font-weight: 500 !important;
    height: 2.25rem !important;
    padding: 0.5rem 1rem !important;
}

.board-surface .btn-secondary:hover {
    background-color: var(--theme-bg-accent) !important;
    border-color: var(--theme-border-medium) !important;
}

.board-surface .btn-outline {
    background-color: transparent !important;
    border-color: var(--theme-border-medium) !important;
    color: var(--theme-text-primary) !important;
    border-radius: var(--radius-md, 0.5rem) !important;
    font-size: 0.875rem !important;
    font-weight: 500 !important;
}

.board-surface .btn-outline:hover {
    background-color: var(--theme-bg-secondary) !important;
    border-color: var(--theme-border-medium) !important;
    color: var(--theme-text-primary) !important;
}

/* 테두리 색상 재정의 */
.board-surface .border-slate-200,
.board-surface .border-gray-200 {
    border-color: var(--theme-border-light) !important;
}

.board-surface .border-slate-300,
.board-surface .border-gray-300 {
    border-color: var(--theme-border-medium) !important;
}

.board-surface .divide-slate-200 > :not([hidden]) ~ :not([hidden]) {
    border-color: var(--theme-border-light) !important;
}

.board-surface .border-t { border-top-color: var(--theme-border-light) !important; }
.board-surface .border-b { border-bottom-color: var(--theme-border-light) !important; }
.board-surface .border-l { border-left-color: var(--theme-border-light) !important; }
.board-surface .border-r { border-right-color: var(--theme-border-light) !important; }

/* 배경색 재정의 */
.board-surface .bg-white {
    background-color: var(--theme-bg-primary) !important;
}

.board-surface .bg-gray-50,
.board-surface .bg-slate-50 {
    background-color: var(--theme-bg-secondary) !important;
}

.board-surface .bg-gray-100,
.board-surface .bg-slate-100 {
    background-color: var(--theme-bg-accent) !important;
}

/* 텍스트 색상 재정의 */
.board-surface .text-slate-900,
.board-surface .text-slate-800,
.board-surface .text-gray-900,
.board-surface .text-gray-800 {
    color: var(--theme-text-primary) !important;
}

.board-surface .text-slate-700,
.board-surface .text-slate-600,
.board-surface .text-gray-700,
.board-surface .text-gray-600 {
    color: var(--theme-text-secondary) !important;
}

.board-surface .text-slate-500,
.board-surface .text-slate-400,
.board-surface .text-gray-500 {
    color: var(--theme-text-muted) !important;
}

/* 상태별 색상 */
.board-surface .text-red-600,
.board-surface .text-red-700,
.board-surface .text-red-800 {
    color: var(--theme-error) !important;
}

.board-surface .text-green-600,
.board-surface .text-green-700,
.board-surface .text-green-800 {
    color: var(--theme-success) !important;
}

.board-surface .text-blue-600,
.board-surface .text-blue-700,
.board-surface .text-blue-800 {
    color: var(--theme-info) !important;
}

.board-surface .text-amber-600,
.board-surface .text-yellow-600 {
    color: var(--theme-warning) !important;
}

/* 상태별 배경색 */
.board-surface .bg-red-100 {
    background-color: hsl(0 84.2% 60.2% / 0.1) !important;
}

.board-surface .bg-red-50 {
    background-color: hsl(0 84.2% 60.2% / 0.05) !important;
}

.board-surface .bg-green-100 {
    background-color: hsl(142 76% 36% / 0.1) !important;
}

.board-surface .bg-green-50 {
    background-color: hsl(142 76% 36% / 0.05) !important;
}

.board-surface .bg-blue-100 {
    background-color: hsl(221 83% 53% / 0.1) !important;
}

.board-surface .bg-blue-50 {
    background-color: hsl(221 83% 53% / 0.05) !important;
}

/* 상태별 테두리 */
.board-surface .border-red-200 {
    border-color: hsl(0 84.2% 60.2% / 0.3) !important;
}

.board-surface .border-green-200 {
    border-color: hsl(142 76% 36% / 0.3) !important;
}

.board-surface .border-blue-200 {
    border-color: hsl(221 83% 53% / 0.3) !important;
}

/* 입력 필드 스타일 - shadcn 스타일 */
.board-surface input[type="text"],
.board-surface input[type="email"],
.board-surface input[type="password"],
.board-surface select,
.board-surface textarea {
    border: 1px solid var(--theme-border-medium) !important;
    border-radius: var(--radius-md, 0.5rem) !important;
    background-color: var(--theme-bg-primary) !important;
    color: var(--theme-text-primary) !important;
    font-size: 0.875rem !important;
    padding: 0.5rem 0.75rem !important;
    height: 2.25rem !important;
    transition: border-color 0.15s ease, box-shadow 0.15s ease !important;
}

.board-surface textarea {
    height: auto !important;
    min-height: 6rem !important;
}

.board-surface input[type="text"]:focus,
.board-surface input[type="email"]:focus,
.board-surface input[type="password"]:focus,
.board-surface select:focus,
.board-surface textarea:focus {
    border-color: var(--theme-border-primary) !important;
    box-shadow: 0 0 0 3px hsl(var(--ring, 240 5.9% 10%) / 0.15) !important;
    outline: none !important;
}

/* 공지사항/추천글 배지 - shadcn badge 스타일 */
.board-surface .notice-badge {
    background-color: var(--theme-error) !important;
    color: white !important;
    font-size: 0.75rem !important;
    font-weight: 600 !important;
    padding: 0.125rem 0.5rem !important;
    border-radius: 9999px !important;
}

.board-surface .featured-badge {
    background-color: var(--theme-info) !important;
    color: white !important;
    font-size: 0.75rem !important;
    font-weight: 600 !important;
    padding: 0.125rem 0.5rem !important;
    border-radius: 9999px !important;
}

/* 댓글 영역 */
.board-surface .comment-item {
    border-left: 3px solid var(--theme-border-medium) !important;
    background-color: var(--theme-bg-secondary) !important;
    border-radius: 0 var(--theme-radius-sm) var(--theme-radius-sm) 0 !important;
    padding: 0.75rem 1rem !important;
}

/* 게시판 구조 */
.board-surface .board-post-header {
    background-color: var(--theme-bg-primary) !important;
    border-color: var(--theme-border-light) !important;
}

.board-surface .board-post-title {
    color: var(--theme-text-primary) !important;
    font-size: 1.25rem !important;
    font-weight: 600 !important;
    letter-spacing: -0.01em !important;
}

.board-surface .board-post-meta {
    border-bottom: 1px solid var(--theme-border-light) !important;
    padding-bottom: 1rem !important;
    color: var(--theme-text-secondary) !important;
    font-size: 0.875rem !important;
}

.board-surface .board-comments-heading {
    color: var(--theme-text-primary) !important;
    font-weight: 600 !important;
    font-size: 1rem !important;
}

.board-surface .board-write-form,
.board-surface .board-edit-form {
    background-color: var(--theme-bg-primary) !important;
}

/* 링크 미리보기 */
.board-surface .preview-card {
    background-color: var(--theme-bg-primary) !important;
    border: 1px solid var(--theme-border-light) !important;
    border-radius: var(--theme-radius) !important;
    box-shadow: var(--theme-shadow-sm) !important;
}

/* 파일 첨부 */
.board-surface .attachment-item {
    border: 1px solid var(--theme-border-light) !important;
    background-color: var(--theme-bg-secondary) !important;
    border-radius: var(--radius-md, 0.5rem) !important;
    padding: 0.5rem 0.75rem !important;
    font-size: 0.875rem !important;
    transition: background-color 0.15s ease !important;
}

.board-surface .attachment-item:hover {
    background-color: var(--theme-bg-accent) !important;
}

/* 검색 영역 */
.board-surface .search-container {
    background-color: var(--theme-bg-secondary) !important;
    border: 1px solid var(--theme-border-light) !important;
    border-radius: var(--theme-radius) !important;
    padding: 1rem !important;
}

/* 페이지네이션 - shadcn 스타일 */
.board-surface .pagination .page-link {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 2.25rem !important;
    height: 2.25rem !important;
    background-color: var(--theme-bg-primary) !important;
    border: 1px solid var(--theme-border-light) !important;
    border-radius: var(--radius-md, 0.5rem) !important;
    color: var(--theme-text-primary) !important;
    font-size: 0.875rem !important;
    font-weight: 500 !important;
    text-decoration: none !important;
    transition: all 0.15s ease !important;
}

.board-surface .pagination .page-link:hover {
    background-color: var(--theme-bg-accent) !important;
    border-color: var(--theme-border-medium) !important;
    color: var(--theme-text-primary) !important;
}

.board-surface .pagination .page-link.active,
.board-surface .pagination .active .page-link {
    background-color: var(--theme-primary) !important;
    border-color: var(--theme-primary) !important;
    color: hsl(var(--primary-foreground, 0 0% 98%)) !important;
}

/* 테이블 스타일 */
.board-surface table {
    background-color: var(--theme-bg-primary) !important;
    border-collapse: collapse !important;
    font-size: 0.875rem !important;
}

.board-surface th {
    background-color: var(--theme-bg-secondary) !important;
    color: var(--theme-text-secondary) !important;
    border-bottom: 1px solid var(--theme-border-medium) !important;
    font-weight: 500 !important;
    padding: 0.75rem 1rem !important;
    text-align: left !important;
}

.board-surface td {
    border-bottom: 1px solid var(--theme-border-light) !important;
    color: var(--theme-text-primary) !important;
    padding: 0.75rem 1rem !important;
    vertical-align: middle !important;
}

.board-surface tr:hover {
    background-color: var(--theme-bg-secondary) !important;
}

/* 캡차 시스템 스타일 - shadcn 스타일 */
.board-surface .captcha-container {
    background: var(--theme-bg-secondary) !important;
    border: 1px solid var(--theme-border-light) !important;
    border-radius: var(--theme-radius) !important;
    box-shadow: var(--theme-shadow-sm) !important;
    padding: 1rem !important;
}

.board-surface .captcha-wrapper {
    background: var(--theme-bg-secondary) !important;
    border: 1px solid var(--theme-border-light) !important;
    border-radius: var(--theme-radius) !important;
}

.board-surface .captcha-container input[name="captcha_code"] {
    background: var(--theme-bg-primary) !important;
    border: 1px solid var(--theme-border-medium) !important;
    border-radius: var(--radius-md, 0.5rem) !important;
    color: var(--theme-text-primary) !important;
    font-size: 0.875rem !important;
    height: 2.25rem !important;
}

.board-surface .captcha-container input[name="captcha_code"]:focus {
    border-color: var(--theme-primary) !important;
    box-shadow: 0 0 0 3px hsl(var(--ring, 240 5.9% 10%) / 0.15) !important;
    outline: none !important;
}

.board-surface .captcha-refresh-btn {
    background: var(--theme-bg-secondary) !important;
    border: 1px solid var(--theme-border-medium) !important;
    border-radius: var(--radius-md, 0.5rem) !important;
    color: var(--theme-text-primary) !important;
    font-size: 0.875rem !important;
    font-weight: 500 !important;
    transition: all 0.15s ease !important;
    height: 2.25rem !important;
    padding: 0 0.75rem !important;
}

.board-surface .captcha-refresh-btn:hover {
    background: var(--theme-bg-accent) !important;
    border-color: var(--theme-border-strong) !important;
}

.board-surface .captcha-audio-btn {
    background: var(--theme-bg-secondary) !important;
    border: 1px solid var(--theme-border-medium) !important;
    border-radius: var(--radius-md, 0.5rem) !important;
    color: var(--theme-text-primary) !important;
    font-size: 0.875rem !important;
    font-weight: 500 !important;
    transition: all 0.15s ease !important;
    height: 2.25rem !important;
    padding: 0 0.75rem !important;
}

.board-surface .captcha-audio-btn:hover {
    background: var(--theme-bg-accent) !important;
}

.board-surface .captcha-container img {
    border: 1px solid var(--theme-border-medium) !important;
    border-radius: var(--radius-md, 0.5rem) !important;
}

.board-surface .captcha-help {
    color: var(--theme-text-secondary) !important;
    font-size: 0.8125rem !important;
}

/* 반응형 조정 */
@media (max-width: 640px) {
    .board-surface {
        border-radius: var(--radius-md, 0.5rem) !important;
        margin: 0.75rem !important;
    }

    .board-surface .captcha-wrapper {
        flex-direction: column !important;
        gap: 0.75rem !important;
        text-align: center !important;
    }

    .board-surface .captcha-buttons {
        justify-content: center !important;
    }
}

/* 다크모드 대응 */
@media (prefers-color-scheme: dark) {
    .board-surface {
        --theme-bg-primary: hsl(240 10% 3.9%);
        --theme-bg-secondary: hsl(240 3.7% 15.9% / 0.5);
        --theme-bg-accent: hsl(240 3.7% 15.9%);
        --theme-text-primary: hsl(0 0% 98%);
        --theme-text-secondary: hsl(240 5% 64.9%);
        --theme-text-muted: hsl(240 5% 64.9%);
        --theme-border-light: hsl(240 3.7% 15.9%);
        --theme-border-medium: hsl(240 3.7% 20%);
        --theme-border-strong: hsl(240 3.7% 30%);
    }
}
