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

/* Language Selector */
.language-selector {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 5px;
    z-index: 10;
}

.lang-btn {
    padding: 8px 12px;
    border: 2px solid #ff6600;
    background: transparent;
    color: #ff6600;
    border-radius: 5px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.3s ease;
    min-width: 40px;
}

.lang-btn:hover,
.lang-btn.active {
    background: #ff6600;
    color: white;
    transform: scale(1.05);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #fff5f0 0%, #ffffff 50%, #fff5f0 100%);
    min-height: 100vh;
    color: #333;
}

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

/* Pages */
.page {
    display: none;
}

.page.active {
    display: block;
    animation: fadeIn 0.3s ease-in;
}

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

/* Header */
.header {
    text-align: center;
    margin-bottom: 50px;
}

.logo {
    height: 80px;
    margin-bottom: 20px;
}

.logo-small {
    height: 40px;
}

h1 {
    font-size: 2.5rem;
    color: #333;
    margin-bottom: 10px;
}

.subtitle {
    font-size: 1.2rem;
    color: #666;
}

/* Mode Selection */
.mode-selection {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
    margin-top: 40px;
}

.mode-card {
    background: white;
    border-radius: 12px;
    padding: 30px;
    text-align: center;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    transition: transform 0.3s, box-shadow 0.3s;
    cursor: pointer;
    border: 2px solid transparent;
}

.mode-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 15px rgba(255, 121, 0, 0.2);
    border-color: #FF7900;
}

.mode-icon {
    font-size: 3rem;
    margin-bottom: 20px;
}

.mode-card h2 {
    color: #FF7900;
    margin-bottom: 15px;
    font-size: 1.5rem;
}

.mode-card p {
    color: #666;
    margin-bottom: 20px;
}

/* Buttons */
.btn {
    padding: 12px 30px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-primary {
    background: #FF7900;
    color: white;
}

.btn-primary:hover {
    background: #e66d00;
    transform: scale(1.05);
}

.btn-secondary {
    background: white;
    color: #FF7900;
    border: 2px solid #FF7900;
}

.btn-secondary:hover {
    background: #fff5f0;
}

/* Page header layout */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    position: relative;
}

.page-header-center {
    display: flex;
    align-items: center;
    gap: 15px;
}

.page-header .language-selector {
    position: static;
    margin: 0;
}

/* Contract Actions - Download Buttons */
.contract-actions {
    display: flex;
    gap: 15px;
    align-items: center;
}

.btn-download {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 24px;
    border: none;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: none;
    letter-spacing: 0.3px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
}

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

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

.btn-download-pdf {
    background: linear-gradient(135deg, #FF7900 0%, #e66d00 100%);
    color: white;
}

.btn-download-pdf:hover {
    background: linear-gradient(135deg, #e66d00 0%, #d45f00 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 121, 0, 0.4);
}

.btn-download-docx {
    background: linear-gradient(135deg, #2B5797 0%, #1e3d6f 100%);
    color: white;
}

.btn-download-docx:hover {
    background: linear-gradient(135deg, #1e3d6f 0%, #152a4f 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(43, 87, 151, 0.4);
}

.btn-download .download-icon {
    flex-shrink: 0;
    transition: transform 0.3s ease;
}

.btn-download:hover .download-icon {
    transform: scale(1.1) translateY(2px);
}

.btn-download span {
    white-space: nowrap;
}

@media (max-width: 768px) {
    .contract-actions {
        flex-direction: column;
        width: 100%;
        gap: 10px;
    }
    
    .btn-download {
        width: 100%;
        justify-content: center;
    }
}

/* Progress Bar */
.progress-bar {
    width: 100%;
    height: 8px;
    background: #e0e0e0;
    border-radius: 10px;
    overflow: hidden;
    margin: 20px 0;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #FF7900 0%, #ff9933 100%);
    transition: width 0.3s ease;
}

.progress-text {
    text-align: center;
    color: #666;
    font-weight: 600;
    margin-bottom: 30px;
}

/* Form Container */
.form-container {
    background: white;
    border-radius: 12px;
    padding: 40px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    min-height: 400px;
}

.form-step {
    display: none;
}

.form-step.active {
    display: block;
    animation: slideIn 0.3s ease;
}

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

.form-step h2 {
    color: #FF7900;
    margin-bottom: 20px;
    font-size: 1.8rem;
}

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

.form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
}

.form-input,
.form-textarea,
.form-select {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s;
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
    outline: none;
    border-color: #FF7900;
}

.form-textarea {
    min-height: 120px;
    resize: vertical;
}

/* AI Augmentation Buttons */
.textarea-container, .input-container {
    position: relative;
}

.btn-augment {
    position: absolute;
    right: 8px;
    top: 8px;
    background: #FF7900;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.3s;
    z-index: 10;
    white-space: nowrap;
}

.btn-augment:hover {
    background: #e66d00;
    transform: scale(1.05);
}

.btn-augment:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

.textarea-container .form-textarea {
    padding-right: 140px;
}

.input-container .form-input {
    padding-right: 140px;
}

/* Article Selection */
.articles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 15px;
    margin-top: 20px;
}

.article-checkbox {
    display: flex;
    align-items: center;
    padding: 15px;
    background: #f9f9f9;
    border-radius: 8px;
    border: 2px solid #e0e0e0;
    transition: all 0.3s;
    cursor: pointer;
}

.article-checkbox:hover {
    background: #fff5f0;
    border-color: #FF7900;
}

.article-checkbox input[type="checkbox"] {
    width: 20px;
    height: 20px;
    margin-right: 12px;
    cursor: pointer;
    accent-color: #FF7900;
}

.article-checkbox.required {
    background: #fff5f0;
    border-color: #FF7900;
}

.article-checkbox.required input[type="checkbox"] {
    pointer-events: none;
}

.required-badge {
    background: #FF7900;
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    margin-left: auto;
}

/* Form Navigation */
.form-navigation {
    display: flex;
    justify-content: space-between;
    margin-top: 30px;
    gap: 15px;
}

/* Chat Container */
.chat-container {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    height: 600px;
    display: flex;
    flex-direction: column;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 30px;
}

.welcome-message {
    text-align: center;
    padding: 40px 20px;
}

.bot-avatar {
    font-size: 4rem;
    margin-bottom: 20px;
}

.welcome-message h3 {
    color: #FF7900;
    margin-bottom: 15px;
}

.suggestions {
    margin-top: 30px;
    text-align: left;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
    background: #f9f9f9;
    padding: 20px;
    border-radius: 8px;
}

.suggestions ul {
    list-style: none;
    margin-top: 10px;
}

.suggestions li {
    padding: 8px 0;
    color: #666;
}

.message {
    margin-bottom: 20px;
    display: flex;
    gap: 10px;
    animation: messageSlide 0.3s ease;
}

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

.message.user {
    justify-content: flex-end;
}

.message-content {
    max-width: 70%;
    padding: 15px 20px;
    border-radius: 12px;
    line-height: 1.6;
}

.message.user .message-content {
    background: #FF7900;
    color: white;
    border-bottom-right-radius: 4px;
}

.message.bot .message-content {
    background: #f0f0f0;
    color: #333;
    border-bottom-left-radius: 4px;
}

.typing-indicator {
    display: inline-block;
    padding: 15px 20px;
    background: #f0f0f0;
    border-radius: 12px;
    border-bottom-left-radius: 4px;
}

.typing-indicator span {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #666;
    border-radius: 50%;
    margin: 0 2px;
    animation: typing 1.4s infinite;
}

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

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

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-10px); }
}

.chat-input-container {
    display: flex;
    gap: 10px;
    padding: 20px;
    border-top: 2px solid #e0e0e0;
}

.chat-input {
    flex: 1;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1rem;
}

.chat-input:focus {
    outline: none;
    border-color: #FF7900;
}

/* Chat Progress */
.chat-progress {
    background: white;
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.progress-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    font-weight: 600;
    color: #FF7900;
}

/* Contract Preview */
.contract-preview {
    background: white;
    border-radius: 12px;
    padding: 40px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    min-height: 600px;
}

.contract-preview h1 {

    text-align: center;
    border-bottom: 3px solid #FF7900;
    padding-bottom: 15px;
    margin-bottom: 30px;
}

.contract-preview h2 {

    margin-top: 30px;
    margin-bottom: 15px;
}

.contract-preview .article {
    margin-bottom: 30px;
    padding: 20px;
    border-left: 4px solid #FF7900;
    background: #fff5f0;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease-out;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    padding: 40px;
    border-radius: 12px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.modal-content h2 {
    color: #FF7900;
    margin-bottom: 20px;
}

.validation-modal {
    text-align: center;
    padding: 40px 35px 35px;
    position: relative;
    background: white;
    animation: modalSlideIn 0.2s ease-out;
}

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

.validation-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
}

.validation-icon svg {
    width: 48px;
    height: 48px;
    display: block;
}

.validation-modal h2 {
    color: #333;
    margin-bottom: 15px;
    font-size: 1.4rem;
    font-weight: 600;
}

.validation-modal p {
    margin: 15px 0 30px 0;
    color: #666;
    line-height: 1.6;
    font-size: 1rem;
    padding: 0 10px;
}

.validation-modal .btn {
    width: 100%;
    padding: 14px 30px;
    font-size: 1rem;
    font-weight: 600;
    transition: background-color 0.2s ease;
}

.validation-modal .btn:hover {
    background: #e66d00;
}

.modal-actions {
    display: flex;
    gap: 15px;
    margin-top: 25px;
}

.modal-actions .btn {
    flex: 1;
}

.help-text {
    margin-top: 15px;
    font-size: 0.9rem;
    color: #666;
    text-align: center;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: normal;
}

.checkbox-label input[type="checkbox"] {
    margin: 0;
}

/* AI Refinement Progress Modal */
.refinement-progress {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    border: 2px solid #ff6600;
    border-radius: 20px;
    padding: 40px;
    max-width: 600px;
    width: 90%;
    z-index: 1000;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    text-align: center;
}

.refinement-header {
    margin-bottom: 30px;
}

.refinement-header h2 {
    color: #ff6600;
    margin: 20px 0 10px 0;
    font-size: 1.8em;
    font-weight: 600;
}

.refinement-subtitle {
    color: #666;
    font-size: 1em;
    line-height: 1.4;
    margin: 0;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #ff6600;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.progress-container {
    margin: 30px 20px;
}

.progress-bar {
    background: #e0e0e0;
    border-radius: 25px;
    height: 12px;
    overflow: hidden;
    margin-bottom: 15px;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.progress-fill {
    background: linear-gradient(90deg, #ff6600 0%, #ff8533 100%);
    height: 100%;
    transition: width 0.8s ease-in-out;
    border-radius: 25px;
    position: relative;
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.3) 50%,
        transparent 100%
    );
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.progress-text {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    color: #333;
}

#progressPercent {
    font-size: 1.2em;
    color: #ff6600;
}

.progress-label {
    font-size: 0.9em;
    color: #666;
}

.refinement-steps {
    display: flex;
    justify-content: space-between;
    margin: 30px 20px;
    position: relative;
}

.refinement-steps::before {
    content: '';
    position: absolute;
    top: 15px;
    left: 20px;
    right: 20px;
    height: 2px;
    background: #e0e0e0;
    z-index: 1;
}

.step {
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 2;
    transition: all 0.3s ease;
    font-size: 0.8em;
}

.step.active {
    background: #ff6600;
    border-color: #ff6600;
    color: white;
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(255, 102, 0, 0.3);
}

.step-icon {
    font-size: 1.2em;
    line-height: 1;
}

.step-text {
    position: absolute;
    top: 50px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.75em;
    color: #666;
    white-space: nowrap;
    opacity: 0.7;
}

.step.active .step-text {
    color: #ff6600;
    font-weight: 600;
    opacity: 1;
}

.refinement-info {
    margin-top: 30px;
    padding: 0 20px;
    color: #666;
    font-size: 0.9em;
}

.processing-dots {
    display: flex;
    justify-content: center;
    margin-top: 15px;
}

.processing-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ff6600;
    margin: 0 4px;
    animation: bounce 1.4s ease-in-out infinite both;
}

.processing-dots span:nth-child(1) { animation-delay: -0.32s; }
.processing-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
    0%, 80%, 100% {
        transform: scale(0);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

.refinement-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(2px);
    z-index: 999;
}

/* Markdown Support Styling */
.markdown-help {
    display: block;
    color: #666;
    font-size: 12px;
    margin-top: 5px;
    font-style: italic;
}

.textarea-container {
    position: relative;
}

.markdown-preview {
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 5px;
    padding: 15px;
    margin-top: 10px;
    max-height: 200px;
    overflow-y: auto;
}

.markdown-preview h1, .markdown-preview h2, .markdown-preview h3 {
    margin-top: 0;
    margin-bottom: 10px;
}

.markdown-preview p {
    margin-bottom: 10px;
}

.markdown-preview ul, .markdown-preview ol {
    padding-left: 20px;
    margin-bottom: 10px;
}

.markdown-preview blockquote {
    border-left: 4px solid #ff6600;
    padding-left: 15px;
    margin: 15px 0;
    color: #666;
    font-style: italic;
}

.markdown-preview code {
    background: #f1f1f1;
    padding: 2px 4px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
}

.markdown-preview pre {
    background: #f1f1f1;
    padding: 10px;
    border-radius: 5px;
    overflow-x: auto;
}

.markdown-preview pre code {
    background: none;
    padding: 0;
}

/* Chat Message Markdown Support */
.message-content h1, .message-content h2, .message-content h3 {
    margin-top: 10px;
    margin-bottom: 8px;
    color: #333;
}

.message-content p {
    margin-bottom: 8px;
}

.message-content ul, .message-content ol {
    padding-left: 20px;
    margin-bottom: 10px;
}

.message-content li {
    margin-bottom: 3px;
}

.message-content blockquote {
    border-left: 3px solid #ff6600;
    padding-left: 12px;
    margin: 10px 0;
    color: #555;
    font-style: italic;
}

.message-content strong {
    font-weight: 600;
}

.message-content em {
    font-style: italic;
}

.message-content code {
    background: #f0f0f0;
    padding: 2px 4px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
}

/* AI Refined Content Styling */
.ai-refined-indicator {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    margin-left: 10px;
}

.ai-refined {
    padding-left: 15px;
    margin: 15px 0;
}

/* Responsive */
@media (max-width: 768px) {
    h1 {
        font-size: 2rem;
    }
    
    .mode-selection {
        grid-template-columns: 1fr;
    }
    
    .form-container {
        padding: 20px;
    }
    
    .message-content {
        max-width: 85%;
    }
    
    .form-navigation {
        flex-direction: column;
    }
    
    .form-navigation .btn {
        width: 100%;
    }
}
