:root {
    --primary-color: #4a6fa5;
    --secondary-color: #166088;
    --accent-color: #4fc3f7;
    --background-color: #f8f9fa;
    --card-color: #ffffff;
    --text-color: #333333;
    --light-text: #666666;
    --border-color: #e0e0e0;
    --success-color: #4caf50;
    --warning-color: #ff9800;
    --error-color: #f44336;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --border-radius: 50px;
    --content-radius: 12px;
    --primary-dark: #3a5a80; /* Added for button hover states */
}

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

body {
    font-family: 'Manrope', sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
}

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

header {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px 0;
}

header h1 {
    font-size: 2.5rem;
    color: var(--secondary-color);
    margin-bottom: 10px;
}

header h1 i {
    margin-right: 10px;
    color: var(--accent-color);
}

.subtitle {
    font-size: 1.1rem;
    color: var(--light-text);
    font-weight: 300;
}

.subtitle2 {
    font-size: 1.1rem;
    color: var(--secondary-color);
    font-weight: 300;
}

.input-section {
    margin-bottom: 30px;
    height: auto;
}

.text-input {
    position: relative;
    height: auto;
}

.text-input textarea {
    width: 100%;
    min-height: 200px;
    padding: 15px;
    border: 2px solid var(--border-color);
    border-radius: var(--content-radius);
    font-size: 1rem;
    field-sizing: content;
    resize: none;
    transition: border 0.3s ease;
    box-shadow: var(--shadow);
    font-family: "Jetbrains Mono", monospace;
}

.text-input textarea:focus {
    outline: none;
    border-color: var(--accent-color);
}

.controls {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.secondary-controls {
    display: flex;
    gap: 10px;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: var(--border-radius);
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn i {
    font-size: 0.9rem;
}

.analyze-btn {
    background-color: var(--primary-color);
    color: white;
    flex: 1;
}

.analyze-btn:hover {
    background-color: var(--secondary-color);
}

.sample-btn {
    background-color: var(--background-color);
    color: var(--text-color);
    border: 1px solid var(--border-color);
}

.sample-btn:hover {
    background-color: #e9ecef;
}

.clear-btn {
    background-color: var(--error-color);
    color: white;
}

.clear-btn:hover {
    background-color: #d32f2f;
}

.processing-section {
    background-color: var(--card-color);
    padding: 20px;
    border-radius: var(--content-radius);
    margin-bottom: 30px;
    box-shadow: var(--shadow);
}

.processing-section.hidden {
    display: none;
}

.progress-container {
    width: 100%;
    margin-bottom: 15px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.progress-bar {
    height: 20px;
    background-color: var(--accent-color);
    width: 0%;
    border-radius: var(--content-radius);
    transition: width 0.5s cubic-bezier(0.075, 0.82, 0.165, 1);
}

.progress-text {
    font-size: 0.9rem;
    color: var(--light-text);
    text-align: center;
    margin-bottom: 10px;
}

.processing-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    justify-content: space-between;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.stat-label {
    font-weight: 500;
    color: var(--light-text);
}

.stat-value {
    font-weight: 700;
    color: var(--text-color);
}

.tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 20px;
    overflow-x: auto;
}

.tab-btn {
    padding: 12px 20px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    color: var(--light-text);
    border-bottom: 3px solid transparent;
    transition: all 0.3s ease;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tab-btn i {
    font-size: 0.9rem;
}

.tab-btn:hover {
    color: var(--primary-color);
}

.tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--accent-color);
    font-weight: 500;
}

.tab-content {
    display: none;
    background-color: var(--card-color);
    padding: 20px;
    border-radius: var(--content-radius);
    box-shadow: var(--shadow);
    margin-bottom: 30px;
}

.tab-content.active {
    display: block;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.results-header h3 {
    font-size: 1.3rem;
    color: var(--secondary-color);
    display: flex;
    align-items: center;
    gap: 10px;
}

.results-header h3 i {
    color: var(--accent-color);
}

.filters select {
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: white;
    cursor: pointer;
    outline: none;
}

.filter select:focus {
    outline: none;
    border-color: var(--border-color);
}

.results-container {
    max-height: 500px;
    overflow-y: auto;
    padding-right: 10px;
}

.entity-card, .relation-card, .event-card, .temporal-card, .pos-card {
    background-color: var(--card-color);
    border-left: 4px solid var(--accent-color);
    padding: 15px;
    margin-bottom: 15px;
    border-radius: 0 var(--content-radius) var(--content-radius) 0;
    box-shadow: var(--shadow);
    transition: transform 0.2s ease;
}

.entity-card:hover, .relation-card:hover, .event-card:hover, .temporal-card:hover, .pos-card:hover {
    transform: translateY(-2px);
}

.entity-header, .relation-header, .event-header, .temporal-header, .pos-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.entity-type, .relation-type, .event-type, .temporal-type, .pos-type {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.entity-type.person {
    background-color: #e3f2fd;
    color: #1565c0;
}

.entity-type.organization {
    background-color: #e8f5e9;
    color: #2e7d32;
}

.entity-type.place {
    background-color: #fff3e0;
    color: #e65100;
}

.entity-type.date {
    background-color: #f3e5f5;
    color: #7b1fa2;
}

.entity-type.value {
    background-color: #e0f7fa;
    color: #00838f;
}

.relation-type {
    background-color: #fce4ec;
    color: #c2185b;
}

.event-type {
    background-color: #e8eaf6;
    color: #303f9f;
}

.temporal-type {
    background-color: #fff8e1;
    color: #ff8f00;
}

.pos-type {
    background-color: #e0f2f1;
    color: #00796b;
}

.entity-text, .relation-text, .event-text, .temporal-text, .pos-text {
    font-weight: 500;
    margin-bottom: 5px;
    color: var(--text-color);
}

.entity-context, .relation-context, .event-context, .temporal-context, .pos-context {
    font-size: 0.9rem;
    color: var(--light-text);
    margin-bottom: 5px;
}

.entity-meta, .relation-meta, .event-meta, .temporal-meta, .pos-meta {
    display: flex;
    gap: 15px;
    font-size: 0.8rem;
    color: var(--light-text);
}

.pos-tag {
    display: inline-block;
    padding: 2px 6px;
    background-color: #e0f7fa;
    border-radius: 4px;
    font-size: 0.8rem;
    margin-right: 5px;
    color: #00838f;
}

footer {
    text-align: center;
    padding: 20px 0;
    color: var(--light-text);
    font-size: 0.9rem;
    margin-top: 30px;
    border-top: 1px solid var(--border-color);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .controls {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
    }
    
    .processing-stats {
        flex-direction: column;
        gap: 10px;
    }
    
    .tabs {
        flex-wrap: wrap;
    }
    
    .tab-btn {
        padding: 10px 15px;
        font-size: 0.9rem;
    }
}

/* Animation for processing */
@keyframes pulse {
    0% { opacity: 0.6; }
    50% { opacity: 1; }
    100% { opacity: 0.6; }
}

.processing {
    animation: pulse 1.5s infinite;
}

.file-upload {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
}

.upload-btn {
    background-color: var(--primary-color);
    color: white;
    padding: 12px 20px;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background-color 0.3s;
}

.upload-btn:hover {
    background-color: var(--primary-dark);
}

.file-name {
    font-size: 14px;
    color: var(--text-color);
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.graph-container {
    width: 100%;
    height: 600px;
    background-color: var(--card-color);
    border-radius: var(--border-radius);
    overflow: hidden;
    position: relative;
}

#graphVisualization {
    width: 100%;
    height: 100%;
}

.graph-controls {
    display: flex;
    gap: 8px;
}

.graph-btn {
    padding: 6px 12px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.graph-btn:hover {
    background-color: var(--secondary-color);
}

/* D3.js graph styles */
.node {
    cursor: pointer;
}

.node circle {
    stroke: #fff;
    stroke-width: 2px;
}

.node text {
    font-size: 12px;
    font-family: 'Roboto', sans-serif;
}

.link {
    stroke: #999;
    stroke-opacity: 0.6;
    stroke-width: 1px;
}

.node-person circle {
    fill: #e3f2fd;
    stroke: #1565c0;
}

.node-organization circle {
    fill: #e8f5e9;
    stroke: #2e7d32;
}

.node-place circle {
    fill: #fff3e0;
    stroke: #e65100;
}

.node-date circle {
    fill: #f3e5f5;
    stroke: #7b1fa2;
}

.node-value circle {
    fill: #e0f7fa;
    stroke: #00838f;
}

.link-employment {
    stroke: #c2185b;
}

.link-location {
    stroke: #303f9f;
}

.link-association {
    stroke: #ff8f00;
}

/* Tooltip styles */
.tooltip {
    position: absolute;
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 12px;
    pointer-events: none;
    z-index: 1000;
}

.timeline-container {
    width: 100%;
    height: 400px;
    background-color: var(--card-color);
    border-radius: var(--border-radius);
    overflow: hidden;
    position: relative;
}

#timelineVisualization {
    width: 100%;
    height: 100%;
}

.timeline-controls {
    display: flex;
    gap: 8px;
}

.timeline-btn {
    padding: 6px 12px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.timeline-btn:hover {
    background-color: var(--secondary-color);
}

/* Timeline specific styles */
.timeline-event {
    cursor: pointer;
    transition: all 0.3s ease;
}

.timeline-event:hover {
    filter: brightness(1.1);
}

.timeline-event rect {
    rx: 4;
    ry: 4;
}

.timeline-event text {
    font-size: 12px;
    font-family: 'Roboto', sans-serif;
    pointer-events: none;
}

.timeline-axis path,
.timeline-axis line {
    stroke: var(--border-color);
}

.timeline-axis text {
    font-size: 12px;
    fill: var(--light-text);
}

.timeline-grid line {
    stroke: var(--border-color);
    stroke-opacity: 0.3;
}

.timeline-event-statement rect {
    fill: #e8eaf6;
    stroke: #303f9f;
}

.timeline-event-creation rect {
    fill: #e8f5e9;
    stroke: #2e7d32;
}

.timeline-event-change rect {
    fill: #fff3e0;
    stroke: #e65100;
}

.timeline-event-action rect {
    fill: #f3e5f5;
    stroke: #7b1fa2;
}

.timeline-tooltip {
    position: absolute;
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 12px;
    pointer-events: none;
    z-index: 1000;
    max-width: 300px;
}

.download-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: var(--bg-color);
    border-bottom: 1px solid var(--border-color);
}

.download-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: var(--border-radius);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background-color 0.3s;
}

.download-btn:hover {
    background: var(--primary-dark);
}

#reportFormat {
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: white;
    cursor: pointer;
}

#reportFormat:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Enhanced Loading Overlay */
.loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.95);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
    transition: opacity 0.3s ease;
    opacity: 0;
    pointer-events: none;
}

.loading.active {
    opacity: 1;
    pointer-events: all;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(74, 111, 165, 0.2);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

.loading-text {
    color: var(--text-color);
    font-size: 1.1rem;
    font-weight: 500;
    max-width: 80%;
    text-align: center;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Disabled State for Buttons */
.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background-color: #cccccc !important;
    color: #666666 !important;
}

/* Enhanced Error States */
.status-error {
    color: var(--error-color) !important;
    font-weight: 500;
}

/* File Upload Validation */
.file-error {
    color: var(--error-color);
    font-size: 0.9rem;
    margin-top: 5px;
    display: none;
}

.file-error.visible {
    display: block;
}

/* Rate Limit Notification */
.rate-limit-notice {
    background-color: #fff3e0;
    border-left: 4px solid var(--warning-color);
    padding: 10px 15px;
    margin-bottom: 20px;
    border-radius: 0 var(--border-radius) var(--border-radius) 0;
    font-size: 0.9rem;
}

/* Responsive Tweaks for New Elements */
@media (max-width: 768px) {
    .loading-text {
        font-size: 1rem;
    }
    
    .rate-limit-notice {
        margin-left: 10px;
        margin-right: 10px;
    }
}