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

:root {
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --secondary-color: #06b6d4;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --error-color: #ef4444;
    --passive-color: #8b5cf6;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --bg-tertiary: #f3f4f6;
    --border-color: #e5e7eb;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --transition: all 0.2s ease-in-out;
}

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

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

/* Header Styles */
.header {
    background: var(--bg-primary);
    padding: 2rem;
    text-align: center;
    box-shadow: var(--shadow-md);
}

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

.logo {
    width: 48px;
    height: 48px;
    object-fit: contain;
}

.header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary-color);
}

.tagline {
    color: var(--text-secondary);
    font-size: 1rem;
}

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

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

.input-group {
    margin-bottom: 1.5rem;
}

.input-group:last-child {
    margin-bottom: 0;
}

.input-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.url-input-container {
    display: flex;
    gap: 1rem;
}

#url-input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 1rem;
    transition: var(--transition);
}

#url-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

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

#text-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.divider {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 1.5rem 0;
    color: var(--text-secondary);
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid var(--border-color);
}

.divider span {
    padding: 0 1rem;
    font-weight: 500;
}

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

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

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

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

#analyze-text-btn {
    margin-top: 1rem;
}

/* Loading Section */
.loading-section {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: 3rem;
    box-shadow: var(--shadow-lg);
    text-align: center;
    margin-bottom: 2rem;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--bg-tertiary);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

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

/* Results Section */
.results-section {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-lg);
    margin-bottom: 2rem;
}

.results-section h2 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

/* Score Cards */
.score-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.score-card {
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    text-align: center;
    border: 2px solid var(--border-color);
    transition: var(--transition);
}

.score-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.score-card h3 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

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

.score-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

#readability-card .score-value {
    color: var(--success-color);
}

#grammar-card .score-value {
    color: var(--error-color);
}

#style-card .score-value {
    color: var(--warning-color);
}

#passive-card .score-value {
    color: var(--passive-color);
}

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

.tab-btn {
    padding: 0.75rem 1.5rem;
    border: none;
    background: none;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    position: relative;
}

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

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

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--primary-color);
}

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

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

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

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

.legend-color {
    width: 1rem;
    height: 1rem;
    border-radius: var(--radius-sm);
}

.grammar-highlight {
    background: rgba(239, 68, 68, 0.3);
    border: 1px solid var(--error-color);
}

.style-highlight {
    background: rgba(245, 158, 11, 0.3);
    border: 1px solid var(--warning-color);
}

.passive-highlight {
    background: rgba(139, 92, 246, 0.3);
    border: 1px solid var(--passive-color);
}

/* Highlighted Text */
.highlighted-text {
    background: var(--bg-secondary);
    padding: 1.5rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    max-height: 500px;
    overflow-y: auto;
    line-height: 1.8;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.highlighted-text .grammar-error {
    background: rgba(239, 68, 68, 0.3);
    border-bottom: 2px wavy var(--error-color);
    padding: 0.1rem 0.2rem;
    border-radius: 2px;
    cursor: help;
}

.highlighted-text .style-issue {
    background: rgba(245, 158, 11, 0.3);
    border-bottom: 2px dashed var(--warning-color);
    padding: 0.1rem 0.2rem;
    border-radius: 2px;
    cursor: help;
}

.highlighted-text .passive-voice {
    background: rgba(139, 92, 246, 0.3);
    border-bottom: 2px dotted var(--passive-color);
    padding: 0.1rem 0.2rem;
    border-radius: 2px;
    cursor: help;
}

/* Issue List */
.issue-list {
    list-style: none;
}

.issue-list li {
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    margin-bottom: 0.75rem;
    border-left: 4px solid var(--border-color);
    transition: var(--transition);
}

.issue-list li:hover {
    transform: translateX(4px);
}

.issue-list li:last-child {
    margin-bottom: 0;
}

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

.issue-list .style-item {
    border-left-color: var(--warning-color);
}

.issue-list .passive-item {
    border-left-color: var(--passive-color);
}

.issue-text {
    font-weight: 600;
    margin-bottom: 0.25rem;
    color: var(--text-primary);
}

.issue-suggestion {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.issue-context {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-style: italic;
    margin-top: 0.5rem;
    padding: 0.5rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
}

.no-issues {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
}

.no-issues .checkmark {
    font-size: 3rem;
    margin-bottom: 0.5rem;
}

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

.footer p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

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

.footer a:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

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

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

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

    .main-content {
        padding: 1rem;
    }

    .input-section {
        padding: 1.5rem;
    }

    .url-input-container {
        flex-direction: column;
    }

    .score-cards {
        grid-template-columns: repeat(2, 1fr);
    }

    .tabs {
        gap: 0.25rem;
    }

    .tab-btn {
        padding: 0.5rem 1rem;
        font-size: 0.8rem;
    }

    .legend {
        gap: 1rem;
    }

    .highlighted-text {
        padding: 1rem;
        max-height: 400px;
    }
}

@media (max-width: 480px) {
    .score-cards {
        grid-template-columns: 1fr;
    }

    .score-value {
        font-size: 2rem;
    }

    .results-section {
        padding: 1rem;
    }

    .issue-list li {
        padding: 0.75rem;
    }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Tooltip for highlighted text */
[title] {
    position: relative;
}

/* Print Styles */
@media print {
    .header,
    .input-section,
    .loading-section,
    .tabs {
        display: none;
    }

    .results-section {
        box-shadow: none;
        padding: 0;
    }

    .tab-panel {
        display: block !important;
        page-break-inside: avoid;
    }
}
