/* CSS Variables for theming */
:root {
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --primary-light: #e0e7ff;
    --secondary-color: #64748b;
    --secondary-hover: #475569;
    --success-color: #10b981;
    --success-light: #d1fae5;
    --warning-color: #f59e0b;
    --warning-light: #fef3c7;
    --error-color: #ef4444;
    --error-light: #fee2e2;
    --info-color: #3b82f6;
    --info-light: #dbeafe;

    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;

    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-muted: #94a3b8;

    --border-color: #e2e8f0;
    --border-radius: 12px;
    --border-radius-sm: 8px;
    --border-radius-lg: 16px;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);

    --transition: all 0.2s ease;
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
}

/* Reset and Base Styles */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    background: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* App Container */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header */
.header {
    background: linear-gradient(135deg, var(--primary-color) 0%, #7c3aed 100%);
    color: white;
    padding: 2rem 1rem;
    text-align: center;
}

.header-content {
    max-width: 800px;
    margin: 0 auto;
}

.logo-section {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.logo {
    width: 48px;
    height: 48px;
    border-radius: var(--border-radius-sm);
}

.header h1 {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.tagline {
    font-size: 1.1rem;
    opacity: 0.9;
    margin-top: 0.5rem;
}

/* Main Content */
.main-content {
    flex: 1;
    max-width: 1000px;
    width: 100%;
    margin: 0 auto;
    padding: 2rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* Input Section */
.input-section {
    background: var(--bg-primary);
    border-radius: var(--border-radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.section-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

textarea#text-input {
    width: 100%;
    min-height: 200px;
    padding: 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    font-family: var(--font-family);
    font-size: 1rem;
    line-height: 1.7;
    resize: vertical;
    transition: var(--transition);
}

textarea#text-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-light);
}

textarea#text-input::placeholder {
    color: var(--text-muted);
}

.input-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.char-count {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--border-radius-sm);
    font-family: var(--font-family);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.btn-icon {
    font-size: 1.1rem;
}

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

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

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

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

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

/* Info Section */
.info-section {
    animation: fadeIn 0.3s ease;
}

.info-card {
    background: var(--bg-primary);
    border-radius: var(--border-radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.info-card h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

.info-card > p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.cohesion-types {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}

.type-item {
    display: flex;
    gap: 0.75rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
}

.type-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.type-item strong {
    display: block;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.type-item p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin: 0;
}

/* Results Section */
.results-section {
    background: var(--bg-primary);
    border-radius: var(--border-radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    animation: slideUp 0.4s ease;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.results-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.score-display {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.score-circle {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: conic-gradient(var(--primary-color) 0deg, var(--bg-tertiary) 0deg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
}

.score-circle::before {
    content: '';
    position: absolute;
    width: 64px;
    height: 64px;
    background: var(--bg-primary);
    border-radius: 50%;
}

.score-value {
    position: relative;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
}

.score-label {
    position: relative;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.score-description {
    max-width: 200px;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Tabs */
.results-tabs {
    display: flex;
    gap: 0.5rem;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 1.5rem;
    overflow-x: auto;
    padding-bottom: 2px;
}

.tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border: none;
    background: transparent;
    font-family: var(--font-family);
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: var(--transition);
    white-space: nowrap;
}

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

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

.tab-icon {
    font-size: 1rem;
}

.badge {
    background: var(--error-light);
    color: var(--error-color);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.125rem 0.5rem;
    border-radius: 999px;
}

/* Tab Panels */
.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

/* Legend */
.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: var(--bg-secondary);
    border-radius: var(--border-radius-sm);
}

.legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 4px;
}

.legend-color.good {
    background: var(--success-light);
    border: 2px solid var(--success-color);
}

.legend-color.moderate {
    background: var(--warning-light);
    border: 2px solid var(--warning-color);
}

.legend-color.weak {
    background: var(--error-light);
    border: 2px solid var(--error-color);
}

.legend-color.transition {
    background: var(--info-light);
    border: 2px solid var(--info-color);
}

/* Highlighted Text */
.highlighted-text {
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    line-height: 1.8;
    font-size: 1rem;
}

.highlighted-text .sentence {
    padding: 0.125rem 0.25rem;
    border-radius: 4px;
    cursor: pointer;
    transition: var(--transition);
}

.highlighted-text .sentence:hover {
    filter: brightness(0.95);
}

.highlighted-text .sentence.good {
    background: var(--success-light);
}

.highlighted-text .sentence.moderate {
    background: var(--warning-light);
}

.highlighted-text .sentence.weak {
    background: var(--error-light);
}

.highlighted-text .transition-word {
    background: var(--info-light);
    border-radius: 4px;
    padding: 0.125rem 0.25rem;
    font-weight: 500;
}

/* Issues List */
.issues-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.issue-item {
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    border-left: 4px solid var(--warning-color);
}

.issue-item.severe {
    border-left-color: var(--error-color);
}

.issue-header {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.issue-icon {
    font-size: 1.25rem;
}

.issue-title {
    font-weight: 600;
    color: var(--text-primary);
}

.issue-location {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.issue-description {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-left: 2rem;
}

/* Suggestions List */
.suggestions-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.suggestion-item {
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    border-left: 4px solid var(--success-color);
}

.suggestion-header {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.suggestion-icon {
    font-size: 1.25rem;
}

.suggestion-title {
    font-weight: 600;
    color: var(--text-primary);
}

.suggestion-content {
    margin-left: 2rem;
}

.suggestion-original {
    color: var(--text-muted);
    text-decoration: line-through;
    margin-bottom: 0.25rem;
}

.suggestion-improved {
    color: var(--success-color);
    font-weight: 500;
}

.suggestion-explanation {
    margin-top: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Connections Panel */
.connections-intro {
    margin-bottom: 1rem;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.sentence-selector {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.sentence-option {
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
    border: 2px solid transparent;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: var(--transition);
    text-align: left;
    font-family: var(--font-family);
    font-size: 0.95rem;
    color: var(--text-primary);
}

.sentence-option:hover {
    border-color: var(--primary-light);
}

.sentence-option.selected {
    border-color: var(--primary-color);
    background: var(--primary-light);
}

.sentence-number {
    display: inline-block;
    width: 24px;
    height: 24px;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    text-align: center;
    line-height: 24px;
    font-size: 0.8rem;
    font-weight: 600;
    margin-right: 0.75rem;
}

.connections-display {
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    min-height: 100px;
}

.connection-item {
    padding: 0.75rem;
    margin-bottom: 0.75rem;
    background: var(--bg-primary);
    border-radius: var(--border-radius-sm);
    border-left: 4px solid var(--info-color);
}

.connection-strength {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.25rem 0.5rem;
    border-radius: 999px;
    margin-bottom: 0.5rem;
}

.connection-strength.strong {
    background: var(--success-light);
    color: var(--success-color);
}

.connection-strength.moderate {
    background: var(--warning-light);
    color: var(--warning-color);
}

.connection-strength.weak {
    background: var(--error-light);
    color: var(--error-color);
}

.connection-details {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.shared-words {
    margin-top: 0.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.shared-word {
    display: inline-block;
    background: var(--info-light);
    color: var(--info-color);
    padding: 0.25rem 0.5rem;
    border-radius: var(--border-radius-sm);
    font-size: 0.8rem;
    font-weight: 500;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

/* Footer */
.footer {
    background: var(--text-primary);
    color: var(--bg-tertiary);
    padding: 1.5rem 1rem;
    text-align: center;
    margin-top: auto;
}

.footer-content {
    max-width: 1000px;
    margin: 0 auto;
}

.footer a {
    color: var(--primary-light);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
}

.footer a:hover {
    color: white;
    text-decoration: underline;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

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

/* Loading State */
.loading {
    position: relative;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn.loading::after {
    content: '';
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    position: static;
    background: none;
    margin-left: 0.5rem;
}

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

/* Responsive Design */
@media (max-width: 768px) {
    .header {
        padding: 1.5rem 1rem;
    }

    .header h1 {
        font-size: 1.5rem;
    }

    .tagline {
        font-size: 0.95rem;
    }

    .main-content {
        padding: 1rem;
        gap: 1.5rem;
    }

    .input-section,
    .results-section,
    .info-card {
        padding: 1rem;
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .input-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .char-count {
        text-align: center;
    }

    .btn-primary {
        justify-content: center;
    }

    .results-header {
        flex-direction: column;
        text-align: center;
    }

    .score-display {
        width: 100%;
        justify-content: center;
    }

    .score-description {
        max-width: none;
        text-align: left;
    }

    .results-tabs {
        gap: 0.25rem;
    }

    .tab-btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.85rem;
    }

    .tab-icon {
        display: none;
    }

    .legend {
        flex-direction: column;
        gap: 0.5rem;
    }

    .issue-description,
    .suggestion-content {
        margin-left: 0;
        margin-top: 0.75rem;
    }

    .cohesion-types {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    html {
        font-size: 14px;
    }

    .logo-section {
        flex-direction: column;
        gap: 0.5rem;
    }

    .logo {
        width: 40px;
        height: 40px;
    }

    textarea#text-input {
        min-height: 150px;
    }
}

/* Print Styles */
@media print {
    .header {
        background: none;
        color: var(--text-primary);
        border-bottom: 2px solid var(--border-color);
    }

    .btn,
    .results-tabs {
        display: none;
    }

    .tab-panel {
        display: block !important;
        margin-bottom: 2rem;
    }

    .footer {
        background: none;
        color: var(--text-primary);
        border-top: 1px solid var(--border-color);
    }
}

/* Focus Styles for Accessibility */
:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

button:focus-visible,
.sentence-option:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    :root {
        --border-color: #000;
        --text-muted: #555;
    }

    .sentence.good,
    .sentence.moderate,
    .sentence.weak {
        border: 2px solid currentColor;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
