/* Korean Typography and Custom Styles */
body {
    font-family: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.7;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #2c3e50;
}

/* Improved Color Scheme */
:root {
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --secondary-gradient: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --success-gradient: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    --card-bg: rgba(255, 255, 255, 0.95);
    --text-primary: #2c3e50;
    --text-secondary: #7f8c8d;
    --border-color: rgba(255, 255, 255, 0.2);
    --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 10px 25px rgba(0, 0, 0, 0.08);
    --shadow-sm: 0 5px 15px rgba(0, 0, 0, 0.05);
}

/* Navigation Bar Styling */
.navbar {
    background: rgba(255, 255, 255, 0.1) !important;
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color) !important;
    padding: 1rem 0;
}

.navbar-brand {
    font-size: 1.5rem;
    font-weight: 700;
    color: white !important;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Hero Section */
.hero-section {
    margin-bottom: 3rem;
}

.hero-section h1 {
    font-size: 3rem;
    font-weight: 800;
    background: linear-gradient(45deg, #fff, #e3f2fd);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    margin-bottom: 1.5rem;
}

.hero-section .lead {
    font-size: 1.25rem;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 400;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Custom Card Styling */
.main-interface-card {
    border-radius: 25px;
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    transition: all 0.3s ease;
    overflow: hidden;
}

.main-interface-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.15);
}

.main-interface-card .card-header {
    background: var(--primary-gradient) !important;
    border: none;
    padding: 1.5rem 2rem;
    border-radius: 25px 25px 0 0;
}

.main-interface-card .card-header h4 {
    font-size: 1.4rem;
    font-weight: 700;
    margin: 0;
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Tab Styling */
.custom-tabs {
    border-bottom: none;
    background: rgba(255, 255, 255, 0.05);
    padding: 0.5rem 0.5rem 0 0.5rem;
}

.custom-tabs .nav-link {
    border: none;
    color: var(--text-secondary);
    font-weight: 600;
    padding: 1rem 2rem;
    border-radius: 15px 15px 0 0;
    transition: all 0.3s ease;
    position: relative;
    background: transparent;
    margin-right: 0.5rem;
    font-size: 1.1rem;
}

.custom-tabs .nav-link:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    transform: translateY(-2px);
}

.custom-tabs .nav-link.active {
    background: white;
    color: var(--text-primary);
    font-weight: 700;
    box-shadow: var(--shadow-sm);
    transform: translateY(-2px);
}

/* Chat Container Styling */
.chat-container {
    height: 500px;
    display: flex;
    flex-direction: column;
    background: white;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.message {
    display: flex;
    margin-bottom: 1.5rem;
    animation: fadeInUp 0.3s ease-out;
}

.message-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 1rem;
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
}

.bot-message .message-avatar {
    background: var(--primary-gradient);
    color: white;
}

.user-message .message-avatar {
    background: var(--secondary-gradient);
    color: white;
    order: 2;
    margin-left: 1rem;
    margin-right: 0;
}

.message-content {
    flex: 1;
    background: white;
    padding: 1.25rem 1.5rem;
    border-radius: 20px;
    box-shadow: var(--shadow-sm);
    position: relative;
    color: var(--text-primary);
    font-weight: 500;
}

.user-message .message-content {
    background: var(--primary-gradient);
    color: white;
    margin-left: 50px;
}

.bot-message .message-content {
    margin-right: 50px;
    border-left: 4px solid #667eea;
}

.message-content p {
    margin: 0;
    line-height: 1.6;
}

.message-content p:not(:last-child) {
    margin-bottom: 10px;
}

.quick-actions {
    margin-top: 15px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.quick-btn {
    font-size: 0.875rem;
    padding: 6px 12px;
    border-radius: 20px;
    transition: all 0.3s ease;
}

.quick-btn:hover {
    transform: translateY(-1px);
}

.chat-input-container {
    padding: 20px;
    background: var(--bs-secondary-bg);
}

.chat-input-container .form-control {
    border-radius: 25px;
    border: 2px solid var(--bs-border-color);
    padding: 12px 20px;
    font-size: 1rem;
}

.chat-input-container .btn {
    border-radius: 25px;
    padding: 12px 20px;
    border: 2px solid var(--bs-primary);
}

/* Typing indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 15px;
    background: var(--bs-secondary-bg);
    border-radius: 15px;
    margin-right: 50px;
}

.typing-dots {
    display: flex;
    gap: 4px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--bs-secondary);
    animation: typingDot 1.4s infinite;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingDot {
    0%, 60%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    30% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.result-card {
    border-radius: 15px;
    animation: slideIn 0.5s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Form Styling */
.form-control {
    border-radius: 15px;
    border: 2px solid rgba(255, 255, 255, 0.6);
    background: rgba(255, 255, 255, 0.98);
    transition: all 0.3s ease;
    color: #2c3e50 !important;
    font-weight: 500;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.form-control:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.25), 0 4px 12px rgba(0, 0, 0, 0.15);
    background: white;
    color: #2c3e50 !important;
    transform: translateY(-2px);
}

.form-control-lg {
    padding: 1rem 1.5rem;
    font-size: 1.1rem;
    font-weight: 600;
}

.form-control::placeholder {
    color: rgba(44, 62, 80, 0.6) !important;
    font-weight: 400;
}

.form-label {
    color: var(--text-primary);
    font-weight: 700;
    font-size: 1.1rem;
    margin-bottom: 0.75rem;
}

.form-text {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 0.5rem;
    font-weight: 400;
}

/* Tone Selection Styling */
.tone-option {
    background: rgba(255, 255, 255, 0.8);
    border-radius: 15px;
    padding: 1.25rem;
    margin-bottom: 1rem;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    display: block;
    width: 100%;
}

.tone-option::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--primary-gradient);
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 1;
}

.tone-option:hover {
    background: rgba(255, 255, 255, 0.95);
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.tone-option:hover::before {
    opacity: 0.05;
}

.tone-option input[type="radio"] {
    position: absolute;
    top: 15px;
    right: 15px;
    z-index: 3;
}

.tone-option input[type="radio"]:checked {
    background-color: #667eea;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

.tone-option:has(input[type="radio"]:checked) {
    border-color: #667eea;
    background: rgba(102, 126, 234, 0.1);
    box-shadow: var(--shadow-md);
}

.tone-option:has(input[type="radio"]:checked)::before {
    opacity: 0.1;
}

.tone-option:has(input[type="radio"]:checked) .tone-label {
    color: #667eea;
    font-weight: 700;
}

.tone-label {
    cursor: pointer;
    margin: 0;
    font-weight: 600;
    color: #2c3e50;
    position: relative;
    z-index: 2;
    display: block;
    width: 100%;
    padding: 0.5rem 0;
    padding-right: 2.5rem;
}

/* Button Styling */
.btn {
    border-radius: 15px;
    font-weight: 700;
    transition: all 0.3s ease;
    border: none;
    position: relative;
    overflow: hidden;
}

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

.btn:hover::before {
    left: 100%;
}

.btn-lg {
    padding: 1rem 2rem;
    font-size: 1.2rem;
    font-weight: 800;
}

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

.btn-primary {
    background: var(--primary-gradient);
    color: white;
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    background: var(--secondary-gradient);
    box-shadow: var(--shadow-lg);
    color: white;
}

.btn-outline-primary {
    border: 2px solid #667eea;
    color: #667eea;
    background: rgba(255, 255, 255, 0.9);
}

.btn-outline-primary:hover {
    background: #667eea;
    color: white;
    transform: translateY(-2px);
}

.btn-outline-secondary {
    border: 2px solid var(--text-secondary);
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.9);
}

.btn-outline-secondary:hover {
    background: var(--text-secondary);
    color: white;
    transform: translateY(-2px);
}

/* Result Styling */
.result-card {
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    border-radius: 25px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.result-card .card-header {
    background: var(--success-gradient) !important;
    border: none;
    padding: 1.5rem 2rem;
}

.result-card .card-header h4 {
    color: white;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.excuse-result {
    position: relative;
}

.excuse-text {
    background: rgba(255, 255, 255, 0.9);
    border-radius: 20px;
    padding: 2rem;
    font-size: 1.2rem;
    line-height: 1.8;
    border-left: 6px solid #4facfe;
    min-height: 100px;
    position: relative;
    color: var(--text-primary);
    font-weight: 500;
    box-shadow: var(--shadow-sm);
}

.excuse-text::before {
    content: '"';
    font-size: 4rem;
    color: #4facfe;
    position: absolute;
    top: -5px;
    left: 20px;
    font-family: serif;
    opacity: 0.7;
}

.excuse-text::after {
    content: '"';
    font-size: 4rem;
    color: #4facfe;
    position: absolute;
    bottom: -30px;
    right: 20px;
    font-family: serif;
    opacity: 0.7;
}

.excuse-actions {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    margin-top: 1.5rem;
}

/* Loading States */
.loading {
    opacity: 0.7;
    pointer-events: none;
}

.spinner-border-sm {
    width: 1rem;
    height: 1rem;
}

/* Error Alert Styling */
.alert {
    border-radius: 10px;
    border: none;
}

.alert-danger {
    background: rgba(var(--bs-danger-rgb), 0.1);
    color: var(--bs-danger);
    border-left: 4px solid var(--bs-danger);
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 0 15px;
    }
    
    .card-body {
        padding: 20px !important;
    }
    
    .excuse-text {
        padding: 20px;
        font-size: 1rem;
    }
    
    .excuse-actions {
        justify-content: center;
    }
    
    .excuse-actions .btn {
        flex: 1;
        min-width: 120px;
    }
}

/* Accessibility Improvements */
.form-check-input:focus {
    box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.25);
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

.btn:focus {
    box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.25);
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

.nav-link:focus {
    box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.25);
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* Loading State Improvements */
.loading {
    opacity: 0.7;
    pointer-events: none;
    filter: blur(1px);
}

.spinner-border-sm {
    width: 1.2rem;
    height: 1.2rem;
    border-width: 0.2em;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .btn {
        border: 2px solid currentColor;
    }
    
    .form-control {
        border: 2px solid currentColor;
    }
    
    .tone-option {
        border: 2px solid currentColor;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .btn:hover {
        transform: none;
    }
    
    .tone-option:hover {
        transform: none;
    }
    
    .main-interface-card:hover {
        transform: none;
    }
}

/* Focus visible improvements */
*:focus-visible {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* Typography improvements */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    letter-spacing: -0.02em;
}

p {
    font-weight: 400;
    letter-spacing: 0.01em;
}

.lead {
    font-weight: 500;
    letter-spacing: 0.01em;
}

/* Chat specific styling */
.chat-excuse-result {
    background: rgba(255, 255, 255, 0.9);
    border-radius: 15px;
    padding: 1.25rem;
    margin-top: 1rem;
    border-left: 4px solid #4facfe;
    box-shadow: var(--shadow-sm);
}

/* Additional input field styling for better visibility */
input.form-control, textarea.form-control {
    color: #2c3e50 !important;
    background: white !important;
    border: 2px solid rgba(102, 126, 234, 0.3) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
}

input.form-control:focus, textarea.form-control:focus {
    color: #2c3e50 !important;
    background: white !important;
    border: 2px solid #667eea !important;
    box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.25), 0 4px 12px rgba(0, 0, 0, 0.15) !important;
}

input.form-control:hover, textarea.form-control:hover {
    border-color: rgba(102, 126, 234, 0.5) !important;
}

.excuse-text-chat {
    background: rgba(76, 172, 254, 0.1);
    border-radius: 12px;
    padding: 1rem;
    margin: 0.75rem 0;
    font-style: italic;
    font-size: 1.1rem;
    line-height: 1.7;
    color: var(--text-primary);
    font-weight: 500;
    border: 1px solid rgba(76, 172, 254, 0.2);
}

.excuse-actions-chat {
    display: flex;
    gap: 10px;
    margin-top: 0.75rem;
}

.excuse-actions-chat .btn {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    border-radius: 10px;
    font-weight: 600;
}

/* Dark Mode Specific Adjustments */
[data-bs-theme="dark"] .excuse-text {
    background: var(--bs-dark);
    color: var(--bs-light);
}

[data-bs-theme="dark"] .tone-option {
    background: var(--bs-dark);
}

[data-bs-theme="dark"] .tone-option:hover {
    background: var(--bs-secondary);
}

[data-bs-theme="dark"] .chat-messages {
    background: var(--bs-dark);
}

[data-bs-theme="dark"] .message-content {
    background: var(--bs-secondary);
    color: var(--bs-light);
}

[data-bs-theme="dark"] .chat-excuse-result {
    background: var(--bs-secondary);
}

[data-bs-theme="dark"] .excuse-text-chat {
    background: var(--bs-dark);
    color: var(--bs-light);
}

/* Footer Styling */
footer {
    background: rgba(255, 255, 255, 0.1) !important;
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--border-color);
    color: rgba(255, 255, 255, 0.9);
    margin-top: 4rem;
}

footer h5 {
    color: white;
    font-weight: 700;
    margin-bottom: 1rem;
}

footer p {
    color: rgba(255, 255, 255, 0.8);
    line-height: 1.6;
}

/* Error Alert Styling */
.alert {
    border-radius: 15px;
    border: none;
    padding: 1.25rem 1.5rem;
    font-weight: 500;
    box-shadow: var(--shadow-sm);
}

.alert-danger {
    background: rgba(248, 215, 218, 0.9);
    color: #721c24;
    border-left: 4px solid #dc3545;
}

/* Animation for smooth transitions */
.card, .btn, .form-control, .alert {
    transition: all 0.3s ease;
}

/* Custom scrollbar for better UX */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

/* Responsive Design Improvements */
@media (max-width: 768px) {
    .hero-section h1 {
        font-size: 2.5rem;
    }
    
    .hero-section .lead {
        font-size: 1.1rem;
    }
    
    .main-interface-card {
        margin: 0 1rem;
    }
    
    .custom-tabs .nav-link {
        padding: 0.75rem 1rem;
        font-size: 1rem;
    }
    
    .tone-option {
        padding: 1rem;
    }
    
    .chat-container {
        height: 400px;
    }
    
    .chat-messages {
        padding: 1rem;
    }
    
    .message-avatar {
        width: 40px;
        height: 40px;
    }
    
    .excuse-text {
        padding: 1.5rem;
        font-size: 1.1rem;
    }
    
    .excuse-actions {
        flex-direction: column;
        gap: 10px;
    }
    
    .excuse-actions .btn {
        width: 100%;
    }
}
