/* ===========================
   Global Styles & Variables
   =========================== */
:root {
    /* Brand Colors - 로켓단게임즈 스타일 */
    --primary-color: #E8344E;
    --primary-dark: #C72D42;
    --primary-light: #ED5A6E;
    --secondary-color: #4ECDC4;
    --accent-color: #FFE66D;
    
    /* UI Colors */
    --background: #F7F9FC;
    --surface: #FFFFFF;
    --border: #E1E8ED;
    --text-primary: #2C3E50;
    --text-secondary: #7F8C97;
    --text-muted: #ADB5BD;
    
    /* Status Colors */
    --success: #10B981;
    --warning: #F59E0B;
    --error: #EF4444;
    --info: #3B82F6;
    
    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.12);
    
    /* Spacing */
    --spacing-xs: 8px;
    --spacing-sm: 12px;
    --spacing-md: 20px;
    --spacing-lg: 32px;
    --spacing-xl: 48px;
    
    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 16px;
    
    /* Typography */
    --font-primary: 'Noto Sans KR', 'Noto Sans', sans-serif;
}

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

body {
    font-family: var(--font-primary);
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Ensure all form elements use Noto Sans */
input, button, textarea, select {
    font-family: var(--font-primary);
}

/* ===========================
   Header
   =========================== */
.header {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    background-size: 200% 200%;
    animation: gradientShift 15s ease infinite;
    color: white;
    padding: var(--spacing-xl) var(--spacing-lg);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    position: relative;
    overflow: hidden;
}

.header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, var(--primary-color) 0%, transparent 50%);
    opacity: 0.15;
    pointer-events: none;
}

.header::after {
    content: '';
    position: absolute;
    top: -50%;
    right: -10%;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(232, 52, 78, 0.15) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
}

@keyframes gradientShift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.header-content {
    max-width: 1600px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    z-index: 1;
}

.header-left {
    display: flex;
    align-items: center;
    gap: var(--spacing-lg);
}

.logo-badge {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--primary-color) 0%, #FF6B9D 100%);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    box-shadow: 0 8px 24px rgba(232, 52, 78, 0.4);
    transition: all 0.3s ease;
}

.logo-badge:hover {
    transform: translateY(-4px) rotate(-5deg);
    box-shadow: 0 12px 32px rgba(232, 52, 78, 0.6);
}

.logo-badge i {
    color: white;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.header-text {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.header-title {
    font-size: 1.75rem;
    font-weight: 800;
    margin: 0;
    background: linear-gradient(135deg, #ffffff 0%, #e0e0e0 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.5px;
}

.header-subtitle {
    font-size: 0.95rem;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.7);
    margin: 0;
    letter-spacing: 0.3px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.status-badge {
    font-size: 0.85rem;
    padding: 10px 18px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    font-weight: 500;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-badge:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
}

.settings-btn {
    color: white;
    text-decoration: none;
    padding: 10px 24px;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.95rem;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.settings-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

.settings-btn i {
    transition: transform 0.3s ease;
}

.settings-btn:hover i {
    transform: rotate(90deg);
}



/* ===========================
   Footer
   =========================== */
.footer {
    background: var(--text-primary);
    color: rgba(255, 255, 255, 0.7);
    text-align: center;
    padding: var(--spacing-lg) var(--spacing-md);
    margin-top: var(--spacing-xl);
}

.footer p {
    font-size: 0.9rem;
    font-family: var(--font-primary);
    margin: 0;
}

/* ===========================
   Main Container
   =========================== */
.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: var(--spacing-lg);
    display: grid;
    grid-template-columns: 1fr 380px 1fr;
    gap: var(--spacing-lg);
    margin-right: 80px; /* Space for history sidebar */
}

/* ===========================
   Section Styles
   =========================== */
.section {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.3s ease;
}

.section:hover {
    box-shadow: var(--shadow-md);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-md);
    padding-bottom: var(--spacing-sm);
    border-bottom: 2px solid var(--border);
}

.section-header h2 {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.section-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}

.section-header i {
    color: var(--primary-color);
}

/* ===========================
   Input Section
   =========================== */
.char-count {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-family: var(--font-primary);
    font-variant-numeric: tabular-nums;
}

.review-input {
    width: 100%;
    min-height: 200px;
    padding: var(--spacing-md);
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-family: var(--font-primary);
    resize: vertical;
    transition: border-color 0.3s ease;
    line-height: 1.6;
}

.review-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.btn-analyze {
    width: 100%;
    margin-top: var(--spacing-md);
    padding: var(--spacing-md);
    font-size: 1.1rem;
    font-weight: 600;
}

.translation-section {
    margin-top: var(--spacing-lg);
    padding-top: var(--spacing-lg);
    border-top: 2px solid var(--border);
}

.detected-lang {
    display: inline-block;
    padding: 4px 12px;
    background: var(--secondary-color);
    color: white;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
}

.translation-result {
    padding: var(--spacing-md);
    background: #F8FAFB;
    border-radius: var(--radius-md);
    border-left: 4px solid var(--secondary-color);
    font-size: 1rem;
    line-height: 1.8;
    margin-top: var(--spacing-sm);
}

/* ===========================
   Template Section
   =========================== */
.recommended-badge {
    padding: var(--spacing-sm) var(--spacing-md);
    background: linear-gradient(135deg, var(--accent-color) 0%, #FFD93D 100%);
    border-radius: var(--radius-md);
    margin-bottom: var(--spacing-md);
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--spacing-xs);
    font-weight: 600;
    color: #856404;
    box-shadow: var(--shadow-sm);
    min-height: 40px;
}

.recommended-badge i {
    color: #F59E0B;
}

.template-buttons {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.btn-template {
    width: 100%;
    padding: var(--spacing-md);
    text-align: left;
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.3s ease;
}

.btn-template i {
    font-size: 1.2rem;
    width: 24px;
    text-align: center;
}

.btn-template:hover {
    transform: translateX(4px);
    box-shadow: var(--shadow-sm);
}

.btn-template.active:hover {
    background: var(--primary-dark);
    transform: translateX(6px);
}

.btn-template.active {
    background: var(--primary-color);
    color: white;
    box-shadow: var(--shadow-md);
    font-weight: 600;
    border: 2px solid var(--primary-dark);
    transform: translateX(4px);
}

.btn-template.active i {
    color: white;
    opacity: 1;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.2));
}

.btn-template.recommended {
    border: 2px solid var(--accent-color);
    background: #FFFBEB;
    position: relative;
}

.btn-template.recommended::before {
    content: '⭐';
    position: absolute;
    right: 12px;
    font-size: 1.2rem;
}

/* 선택된 템플릿이 추천 템플릿일 때 */
.btn-template.active.recommended {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.btn-template.active.recommended::before {
    content: '⭐✓';
    color: white;
}

/* ===========================
   Result Section
   =========================== */
.result-container {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.response-box {
    background: #F8FAFB;
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
    border: 1px solid var(--border);
}

.response-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-sm);
}

.response-content {
    padding: var(--spacing-md);
    background: white;
    border-radius: var(--radius-sm);
    border-left: 4px solid var(--primary-color);
    font-size: 1rem;
    line-height: 1.8;
    white-space: pre-wrap;
}

.response-edit {
    width: 100%;
    padding: var(--spacing-md);
    background: white;
    border: 2px solid var(--primary-color);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    line-height: 1.8;
    font-family: inherit;
    resize: vertical;
    min-height: 120px;
    transition: border-color 0.3s ease;
}

.response-edit:focus {
    outline: none;
    border-color: var(--primary-dark);
    box-shadow: 0 0 0 3px rgba(232, 52, 78, 0.1);
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-xl);
    color: var(--text-muted);
    text-align: center;
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: var(--spacing-md);
    opacity: 0.5;
}

.empty-state p {
    font-size: 1rem;
    line-height: 1.6;
}

/* ===========================
   Buttons
   =========================== */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font-primary);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-xs);
    box-shadow: var(--shadow-sm);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

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

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

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-dark) 0%, #D04A1D 100%);
}

.btn-template {
    background: white;
    color: var(--text-primary);
    border: 2px solid var(--border);
}

.btn-template:hover {
    border-color: var(--primary-color);
    background: #FFF5F2;
}

.btn-copy {
    background: var(--secondary-color);
    color: white;
    padding: 6px 14px;
    font-size: 0.85rem;
}

.btn-copy:hover {
    background: #3DB9B0;
}

.btn-copy-small {
    padding: 6px 12px;
    font-size: 0.8rem;
}

.btn-edit {
    background: #3B82F6;
    color: white;
    padding: 6px 14px;
    font-size: 0.85rem;
}

.btn-edit:hover {
    background: #2563EB;
}

.btn-save {
    background: #10B981;
    color: white;
    padding: 6px 14px;
    font-size: 0.85rem;
}

.btn-save:hover {
    background: #059669;
}

.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: var(--spacing-xs);
    border-radius: var(--radius-sm);
    transition: all 0.3s ease;
}

.btn-icon:hover {
    background: var(--border);
    color: var(--text-primary);
}

/* ===========================
   History Sidebar
   =========================== */
.history-sidebar {
    position: fixed;
    right: 0;
    top: 0;
    height: 100vh;
    width: 360px;
    background: var(--surface);
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.1);
    transform: translateX(100%);
    transition: transform 0.3s ease;
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

.history-sidebar.open {
    transform: translateX(0);
}

.history-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.history-overlay.active {
    opacity: 1;
    visibility: visible;
}

.history-header {
    padding: var(--spacing-lg);
    border-bottom: 2px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, #F8FAFB 0%, white 100%);
}

.history-header h3 {
    font-size: 1.2rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.history-header i {
    color: var(--primary-color);
}

.history-list {
    flex: 1;
    overflow-y: auto;
    padding: var(--spacing-md);
}

.history-item {
    padding: var(--spacing-md);
    background: #F8FAFB;
    border-radius: var(--radius-md);
    margin-bottom: var(--spacing-sm);
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.history-item:hover {
    background: white;
    border-color: var(--primary-color);
    transform: translateX(-4px);
    box-shadow: var(--shadow-md);
}

.history-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-xs);
}

.history-item-lang {
    font-size: 0.75rem;
    padding: 2px 8px;
    background: var(--secondary-color);
    color: white;
    border-radius: 12px;
    font-weight: 500;
}

.history-item-time {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.history-item-review {
    font-size: 0.85rem;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-height: 1.4;
    margin-bottom: var(--spacing-xs);
}

.history-item-template {
    font-size: 0.8rem;
    color: var(--primary-color);
    font-weight: 600;
}

.history-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-xl);
    color: var(--text-muted);
    text-align: center;
}

.history-empty i {
    font-size: 3rem;
    margin-bottom: var(--spacing-md);
    opacity: 0.3;
}

.history-toggle {
    position: fixed;
    right: var(--spacing-md);
    top: 120px;
    width: 50px;
    height: 50px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    transition: all 0.3s ease;
    z-index: 999;
}

.history-toggle:hover {
    background: var(--primary-dark);
    transform: scale(1.1);
}

/* ===========================
   Loading Overlay
   =========================== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.loading-spinner {
    background: white;
    padding: var(--spacing-xl);
    border-radius: var(--radius-lg);
    text-align: center;
    box-shadow: var(--shadow-lg);
}

.loading-spinner i {
    font-size: 3rem;
    color: var(--primary-color);
    margin-bottom: var(--spacing-md);
}

.loading-spinner p {
    font-size: 1.1rem;
    color: var(--text-primary);
    font-weight: 500;
    margin-bottom: var(--spacing-sm);
}

.loading-progress {
    width: 250px;
    height: 4px;
    background: #E5E7EB;
    border-radius: 2px;
    overflow: hidden;
    margin-top: var(--spacing-md);
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--primary-light));
    width: 0%;
    transition: width 0.3s ease;
    animation: progressPulse 1.5s ease-in-out infinite;
}

@keyframes progressPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* ===========================
   Toast Notification
   =========================== */
.toast {
    position: fixed;
    bottom: var(--spacing-lg);
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--text-primary);
    color: white;
    padding: var(--spacing-md) var(--spacing-lg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    font-size: 0.95rem;
    font-weight: 500;
    z-index: 3000;
    opacity: 0;
    transition: all 0.3s ease;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast.success {
    background: var(--success);
}

.toast.error {
    background: var(--error);
}

/* ===========================
   Responsive Design
   =========================== */
@media (max-width: 1400px) {
    .container {
        grid-template-columns: 1fr 320px 1fr;
        gap: var(--spacing-md);
    }
}

@media (max-width: 1200px) {
    .container {
        grid-template-columns: 1fr;
        margin-right: 0;
        padding: var(--spacing-md);
    }
    
    .history-sidebar {
        width: 100%;
        max-width: 400px;
    }
    
    .header-content {
        flex-wrap: wrap;
    }
    
    .header-title {
        font-size: 1.5rem;
    }
}

@media (max-width: 768px) {
    .header {
        padding: var(--spacing-lg) var(--spacing-md);
    }
    
    .header-content {
        flex-direction: column;
        gap: var(--spacing-lg);
        align-items: flex-start;
    }
    
    .header-left {
        gap: var(--spacing-md);
    }
    
    .logo-badge {
        width: 56px;
        height: 56px;
        font-size: 1.75rem;
    }
    
    .header-title {
        font-size: 1.3rem;
    }
    
    .header-subtitle {
        font-size: 0.85rem;
    }
    
    .header-right {
        width: 100%;
        justify-content: space-between;
    }
    
    .status-badge {
        font-size: 0.8rem;
        padding: 8px 14px;
    }
    
    .settings-btn {
        padding: 8px 16px;
        font-size: 0.85rem;
    }
    
    .section {
        padding: var(--spacing-md);
    }
    
    .btn-analyze {
        font-size: 1rem;
    }
    
    .history-toggle {
        right: var(--spacing-sm);
        top: 100px;
        width: 45px;
        height: 45px;
        font-size: 1rem;
    }
    
    .recommended-badge {
        font-size: 0.9rem;
        padding: var(--spacing-xs) var(--spacing-sm);
    }
    
    #recommendSource {
        font-size: 0.75em !important;
    }
    
    .btn-template.recommended::before {
        font-size: 1rem;
        right: 8px;
    }
}

/* ===========================
   Animations
   =========================== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.3s ease;
}

/* ===========================
   Scrollbar Styling
   =========================== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--background);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}
