/* AI-Powered Document Editor - Professional Styling */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

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

/* Header */
.header {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    padding: 2rem 0;
    text-align: center;
    color: white;
}

.header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.header p {
    font-size: 1.1rem;
    opacity: 0.9;
}

.lang-switch {
    position: absolute;
    top: 1rem;
    right: 1rem;
}

.lang-btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    margin-left: 0.5rem;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    text-decoration: none;
    border-radius: 6px;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

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

.lang-btn.active {
    background: rgba(255, 255, 255, 0.4);
    font-weight: bold;
}

/* Main Content */
.main {
    padding: 3rem 0;
    flex: 1;
}

/* Main Layout */
.main-layout {
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    gap: 2rem;
    align-items: start;
}

@media (max-width: 968px) {
    .main-layout {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
}

.upload-card {
    background: white;
    border-radius: 20px;
    padding: 2.5rem;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
}

.upload-card h2 {
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
    color: #2d3748;
}

.upload-card p {
    color: #718096;
    margin-bottom: 2rem;
}

.rules-card {
    background: white;
    border-radius: 20px;
    padding: 2.5rem;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
}

.rules-card h2 {
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
    color: #2d3748;
}

.rules-card p {
    color: #718096;
    margin-bottom: 2rem;
}

/* File Input Styling */
.file-input-group {
    margin-bottom: 1.5rem;
}

/* Rules Input Styling */
.rules-input-group {
    margin-bottom: 2rem;
}

.rules-label {
    display: block;
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 0.8rem;
    font-size: 1.1rem;
}

.rules-label i {
    color: #667eea;
    margin-right: 0.5rem;
}

.rules-container {
    position: relative;
    margin-bottom: 1rem;
}

.textarea-wrapper {
    position: relative;
}

.textarea-background {
    position: absolute;
    top: 12px;
    left: 12px;
    right: 12px;
    bottom: 12px;
    font-family: inherit;
    font-size: 0.95rem;
    line-height: 1.4;
    color: #a0aec0;
    pointer-events: none;
    white-space: pre-line;
    z-index: 1;
}

.rules-textarea:focus + .textarea-background,
.rules-textarea:not(:placeholder-shown) + .textarea-background {
    display: none;
}

.rules-textarea {
    width: 100%;
    min-height: 250px;
    padding: 1rem;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.9rem;
    line-height: 1.5;
    resize: vertical;
    transition: all 0.3s ease;
    background: #f7fafc;
}

.rules-textarea:focus {
    outline: none;
    border-color: #667eea;
    background: white;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.rules-textarea.drag-over {
    border-color: #38a169;
    background: #f0fff4;
}

.rules-drop-zone {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(56, 161, 105, 0.15);
    border: 3px dashed #38a169;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(3px);
    z-index: 10;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    pointer-events: none;
}

.rules-drop-zone.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.rules-drop-zone i {
    font-size: 2.5rem;
    color: #38a169;
    margin-bottom: 0.5rem;
}

.rules-drop-zone p {
    color: #2f855a;
    font-weight: 600;
    margin: 0;
}

.agents-preview {
    background: #edf2f7;
    border-radius: 12px;
    padding: 1.5rem;
}

.agents-preview h4 {
    margin-bottom: 1rem;
    color: #2d3748;
    font-size: 1rem;
}

.agents-preview h4 i {
    color: #667eea;
    margin-right: 0.5rem;
}

.agents-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.8rem;
}

.agent-tag {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
    color: #4a5568;
    font-weight: 500;
    display: flex;
    align-items: center;
}

.agent-tag.detected {
    background: #f0fff4;
    border-color: #38a169;
    color: #2f855a;
}

.agent-tag.error {
    background: #fff5f5;
    border-color: #fc8181;
    color: #c53030;
}

.agents-preview small {
    color: #718096;
    font-size: 0.8rem;
}

/* Rules Actions */
.rules-actions {
    text-align: center;
    margin-bottom: 1.5rem;
}

.split-agents-btn {
    background: linear-gradient(135deg, #ed8936 0%, #dd6b20 100%);
    color: white;
    border: none;
    border-radius: 12px;
    padding: 0.8rem 1.5rem;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(237, 137, 54, 0.3);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.split-agents-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(237, 137, 54, 0.5);
}

.split-agents-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: 0 4px 15px rgba(237, 137, 54, 0.2);
}

.split-agents-btn.loading {
    background: linear-gradient(135deg, #a0aec0 0%, #718096 100%);
}

.split-agents-btn.highlight-attention {
    animation: pulseHighlight 0.8s ease-in-out 3;
    box-shadow: 0 0 20px rgba(237, 137, 54, 0.8);
}

@keyframes pulseHighlight {
    0% {
        transform: scale(1);
        box-shadow: 0 4px 15px rgba(237, 137, 54, 0.3);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 0 25px rgba(237, 137, 54, 0.9);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 4px 15px rgba(237, 137, 54, 0.3);
    }
}

.rules-actions small {
    display: block;
    margin-top: 0.5rem;
    color: #718096;
    font-size: 0.8rem;
}

.file-label {
    display: block;
    padding: 1.5rem;
    border: 2px dashed #cbd5e0;
    border-radius: 12px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #f7fafc;
}

.file-label:hover {
    border-color: #667eea;
    background: #edf2f7;
}

.file-label.optional {
    border-style: solid;
    border-color: #e2e8f0;
    opacity: 0.8;
}

.file-label input[type="file"] {
    display: none;
}

.file-label i {
    font-size: 2rem;
    color: #667eea;
    margin-bottom: 0.5rem;
    display: block;
}

.file-label span {
    font-weight: 600;
    color: #2d3748;
}

.file-name {
    margin-top: 0.5rem;
    font-size: 0.9rem;
    color: #38a169;
    font-weight: 500;
}

.file-input-group small {
    display: block;
    margin-top: 0.5rem;
    color: #718096;
    font-size: 0.85rem;
}

/* Options */
.options {
    margin: 2rem 0;
    padding: 1.5rem;
    background: #f7fafc;
    border-radius: 12px;
}

.options h3 {
    margin-bottom: 1rem;
    color: #2d3748;
}

.checkbox-label {
    display: flex;
    align-items: center;
    margin-bottom: 0.8rem;
    cursor: pointer;
    font-size: 0.95rem;
}

.checkbox-label input[type="checkbox"] {
    margin-right: 0.8rem;
    transform: scale(1.2);
}

.option-info {
    display: flex;
    align-items: center;
    margin-bottom: 0.8rem;
    font-size: 0.95rem;
    color: #2d3748;
}

.option-info i {
    margin-right: 0.8rem;
    font-size: 1.1rem;
}

/* Process Button */
.process-btn {
    width: 100%;
    padding: 1rem 2rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.process-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.6);
}

.process-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.process-btn.disabled-no-agents {
    background: linear-gradient(135deg, #a0aec0 0%, #718096 100%);
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
    box-shadow: 0 4px 15px rgba(160, 174, 192, 0.3);
}

.process-btn.disabled-no-agents:hover {
    transform: none;
    box-shadow: 0 4px 15px rgba(160, 174, 192, 0.3);
}

.process-btn i {
    margin-right: 0.5rem;
}

/* Progress Section */
.progress-section {
    margin-top: 2rem;
    text-align: center;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 1rem;
}

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

#progressText {
    color: #4a5568;
    font-weight: 500;
}

/* Info Section */
.info-section {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 2.5rem;
    backdrop-filter: blur(10px);
}

.info-section h3 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    color: #2d3748;
}

.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.feature {
    text-align: center;
    padding: 1.5rem;
    background: #f7fafc;
    border-radius: 12px;
    transition: transform 0.3s ease;
}

.feature:hover {
    transform: translateY(-5px);
}

.feature i {
    font-size: 2rem;
    color: #667eea;
    margin-bottom: 0.8rem;
}

.feature h4 {
    margin-bottom: 0.5rem;
    color: #2d3748;
}

.feature p {
    font-size: 0.9rem;
    color: #718096;
}

/* Stats */
.stats {
    background: #edf2f7;
    border-radius: 12px;
    padding: 1.5rem;
}

.stats h4 {
    margin-bottom: 1rem;
    color: #2d3748;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid #e2e8f0;
}

.stat-row:last-child {
    border-bottom: none;
}

.stat-row span:first-child {
    color: #4a5568;
}

.stat-row span:last-child {
    font-weight: 600;
    color: #2d3748;
}

/* Results Page */
.results-section {
    max-width: 800px;
    margin: 0 auto;
}

.success-card, .error-card {
    background: white;
    border-radius: 20px;
    padding: 3rem;
    margin-bottom: 2rem;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    text-align: center;
}

.success-card h2 {
    color: #38a169;
    font-size: 2rem;
    margin-bottom: 1rem;
}

.error-card h2 {
    color: #e53e3e;
    font-size: 2rem;
    margin-bottom: 1rem;
}

.download-section {
    margin: 2rem 0;
}

.download-section h3 {
    margin-bottom: 1rem;
    color: #2d3748;
}

.download-options {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.download-btn {
    display: flex;
    align-items: center;
    padding: 1.5rem;
    background: white;
    color: #2d3748;
    text-decoration: none;
    border-radius: 12px;
    font-weight: 500;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    border: 2px solid transparent;
}

.download-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.download-primary {
    border-color: #38a169;
    background: linear-gradient(135deg, #38a169 0%, #2f855a 100%);
    color: white;
}

.download-primary:hover {
    box-shadow: 0 8px 25px rgba(56, 161, 105, 0.4);
}

.download-secondary {
    border-color: #4299e1;
}

.download-secondary:hover {
    border-color: #3182ce;
    background: #f7fafc;
}

.download-btn i {
    margin-right: 1rem;
    font-size: 1.5rem;
    min-width: 24px;
}

.download-btn div {
    flex: 1;
}

.download-btn strong {
    display: block;
    font-size: 1.1rem;
    margin-bottom: 0.25rem;
}

.download-btn small {
    display: block;
    opacity: 0.8;
    font-size: 0.9rem;
}

/* Results Grid */
.results-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin: 2rem 0;
    text-align: left;
}

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

.result-card {
    background: #f7fafc;
    border-radius: 12px;
    padding: 2rem;
}

.result-card h3 {
    margin-bottom: 1.5rem;
    color: #2d3748;
}

.stat-list {
    space-y: 1rem;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 0;
    border-bottom: 1px solid #e2e8f0;
}

.stat-item:last-child {
    border-bottom: none;
}

.stat-label {
    color: #4a5568;
    font-weight: 500;
}

.stat-value {
    color: #2d3748;
    font-weight: 600;
}

/* QA Results */
.qa-success, .qa-warning {
    display: flex;
    align-items: center;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.qa-success {
    background: #f0fff4;
    border-left: 4px solid #38a169;
}

.qa-warning {
    background: #fffbf0;
    border-left: 4px solid #ed8936;
}

.qa-success i {
    color: #38a169;
    font-size: 1.5rem;
    margin-right: 1rem;
}

.qa-warning i {
    color: #ed8936;
    font-size: 1.5rem;
    margin-right: 1rem;
}

.qa-success strong, .qa-warning strong {
    color: #2d3748;
    display: block;
}

.qa-success p, .qa-warning p {
    font-size: 0.9rem;
    color: #718096;
    margin: 0;
}

/* Agent Grid */
.agent-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.agent-item {
    display: flex;
    align-items: center;
    padding: 0.8rem;
    background: #f7fafc;
    border-radius: 8px;
}

.agent-item i {
    color: #667eea;
    margin-right: 0.8rem;
    font-size: 1.2rem;
}

/* File Info */
.file-info {
    background: #edf2f7;
    border-radius: 12px;
    padding: 1.5rem;
    margin: 2rem 0;
    text-align: left;
}

.file-info h3 {
    margin-bottom: 1rem;
    color: #2d3748;
}

.file-info p {
    margin-bottom: 0.5rem;
    color: #4a5568;
}

/* Actions */
.actions {
    text-align: center;
    margin-top: 2rem;
}

.back-btn {
    display: inline-block;
    padding: 1rem 2rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    text-decoration: none;
    border-radius: 12px;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.back-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.6);
}

.back-btn i {
    margin-right: 0.5rem;
}

/* Footer */
.footer {
    background: rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    color: white;
    text-align: center;
    padding: 2rem 0;
    margin-top: 4rem;
}

.footer p {
    opacity: 0.9;
}