/* 다크 테마 공통 스타일 */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    color: #e0e6ed;
    min-height: 100vh;
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* 메인 레이아웃 */
.main-layout {
    display: flex;
    gap: 30px;
    align-items: flex-start;
}

.main-content {
    flex: 2;
    min-width: 0; /* flexbox에서 텍스트 오버플로우 방지 */
}

/* 헤더 스타일 */
.header {
    text-align: center;
    margin-bottom: 50px;
    padding: 40px 0;
}

.header h1 {
    font-size: 3rem;
    margin-bottom: 20px;
    background: linear-gradient(45deg, #64b5f6, #42a5f5, #2196f3);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 30px rgba(100, 181, 246, 0.3);
}

.header p {
    font-size: 1.2rem;
    color: #b0bec5;
    max-width: 600px;
    margin: 0 auto;
}

/* 템플릿 카드 스타일 */
.template-card {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 15px;
    padding: 25px;
    text-align: center;
    transition: all 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    position: relative;
    overflow: hidden;
}

.template-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transition: left 0.5s;
}

.template-card:hover::before {
    left: 100%;
}

.template-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    border-color: rgba(100, 181, 246, 0.5);
}

.template-icon {
    font-size: 3.5rem;
    margin-bottom: 18px;
    color: #64b5f6;
}

.template-card h3 {
    font-size: 1.3rem;
    margin-bottom: 22px;
    color: #e0e6ed;
}

/* 버튼 스타일 */
.download-btn {
    background: linear-gradient(45deg, #64b5f6, #42a5f5);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 25px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
    position: relative;
    overflow: hidden;
    flex: 1;
    max-width: 150px;
    text-align: center;
}

.download-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(100, 181, 246, 0.4);
    background: linear-gradient(45deg, #42a5f5, #2196f3);
}

.download-btn:active {
    transform: translateY(0);
}

.button-container {
    display: flex;
    gap: 10px;
    justify-content: center;
    align-items: center;
    margin-top: 20px;
}

.preview-btn {
    background: rgba(255, 255, 255, 0.1);
    color: #e0e6ed;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 12px 25px;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
    flex: 1;
    max-width: 150px;
    text-align: center;
}

.preview-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

/* Features 스타일 */
.features {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 20px;
    padding: 40px;
    margin-top: 50px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.features h2 {
    text-align: center;
    margin-bottom: 30px;
    color: #64b5f6;
    font-size: 2rem;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.feature-item {
    display: flex;
    align-items: center;
    padding: 15px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    transition: all 0.3s ease;
}

.feature-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.feature-icon {
    font-size: 1.5rem;
    margin-right: 15px;
    color: #64b5f6;
}

/* 모달 스타일 */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
}

.modal-content {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    margin: 5% auto;
    padding: 30px;
    border-radius: 20px;
    width: 80%;
    max-width: 800px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    position: absolute;
    top: 15px;
    right: 20px;
}

.close:hover {
    color: #e0e6ed;
}

.preview-content {
    background: rgba(255, 255, 255, 0.05);
    padding: 20px;
    border-radius: 10px;
    margin-top: 20px;
    white-space: pre-line;
    font-family: 'Courier New', monospace;
    line-height: 1.8;
}

/* 광고 영역 스타일 */
.ad-banner {
    margin: 30px 0;
    text-align: center;
}

.ad-banner.ad-top {
    margin-top: 0;
    margin-bottom: 40px;
}

.ad-banner.ad-bottom {
    margin-top: 40px;
    margin-bottom: 0;
}

.ad-content {
    display: inline-block;
    background: rgba(255, 255, 255, 0.05);
    border: 2px dashed rgba(255, 255, 255, 0.2);
    border-radius: 15px;
    padding: 20px;
    transition: all 0.3s ease;
}

.ad-content:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(100, 181, 246, 0.3);
}

.ad-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #b0bec5;
    font-size: 1.1rem;
    min-height: 90px;
    min-width: 728px;
    background: linear-gradient(45deg, rgba(100, 181, 246, 0.1), rgba(66, 165, 245, 0.1));
    border-radius: 10px;
    transition: all 0.3s ease;
}

.ad-placeholder:hover {
    background: linear-gradient(45deg, rgba(100, 181, 246, 0.15), rgba(66, 165, 245, 0.15));
    transform: scale(1.02);
}

.ad-placeholder i {
    font-size: 2rem;
    margin-bottom: 10px;
    color: #64b5f6;
}

.ad-sidebar {
    flex-shrink: 0;
    position: sticky;
    top: 20px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* 인기 템플릿 TOP 5 스타일 */
.popular-templates {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 15px;
    padding: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
}

.popular-templates h3 {
    color: #64b5f6;
    font-size: 1.2rem;
    margin-bottom: 15px;
    text-align: center;
}

.popular-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.popular-item {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    transition: all 0.3s ease;
}

.popular-item:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: translateX(5px);
}

.popular-item .rank {
    background: linear-gradient(45deg, #64b5f6, #42a5f5);
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: bold;
    margin-right: 12px;
    flex-shrink: 0;
}

.popular-item .template-link {
    color: #e0e6ed;
    text-decoration: none;
    font-size: 0.9rem;
    flex: 1;
    transition: color 0.3s ease;
}

.popular-item .template-link:hover {
    color: #64b5f6;
}

.ad-sidebar .ad-content {
    background: rgba(255, 255, 255, 0.05);
    border: 2px dashed rgba(255, 255, 255, 0.2);
    border-radius: 15px;
    padding: 15px;
    transition: all 0.3s ease;
    position: sticky;
    top: calc(100vh - 600px - 24px); /* 뷰포트 하단 24px 여유 */
    box-sizing: border-box;
}

.ad-sidebar .ad-content:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(100, 181, 246, 0.3);
}

.ad-sidebar .ad-placeholder {
    height: 600px; /* 기본 높이 */
    width: 100%;
    max-width: 300px;
    min-width: 300px;
    background: linear-gradient(45deg, rgba(100, 181, 246, 0.1), rgba(66, 165, 245, 0.1));
    border-radius: 10px;
    transition: all 0.3s ease;
    box-sizing: border-box;
    position: relative;
    overflow: hidden;
}

/* 멀티사이즈 광고 (300x600) */
.ad-sidebar .ad-placeholder.multi-size {
    height: 600px;
}

/* CLS 방지를 위한 고정 높이 */
.ad-sidebar .ad-placeholder::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: inherit;
    z-index: 1;
}

.ad-sidebar .ad-placeholder:hover {
    background: linear-gradient(45deg, rgba(100, 181, 246, 0.15), rgba(66, 165, 245, 0.15));
    transform: scale(1.02);
}

.ad-sidebar .ad-placeholder i {
    font-size: 3rem;
    margin-bottom: 15px;
    color: #64b5f6;
}

/* 푸터 스타일 */
.footer {
    text-align: center;
    margin-top: 50px;
    padding: 30px 0;
    color: #b0bec5;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* 계산기 공통 스타일 */
.calculator-container {
    display: flex;
    gap: 30px;
    margin-bottom: 50px;
}

.calculator-form {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 15px;
    padding: 30px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
}

.calculator-form h2 {
    color: #64b5f6;
    font-size: 1.8rem;
    margin-bottom: 15px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.calculator-form .description {
    color: #b0bec5;
    text-align: center;
    margin-bottom: 30px;
    font-size: 1rem;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    color: #e0e6ed;
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 1rem;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px 15px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: #e0e6ed;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #64b5f6;
    background: rgba(255, 255, 255, 0.15);
    box-shadow: 0 0 0 3px rgba(100, 181, 246, 0.1);
}

.form-group input::placeholder {
    color: #8a9ba8;
}

.form-group small {
    display: block;
    color: #8a9ba8;
    font-size: 0.85rem;
    margin-top: 5px;
}

.button-container {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 30px;
}

.calc-btn,
.reset-btn {
    padding: 12px 25px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 120px;
    justify-content: center;
}

.calc-btn {
    background: linear-gradient(45deg, #64b5f6, #42a5f5);
    color: white;
}

.calc-btn:hover {
    background: linear-gradient(45deg, #42a5f5, #2196f3);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(100, 181, 246, 0.3);
}

.reset-btn {
    background: rgba(255, 255, 255, 0.1);
    color: #e0e6ed;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.reset-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.calculator-result {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 15px;
    padding: 30px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
}

.calculator-result h3 {
    color: #64b5f6;
    font-size: 1.5rem;
    margin-bottom: 20px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.result-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.result-item {
    background: rgba(255, 255, 255, 0.05);
    padding: 15px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.result-item.highlight {
    background: linear-gradient(45deg, rgba(100, 181, 246, 0.1), rgba(66, 165, 245, 0.1));
    border-color: rgba(100, 181, 246, 0.3);
}

.result-item .label {
    color: #b0bec5;
    font-weight: 500;
}

.result-item .value {
    color: #e0e6ed;
    font-weight: 600;
    font-size: 1.1rem;
}

.calculation-info {
    background: rgba(255, 255, 255, 0.03);
    padding: 20px;
    border-radius: 8px;
    margin-top: 20px;
}

.calculation-info h4 {
    color: #64b5f6;
    margin-bottom: 10px;
}

.calculation-info p {
    color: #b0bec5;
    line-height: 1.6;
    margin: 0;
}

/* 뒤로가기 버튼 */
.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #64b5f6;
    text-decoration: none;
    font-weight: 500;
    margin-bottom: 20px;
    padding: 8px 15px;
    border-radius: 6px;
    transition: all 0.3s ease;
    background: rgba(100, 181, 246, 0.1);
    border: 1px solid rgba(100, 181, 246, 0.2);
}

.back-btn:hover {
    background: rgba(100, 181, 246, 0.2);
    transform: translateX(-3px);
}

/* 반응형 스타일 */
@media (max-width: 768px) {
    .header h1 {
        font-size: 2rem;
    }
    
    .templates-grid {
        grid-template-columns: 1fr;
    }
    
    .template-card {
        padding: 20px;
    }

    .modal-content {
        width: 95%;
        margin: 10% auto;
        padding: 20px;
    }

    .ad-placeholder {
        min-width: 100%;
        font-size: 0.9rem;
    }

    .main-layout {
        flex-direction: column;
        gap: 20px;
    }

    .ad-sidebar {
        width: 100%;
        position: static;
        order: -1; /* 모바일에서는 사이드바를 상단으로 이동 */
    }

    .ad-sidebar .ad-content {
        position: static;
    }

    .ad-sidebar .ad-placeholder {
        min-width: 100%;
        min-height: 400px;
    }

    /* 계산기 반응형 */
    .calculator-container {
        flex-direction: column;
        gap: 20px;
    }

    .calculator-form,
    .calculator-result {
        padding: 20px;
    }

    .result-grid {
        grid-template-columns: 1fr;
    }

    .button-container {
        flex-direction: column;
    }

    .calc-btn,
    .reset-btn {
        width: 100%;
    }
}