/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 16px;
    font-weight: 400;
    line-height: 1.6;
    color: #3F3F46;
    background-color: #F8F9FA;
    overflow-x: hidden;
}

/* Layout Structure */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: 240px;
    height: 100vh;
    background: #FFFFFF;
    border-right: 1px solid #E4E4E7;
    box-shadow: 4px 0 12px rgba(37, 99, 235, 0.08);
    z-index: 100;
    overflow-y: auto;
}

.main-content {
    margin-left: 240px;
    min-height: 100vh;
    background: #F8F9FA;
}

/* Sidebar Styles */
.sidebar-header {
    padding: 32px 24px 24px;
    border-bottom: 1px solid #F3F4F6;
}

.logo {
    font-size: 24px;
    font-weight: 700;
    color: #18181B;
    line-height: 1.3;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 12px 24px;
    color: #6B7280;
    text-decoration: none;
    transition: all 200ms ease-out;
    position: relative;
}

.nav-item:hover {
    background-color: #EBF4FF;
    color: #2563EB;
}

.nav-item.active {
    background-color: #EBF4FF;
    color: #2563EB;
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: #2563EB;
}

.nav-icon {
    width: 20px;
    height: 20px;
    margin-right: 12px;
}

.nav-item span {
    font-size: 14px;
    font-weight: 500;
}

/* Header Styles */
.header {
    background: #FFFFFF;
    padding: 24px 32px;
    border-bottom: 1px solid #E4E4E7;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.05);
}

.page-title {
    font-size: 32px;
    font-weight: 700;
    color: #18181B;
    line-height: 1.3;
}

.header-actions {
    display: flex;
    gap: 12px;
}

/* Button Styles */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 200ms ease-out;
    background: transparent;
    color: inherit;
}

.btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.btn-primary {
    background: #2563EB;
    color: #FFFFFF;
    box-shadow: none;
}

.btn-primary:hover {
    background: #1D4ED8;
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(37, 99, 235, 0.12);
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-secondary {
    background: #F3F4F6;
    color: #3F3F46;
    border: 1px solid #E4E4E7;
}

.btn-secondary:hover {
    background: #E4E4E7;
    color: #18181B;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 14px;
}

.btn-large {
    padding: 16px 32px;
    font-size: 16px;
    min-width: 180px;
    justify-content: center;
}

.btn-icon {
    width: 16px;
    height: 16px;
}

.btn-icon-right {
    margin-left: 8px;
}

/* Content Container */
.content-container {
    padding: 32px;
    max-width: none;
    width: calc(100% - 48px);
    margin: 0 auto;
}

.editor-layout {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 32px;
    align-items: start;
}

/* Two-column layout: evenly split input and results (50/50) */
.editor-layout.two-column {
    grid-template-columns: 1fr 1fr;
    gap: 32px;
    align-items: start;
}

/* Panel Styles */
.panel {
    background: #FFFFFF;
    border-radius: 12px;
    box-shadow: 4px 12px rgba(37, 99, 235, 0.08);
    overflow: hidden;
}

.panel-header {
    padding: 24px;
    border-bottom: 1px solid #F3F4F6;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.panel-title {
    font-size: 18px;
    font-weight: 600;
    color: #18181B;
    line-height: 1.4;
}

.panel-stats {
    font-size: 14px;
    color: #6B7280;
}

/* Text Input */
.text-input {
    width: 100%;
    height: 400px;
    padding: 24px;
    border: none;
    border-bottom: 1px solid #F3F4F6;
    font-family: inherit;
    font-size: 16px;
    line-height: 1.6;
    resize: vertical;
    background: transparent;
    color: #3F3F46;
}

.text-input:focus {
    outline: none;
    border-color: #2563EB;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.text-input::placeholder {
    color: #A1A1AA;
}

/* Action Panel */
.action-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    padding: 32px;
}

.action-controls {
    display: flex;
    flex-direction: column;
    gap: 24px;
    align-items: center;
}

.tab-selector {
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: #F8F9FA;
    padding: 4px;
    border-radius: 12px;
}

.tab-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #6B7280;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 200ms ease-out;
}

.tab-btn:hover {
    color: #2563EB;
}

.tab-btn.active {
    background: #FFFFFF;
    color: #2563EB;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.08);
}

.tab-icon {
    width: 16px;
    height: 16px;
}

/* Loading Indicator */
.loading-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 32px;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #F3F4F6;
    border-top: 3px solid #2563EB;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-text {
    font-size: 14px;
    color: #6B7280;
}

/* Results Container */
.results-container {
    width: 100%;
    max-width: none;
    min-width: 0;
}

.result-card {
    background: #FFFFFF;
    border-radius: 12px;
    box-shadow: 4px 12px rgba(37, 99, 235, 0.08);
    overflow: hidden;
}

.result-header {
    padding: 24px;
    border-bottom: 1px solid #F3F4F6;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.result-title {
    font-size: 18px;
    font-weight: 600;
    color: #18181B;
    line-height: 1.4;
}

/* AI Detection Specific */
.ai-detection .circular-progress {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: conic-gradient(#16A34A 0deg, #16A34A calc(var(--score) * 3.6deg), #F3F4F6 calc(var(--score) * 3.6deg), #F3F4F6 360deg);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.ai-detection .circular-progress::before {
    content: '';
    position: absolute;
    width: 48px;
    height: 48px;
    background: #FFFFFF;
    border-radius: 50%;
    z-index: 1;
}

.score-text {
    position: relative;
    z-index: 2;
    font-size: 14px;
    font-weight: 600;
    color: #18181B;
}

.confidence-level {
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 16px;
}

.confidence-level.high {
    background: #FEE2E2;
    color: #DC2626;
}

.confidence-level.medium {
    background: #FEF3C7;
    color: #F59E0B;
}

.confidence-level.low {
    background: #D1FAE5;
    color: #16A34A;
}

/* Humanization Specific */
.humanization .improvement-badge {
    background: #D1FAE5;
    color: #16A34A;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
}

.comparison-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 24px;
}

.text-comparison h5 {
    font-size: 14px;
    font-weight: 600;
    color: #6B7280;
    margin-bottom: 8px;
}

.text-preview {
    padding: 16px;
    background: #F8F9FA;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.5;
    max-height: 200px;
    overflow-y: auto;
}

.text-preview.original {
    border-left: 4px solid #F59E0B;
}

.text-preview.humanized {
    border-left: 4px solid #16A34A;
}

/* Grammar Check Specific */
.grammar-check .error-count {
    background: #FEE2E2;
    color: #DC2626;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
}

.corrected-text {
    padding: 16px;
    background: #F0FDF4;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 24px;
    border-left: 4px solid #16A34A;
}

.corrected-text .correction {
    background: #FEF3C7;
    padding: 2px 4px;
    border-radius: 4px;
    text-decoration: underline;
    text-decoration-color: #F59E0B;
}

.error-item {
    padding: 12px;
    background: #FEF2F2;
    border-radius: 8px;
    margin-bottom: 12px;
    border-left: 4px solid #DC2626;
}

.error-type {
    font-size: 14px;
    font-weight: 600;
    color: #DC2626;
    margin-bottom: 4px;
}

.error-location {
    font-size: 12px;
    color: #6B7280;
    margin-bottom: 4px;
}

.error-suggestion {
    font-size: 14px;
    color: #3F3F46;
}

/* Metrics */
.humanization-metrics {
    display: flex;
    gap: 24px;
    margin-top: 16px;
}

.metric {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.metric-label {
    font-size: 12px;
    color: #6B7280;
    font-weight: 500;
}

.metric-value {
    font-size: 16px;
    font-weight: 600;
    color: #16A34A;
}

/* Input Actions */
.input-actions {
    padding: 16px 24px;
    display: flex;
    gap: 12px;
    background: #F8F9FA;
}

/* Grammar Actions */
.grammar-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid #F3F4F6;
}

/* Analysis Details */
.analysis-details {
    margin-top: 16px;
}

.analysis-details h5 {
    font-size: 14px;
    font-weight: 600;
    color: #3F3F46;
    margin-bottom: 8px;
}

.analysis-details ul {
    list-style: none;
    padding: 0;
}

.analysis-details li {
    padding: 4px 0;
    font-size: 14px;
    color: #6B7280;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .main-content {
        margin-left: 0;
    }
    
    .sidebar {
        transform: translateX(-100%);
        transition: transform 300ms ease-out;
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .editor-layout {
        grid-template-columns: 1fr;
        gap: 24px;
    }
    
    .action-panel {
        order: -1;
    }
    
    .comparison-container {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .content-container {
        padding: 16px;
    }
    
    .header {
        padding: 16px;
        flex-direction: column;
        gap: 16px;
        align-items: flex-start;
    }
    
    .header-actions {
        width: 100%;
        justify-content: stretch;
    }
    
    .btn-large {
        width: 100%;
    }
    
    .tab-selector {
        flex-direction: row;
        width: 100%;
    }
    
    .tab-btn {
        flex: 1;
        justify-content: center;
    }
    
    .panel-header {
        flex-direction: column;
        gap: 8px;
        align-items: flex-start;
    }
    
    .text-input {
        height: 300px;
    }
    
    .input-actions {
        flex-wrap: wrap;
    }
    
    .grammar-actions {
        flex-direction: column;
    }
}

/* Animations */
.result-card {
    animation: slideUp 300ms ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .btn-primary {
        border: 2px solid #000000;
    }
    
    .nav-item.active {
        border: 2px solid #2563EB;
    }
}