/* 텍스트 오버플로우 방지를 위한 기본 설정 */
* {
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: keep-all;
}

/* 긴 텍스트(별표 등) 오버플로우 처리 */
.long-text-wrapper,
.star-decoration,
.decoration-line {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

/* 모바일에서 긴 장식 텍스트 처리 */
@media (max-width: 768px) {
    /* 별표 장식 라인 반응형 처리 */
    .star-line,
    .decoration-stars {
        display: block;
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-size: 0.8em;
        line-height: 1.2;
    }
    
    /* 생성된 콘텐츠 내 별표 라인 처리 */
    #contentPreview .star-line,
    #generatedContent .star-line,
    .generated-content .star-line {
        display: block;
        width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    
    /* pre 태그 내 텍스트 오버플로우 처리 */
    pre {
        white-space: pre-wrap;
        word-wrap: break-word;
        overflow-wrap: break-word;
        max-width: 100%;
        overflow-x: auto;
    }
    
    /* 코드 블록 오버플로우 처리 */
    code {
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
}

/* Responsive */
@media (max-width: 992px) {
    .container { padding: 0 15px; }
    .main-cta-container {
        grid-template-columns: 1fr;
        gap: 40px;
    }
    .main-cta-info {
        text-align: center;
    }
    .main-cta-info ul {
        justify-content: center;
        display: inline-flex;
        flex-wrap: wrap;
        gap: 15px;
    }
    .features-grid {
        grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    }
}

@media (max-width: 768px) {
    /* 헤더 모바일 최적화 */
    .main-header .container {
        flex-direction: column;
        gap: 15px;
        padding: 15px 0;
    }
    .logo { font-size: 1.3em; }
    .main-nav a { 
        margin: 0 15px; 
        font-size: 0.9em;
        min-height: 44px; /* Better touch target */
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    /* 메인 CTA 섹션 */
    .main-cta { padding: 40px 0; }
    .main-cta-info h1 { font-size: 2.0em; line-height: 1.3; }
    .main-cta-info p { font-size: 1.0em; }
    .main-cta-form { padding: 30px 20px; }
    .main-cta-form h3 { font-size: 1.4em; }
    
    /* 폼 요소들 모바일 최적화 */
    input[type="text"], input[type="url"] { 
        padding: 14px 16px; 
        font-size: 16px; /* iOS 줌 방지 */
        border-radius: 10px;
        min-height: 48px; /* Better touch target */
    }
    .btn, .btn-generate, .btn-submit {
        padding: 14px 16px;
        font-size: 1.0em;
        border-radius: 10px;
        min-height: 48px; /* Better touch target */
        min-width: 48px;
    }
    
    /* 피처 섹션 */
    .features { padding: 60px 0; }
    .features-grid {
        grid-template-columns: 1fr;
        gap: 25px;
    }
    .feature-card { 
        padding: 25px 20px; 
        min-height: 44px; /* Better touch target */
    }
    .feature-card .icon { font-size: 2.5em; }
    
    /* 보드 헤더 */
    .board-section { padding: 60px 0; }
    .board-header { 
        flex-direction: column; 
        gap: 15px; 
        text-align: center; 
    }
    .board-header h2 { font-size: 1.6em; }
    .board-stats { 
        justify-content: center;
        gap: 40px;
    }
    .stat-number { font-size: 1.6em; }
    
    /* 모바일 테이블 카드 스타일 - 강화된 버전 */
    .board-table {
        display: block;
        width: 100%;
        overflow: hidden;
    }
    /* 헤더 없는 테이블이므로 더 이상 헤더 숨김 불필요 */
    .board-table tbody {
        display: block;
    }
    .board-table tr {
        display: block;
        margin-bottom: 20px;
        background: var(--white-color);
        border: 1px solid var(--border-color);
        border-radius: 12px;
        padding: 20px;
        box-shadow: 0 4px 12px rgba(0,0,0,0.08);
        position: relative;
        overflow: hidden;
        width: 100%;
        min-height: 44px; /* Better touch target */
    }
    .board-table tr:hover {
        box-shadow: 0 6px 20px rgba(0,0,0,0.12);
        transform: translateY(-2px);
        transition: all 0.3s ease;
    }
    
    /* 카드 번호 배지 */
    .board-table tr::before {
        content: attr(data-number);
        position: absolute;
        top: -8px;
        right: 15px;
        background: var(--primary-color);
        color: white;
        padding: 4px 10px;
        border-radius: 12px;
        font-size: 0.8em;
        font-weight: 600;
    }
    
    .board-table td {
        display: block;
        text-align: left;
        padding: 8px 0;
        border: none;
        position: relative;
        word-wrap: break-word;
        overflow-wrap: break-word;
        max-width: 100%;
    }
    .board-table td:not(:first-child) {
        padding-left: 0;
        margin-top: 12px;
    }
    .board-table td:before {
        content: attr(data-label) ": ";
        font-weight: 600;
        color: var(--secondary-color);
        font-size: 0.9em;
        display: inline-block;
        min-width: 60px;
        margin-right: 8px;
    }
    .board-table td:first-child {
        display: none; /* 번호는 배지로 표시되므로 숨김 */
    }
    
    /* 보기 버튼 컬럼 스타일 */
    .board-table td[data-label="보기"] {
        text-align: center;
        padding-top: 15px;
    }
    
    .board-table td[data-label="보기"]:before {
        content: "";
        display: none;
    }
    
    /* 링크 스타일 개선 */
    .promotion-title {
        font-size: 1.1em;
        line-height: 1.4;
        margin-bottom: 8px;
        display: block;
        min-height: 44px; /* Better touch target */
    }
    .promotion-url {
        color: var(--primary-color);
        font-size: 0.9em;
        word-break: break-all;
        margin-top: 4px;
        min-height: 44px; /* Better touch target */
        display: flex;
        align-items: center;
    }
    
    /* 키워드 태그 개선 */
    .promotion-keywords {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        margin-top: 8px;
        max-width: 100%;
        overflow: hidden;
    }
    .promotion-keywords .keyword-tag {
        font-size: 0.8em;
        padding: 4px 10px;
        border-radius: 15px;
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        min-height: 36px; /* Better touch target */
    }
    
    /* 보기 버튼 개선 */
    .view-btn {
        display: inline-block;
        margin-top: 12px;
        padding: 8px 16px;
        background: linear-gradient(45deg, var(--primary-color), var(--primary-hover));
        border-radius: 20px;
        color: white !important;
        text-decoration: none;
        font-size: 0.9em;
        font-weight: 500;
        box-shadow: 0 2px 8px rgba(0,123,255,0.3);
        transition: all 0.3s ease;
        position: relative;
        z-index: 1;
        min-height: 44px; /* Better touch target */
        min-width: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    .view-btn:hover {
        transform: translateY(-1px);
        box-shadow: 0 4px 12px rgba(0,123,255,0.4);
    }
    /* 모바일에서 터치 영역 확대 */
    @media (hover: none) {
        .view-btn {
            padding: 10px 20px;
            margin: 12px 0;
        }
    }
    
    /* 키워드 태그 복사 버튼 */
    .keyword-tag {
        min-height: 40px; /* Better touch target */
    }
    
    /* 숨김된 번호 처리 */
    .hide-numbers .board-table tr::before {
        display: none;
    }
    
    .hide-numbers .board-table td:first-child {
        display: none;
    }
}

@media (max-width: 576px) {
    .container { padding: 0 12px; }
    
    /* 버튼 컨테이너 */
    .btn-container { 
        grid-template-columns: 1fr; 
        gap: 12px;
    }
    
    /* 메인 폼 */
    .main-cta-form { 
        padding: 20px 15px; 
        margin: 0 10px;
    }
    .main-cta-form h3 { font-size: 1.2em; }
    
    /* 보드 컨테이너 */
    .board-container { 
        padding: 20px 15px; 
        margin: 0 10px;
    }
    
    /* 제목들 */
    .section-title h2 { font-size: 1.6em; }
    .main-cta-info h1 { 
        font-size: 1.6em; 
        margin-bottom: 15px;
    }
    .main-cta-info p {
        font-size: 0.95em;
        margin-bottom: 20px;
    }
    
    /* 키워드 태그들 */
    .keyword-tag { 
        font-size: 0.8em; 
        padding: 5px 10px;
    }
    
    /* 통계 섹션 */
    .board-stats {
        gap: 30px;
        flex-wrap: wrap;
    }
    
    /* 페이지네이션 모바일 최적화 */
    .pagination {
        flex-wrap: wrap;
        gap: 8px;
        justify-content: center;
    }
    .pagination button {
        min-width: 40px;
        padding: 8px 10px;
        font-size: 0.9em;
    }
    
    /* 생성된 콘텐츠 섹션 */
    .generated-content-container {
        padding: 0 10px;
        max-width: 100%;
        overflow-x: hidden;
    }
    .generated-content-section { 
        padding: 40px 0; 
        overflow-x: hidden;
    }
    #contentPreview {
        padding: 20px 15px;
        font-size: 0.95em;
        max-height: 400px;
        overflow-x: auto;
        overflow-y: auto;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
    
    /* 콘텐츠 내부 모든 요소 오버플로우 방지 */
    #contentPreview * {
        max-width: 100%;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
    
    /* 토스트 메시지 */
    .toast {
        left: 10px;
        right: 10px;
        bottom: 10px;
        padding: 12px 15px;
        font-size: 0.9em;
    }
    
    /* 숨김된 번호 처리 - 작은 화면 */
    .board-table tr::before {
        display: none !important;
    }
    
    .board-table td:first-child {
        display: none !important;
    }
}

@media (max-width: 360px) {
    .main-cta-info h1 { font-size: 1.4em; }
    .board-table tr { padding: 15px; }
    .promotion-title { font-size: 1.0em; }
    
    /* 숨김된 번호 처리 - 매우 작은 화면 */
    .board-table tr::before {
        display: none !important;
    }
    
    .board-table td:first-child {
        display: none !important;
    }
}