/* ========== 변수 정의 ========== */
:root {
    --primary-color: #1e3c72;
    --gradient-start: #1e3c72;
    --gradient-end: #2a5298;
    --success-color: #28a745;
    --error-color: #dc3545;
    --warning-color: #ffc107;
}

/* ========== 기본 스타일 ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, var(--gradient-start) 0%, var(--gradient-end) 100%);
    min-height: 100vh;
    color: #333;
    transition: background 0.3s ease;
}

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

/* ========== 헤더 ========== */
header {
    text-align: center;
    background: white;
    border-radius: 15px;
    padding: 25px;
    margin-bottom: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

.header-icon {
    font-size: 2.5rem;
}

header h1 {
    color: var(--primary-color);
    font-size: 1.8rem;
    transition: color 0.3s ease;
}

.topic-selector {
    margin-top: 15px;
}

.topic-selector select {
    padding: 10px 20px;
    font-size: 1rem;
    border: 2px solid var(--primary-color);
    border-radius: 8px;
    background: white;
    color: var(--primary-color);
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
}

.topic-selector select:hover {
    background: var(--primary-color);
    color: white;
}

/* ========== 자동 모드 컨테이너 ========== */
.auto-mode-container {
    background: linear-gradient(135deg, #ff6b6b 0%, #ffd93d 100%);
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

.auto-mode-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.auto-mode-title {
    color: white;
    font-size: 1.2rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

.toggle-switch {
    position: relative;
    width: 70px;
    height: 35px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255,255,255,0.3);
    transition: .4s;
    border-radius: 35px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 27px;
    width: 27px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .toggle-slider {
    background-color: #4CAF50;
}

input:checked + .toggle-slider:before {
    transform: translateX(35px);
}

.auto-mode-status {
    color: white;
    font-size: 0.95rem;
    padding: 10px;
    background: rgba(0,0,0,0.2);
    border-radius: 10px;
    text-align: center;
}

/* ========== 메인 컨텐츠 ========== */
.main-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

@media (max-width: 900px) {
    .main-content {
        grid-template-columns: 1fr;
    }
}

.auto-mode-disable {
    opacity: 0.5;
    pointer-events: none;
}

/* ========== 패널 공통 ========== */
.input-panel, .output-panel {
    background: white;
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

.section-title {
    color: var(--primary-color);
    font-size: 1.2rem;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #e0e0e0;
    transition: color 0.3s ease;
}

/* ========== 입력 그룹 ========== */
.input-group {
    margin-bottom: 18px;
}

.input-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: #555;
    font-size: 0.95rem;
}

.input-group input,
.input-group select,
.input-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 0.95rem;
    transition: all 0.3s ease;
}

.input-group input:focus,
.input-group select:focus,
.input-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(30, 60, 114, 0.1);
}

.input-group textarea {
    resize: vertical;
    min-height: 80px;
}

.keyword-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    align-items: end;
}

.keyword-row-wrapper {
    position: relative;
}

.keyword-row select {
    width: 90px;
}

/* 지역 체크 오버레이 */
.region-overlay {
    position: absolute;
    top: 50%;
    right: 100px;
    transform: translateY(-50%);
    background: rgba(33, 150, 243, 0.95);
    color: white;
    padding: 15px 25px;
    border-radius: 30px;
    font-size: 1.1rem;
    font-weight: 700;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    white-space: nowrap;
    z-index: 10;
    box-shadow: 0 4px 15px rgba(33, 150, 243, 0.4);
}

.region-overlay.show {
    opacity: 1;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { transform: translateY(-50%) scale(1); }
    50% { transform: translateY(-50%) scale(1.08); }
}

/* ========== 지역 체크박스 ========== */
.region-check {
    float: right;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: #e8f4ff;
    padding: 3px 10px;
    border-radius: 15px;
    font-size: 0.85rem;
}

.region-check input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin: 0;
    cursor: pointer;
    accent-color: #2196f3;
}

.region-check label {
    display: inline !important;
    margin: 0 !important;
    font-weight: 500 !important;
    font-size: 0.85rem !important;
    color: #2196f3 !important;
    cursor: pointer;
}

.input-hint {
    margin-top: 6px;
    font-size: 0.8rem;
    color: #2196f3;
    background: #e8f4ff;
    padding: 6px 10px;
    border-radius: 5px;
}

/* ========== 네이버 옵션 섹션 ========== */
.naver-section {
    background: #f8f9fa;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 18px;
}

.naver-section-title {
    color: #333;
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.naver-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.checkbox-item {
    display: flex;
    align-items: center;
    padding: 8px 10px;
    background: white;
    border-radius: 6px;
    transition: all 0.2s ease;
    cursor: pointer;
}

.checkbox-item:hover {
    background: #e8f4ff;
}

.checkbox-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-right: 8px;
    cursor: pointer;
    accent-color: var(--primary-color);
}

.checkbox-item label {
    cursor: pointer;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ========== 글 구조 선택 ========== */
.structure-section {
    margin-top: 15px;
}

.structure-section h4 {
    color: #666;
    font-size: 0.95rem;
    margin-bottom: 10px;
}

.structure-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

@media (max-width: 600px) {
    .structure-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.struct-btn {
    padding: 8px 10px;
    background: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.85rem;
    font-weight: 500;
}

.struct-btn:hover {
    background: #e0e0e0;
    transform: translateY(-1px);
}

.struct-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.structure-hint {
    color: #888;
    font-size: 0.8rem;
    margin-top: 8px;
}

/* ========== 출력 영역 ========== */
.output-textarea {
    width: 100%;
    min-height: 350px;
    padding: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 1.6;
    resize: vertical;
}

.output-textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* ========== 랜덤 정보 ========== */
.random-info {
    background: #fff3cd;
    border: 2px solid #ffc107;
    border-radius: 10px;
    padding: 15px;
    margin-top: 15px;
    display: none;
}

.random-info.active {
    display: block;
}

.random-info-title {
    color: #856404;
    font-weight: 600;
    margin-bottom: 10px;
}

.random-values {
    font-family: monospace;
    color: #333;
    line-height: 1.8;
    font-size: 0.9rem;
}

/* ========== 플로팅 버튼 ========== */
.floating-buttons {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.95);
    padding: 12px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    backdrop-filter: blur(10px);
}

@media (max-width: 600px) {
    .floating-buttons {
        bottom: 10px;
        left: 50%;
        transform: translateX(-50%);
        width: calc(100% - 20px);
        justify-content: center;
        flex-wrap: wrap;
    }
}

.floating-btn {
    padding: 10px 14px;
    border: none;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    white-space: nowrap;
}

.floating-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none !important;
}

.floating-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

.btn-random {
    background: linear-gradient(135deg, #ff6b6b 0%, #ffd93d 100%);
    color: white;
}

.btn-generate {
    background: linear-gradient(135deg, var(--gradient-start) 0%, var(--gradient-end) 100%);
    color: white;
}

.btn-copy {
    background: #28a745;
    color: white;
}

.btn-save {
    background: #17a2b8;
    color: white;
}

.btn-reset {
    background: #6c757d;
    color: white;
}

.btn-clear {
    background: #fd7e14;
    color: white;
}

/* ========== 알림 ========== */
.notification {
    position: fixed;
    bottom: 120px;
    right: 30px;
    padding: 15px 25px;
    background: var(--success-color);
    color: white;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    font-weight: 600;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
    z-index: 1001;
}

.notification.show {
    opacity: 1;
    transform: translateY(0);
}

.notification.error {
    background: var(--error-color);
}

/* ========== 마크다운 변환기 플로팅 버튼 ========== */
.md-floating-btn {
    position: fixed;
    bottom: 20px;
    left: 20px;
    padding: 12px 16px;
    background: linear-gradient(135deg, #03c75a 0%, #02a84d 100%);
    color: white;
    border: none;
    border-radius: 25px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(3, 199, 90, 0.4);
    z-index: 999;
    transition: all 0.3s ease;
}

.md-floating-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(3, 199, 90, 0.5);
}

/* ========== 마크다운 변환기 모달 ========== */
.md-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: none;
}

.md-modal-overlay.active {
    display: block;
}

.md-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    width: 95%;
    max-width: 1200px;
    height: 85vh;
    background: white;
    border-radius: 15px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    z-index: 1001;
    display: none;
    flex-direction: column;
    opacity: 0;
    transition: all 0.3s ease;
}

.md-modal.active {
    display: flex;
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

.md-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: linear-gradient(135deg, #03c75a 0%, #02a84d 100%);
    color: white;
    border-radius: 15px 15px 0 0;
}

.md-modal-header h2 {
    font-size: 1.1rem;
    margin: 0;
}

.md-close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    transition: background 0.2s;
}

.md-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.md-modal-body {
    flex: 1;
    padding: 15px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.md-panels {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    flex: 1;
    min-height: 0;
}

.md-panel {
    display: flex;
    flex-direction: column;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    overflow: hidden;
}

.md-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background: #f5f5f5;
    font-weight: 600;
    font-size: 0.9rem;
}

.md-panel-header button {
    padding: 5px 12px;
    background: #03c75a;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 0.8rem;
    cursor: pointer;
}

.md-panel-header button:hover {
    background: #02a84d;
}

.md-char-count {
    font-size: 0.85rem;
    color: #666;
}

.md-char-count strong {
    color: #03c75a;
    font-size: 1rem;
}

.md-panel textarea {
    flex: 1;
    border: none;
    padding: 15px;
    font-size: 0.9rem;
    line-height: 1.7;
    resize: none;
    font-family: 'D2Coding', 'Consolas', monospace;
}

.md-panel textarea:focus {
    outline: none;
}

.md-preview {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    line-height: 1.8;
    font-size: 0.95rem;
}

.md-preview h1 {
    font-size: 1.4rem;
    margin: 15px 0 10px 0;
    color: #333;
}

.md-preview h2 {
    font-size: 1.2rem;
    margin: 12px 0 8px 0;
    color: #333;
    border-bottom: 2px solid #333;
    padding-bottom: 5px;
}

.md-preview h3 {
    font-size: 1.1rem;
    margin: 10px 0 6px 0;
    color: #333;
}

.md-preview p {
    margin: 8px 0;
    color: #333;
}

.md-preview strong {
    font-weight: bold;
}

.md-preview blockquote {
    border-left: 4px solid #03c75a;
    padding: 10px 15px;
    margin: 12px 0;
    background: #f0fdf4;
    color: #333;
}

.md-preview ul, .md-preview ol {
    margin: 10px 0 10px 20px;
}

.md-preview li {
    margin: 5px 0;
}

.md-preview hr {
    border: none;
    border-top: 1px solid #ddd;
    margin: 15px 0;
}

.md-bottom-btns {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    justify-content: center;
}

.md-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.md-btn-clear {
    background: #6c757d;
    color: white;
}

.md-btn-copy-html {
    background: #03c75a;
    color: white;
}

.md-btn-copy-text {
    background: #17a2b8;
    color: white;
}

.md-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
}

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

    .md-modal {
        height: 90vh;
        width: 98%;
    }

    .md-floating-btn {
        bottom: 20px;
        left: 10px;
        padding: 10px 14px;
        font-size: 0.8rem;
    }
}

/* ========== 반응형 조정 ========== */
@media (max-width: 500px) {
    .container {
        padding: 10px;
        padding-bottom: 90px;
    }

    header h1 {
        font-size: 1.4rem;
    }

    .header-icon {
        font-size: 2rem;
    }

    .floating-btn {
        padding: 8px 10px;
        font-size: 0.75rem;
    }

    .naver-options {
        grid-template-columns: 1fr;
    }
}
