/* Design Tokens (Medium Light Theme) */
:root {
    --bg-main: #fbfbfb; /* Warm, clean off-white background */
    --bg-workspace: #ffffff;
    --bg-card: #ffffff;
    --border-color: rgba(230, 230, 230, 1); /* Clean light gray borders */
    --text-main: #292929; /* Dark gray for high contrast readability */
    --text-muted: #757575; /* Medium-style secondary label gray */
    
    --primary: #1a8917; /* Medium-style forest green */
    --primary-hover: #156f12;
    --primary-glow: rgba(26, 137, 23, 0.12);
    
    --success: #1a8917;
    --success-glow: rgba(26, 137, 23, 0.1);
    --warning: #f59e0b;
    --warning-glow: rgba(245, 158, 11, 0.1);
    --danger: #c94a29;
    --danger-glow: rgba(201, 74, 41, 0.1);
    
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 12px 28px rgba(0, 0, 0, 0.08);
    
    --font-sans: 'Inter', sans-serif;
    --font-logo: 'Outfit', sans-serif;
    --font-serif: 'Lora', Georgia, serif;
    --font-mono: 'JetBrains Mono', monospace;
    
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    font-family: var(--font-sans);
    line-height: 1.5;
    overflow-x: hidden;
}

/* App Container Layout */
.app-container {
    display: flex;
    min-height: 100vh;
    position: relative;
}

/* Main Workspace */
.workspace {
    flex: 1;
    max-width: 760px; /* Slimmer max-width for readable paragraph length (like Medium articles) */
    margin: 0 auto;
    padding: 3rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 2.25rem;
    transition: var(--transition);
}

/* Header & Logo */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1.25rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.logo i {
    font-size: 1.4rem;
    color: var(--text-main);
}

.logo span {
    font-family: var(--font-logo);
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    color: var(--text-main);
}

/* Prompt Selector */
.prompt-selector-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.prompt-selector-container label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.prompt-selector-container label i {
    margin-right: 0.2rem;
}

.prompt-selector-container select {
    background-color: #ffffff;
    color: var(--text-main);
    border: 1px solid var(--border-color);
    padding: 0.4rem 0.8rem;
    border-radius: 99px; /* Rounded pill style */
    outline: none;
    font-family: var(--font-sans);
    font-size: 0.825rem;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-md);
}

.prompt-selector-container select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-glow);
}

/* Prompt Card */
.prompt-card {
    background: #ffffff;
    border: 1px solid var(--border-color);
    padding: 1.75rem;
    border-radius: 12px;
    box-shadow: var(--shadow-md);
}

.prompt-card h2 {
    font-family: var(--font-logo);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 0.6rem;
}

.prompt-card p {
    font-size: 1.2rem;
    color: var(--text-main);
    font-weight: 500;
    font-family: var(--font-serif);
    line-height: 1.5;
}

/* Textarea & Editor Container */
.editor-container {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    flex-grow: 1;
}

textarea#writing-input {
    width: 100%;
    min-height: 280px;
    flex-grow: 1;
    background-color: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.75rem;
    color: var(--text-main);
    font-family: var(--font-serif); /* Editorial Lora font */
    font-size: 1.2rem; /* Medium style font sizing */
    line-height: 1.65;
    resize: none;
    outline: none;
    transition: var(--transition);
    box-shadow: var(--shadow-md);
}

textarea#writing-input:focus {
    border-color: rgba(41, 41, 41, 0.6);
    box-shadow: 0 0 0 3px rgba(0,0,0,0.03), var(--shadow-md);
}

/* Editor Footer & Status Indicators */
.editor-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--warning);
    box-shadow: 0 0 8px var(--warning-glow);
    transition: var(--transition);
}

/* Validation Glowing States */
.status-indicator.invalid .status-dot {
    background-color: var(--warning);
    box-shadow: 0 0 8px var(--warning-glow);
}

.status-indicator.valid .status-dot {
    background-color: var(--success);
    box-shadow: 0 0 8px var(--success-glow);
}

.status-indicator.over .status-dot {
    background-color: var(--danger);
    box-shadow: 0 0 8px var(--danger-glow);
}

/* Buttons (Medium rounded-pill style) */
.editor-actions {
    display: flex;
    gap: 0.75rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.65rem 1.4rem;
    border-radius: 99px; /* Pill shaped buttons */
    font-family: var(--font-sans);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    outline: none;
    transition: var(--transition);
}

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

.btn-secondary:hover {
    background-color: #f2f2f2;
    border-color: rgba(41, 41, 41, 0.4);
}

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

.btn-primary:hover:not(:disabled) {
    background-color: var(--primary-hover);
}

.btn-primary:disabled {
    background-color: #e6e6e6;
    color: #a8a8a8;
    cursor: not-allowed;
}

/* Drawer Sliding Dashboard (Medium Light Theme) */
.feedback-drawer {
    position: fixed;
    top: 0;
    right: 0;
    width: 480px;
    height: 100vh;
    background-color: #ffffff;
    border-left: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    z-index: 100;
    transform: translateX(100%);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    overflow-y: auto;
}

.feedback-drawer.open {
    transform: translateX(0);
}

/* Shift Workspace left when drawer is open on wide screens */
@media (min-width: 1400px) {
    body.drawer-open .workspace {
        margin-left: calc(50% - 660px);
    }
}

.close-drawer-btn {
    position: absolute;
    top: 1.25rem;
    right: 1.25rem;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.25rem;
    cursor: pointer;
    transition: var(--transition);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.close-drawer-btn:hover {
    background-color: #f2f2f2;
    color: var(--text-main);
}

.drawer-content {
    padding: 3rem 2rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.drawer-title {
    font-family: var(--font-logo);
    font-size: 1.35rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1rem;
    color: var(--text-main);
}

.drawer-title i {
    color: var(--primary);
}

/* Radial Progress Ring & Grade Badge */
.grade-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    margin: 0.5rem 0;
}

.radial-progress {
    position: relative;
    width: 120px;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.progress-ring {
    transform: rotate(-90deg);
}

.progress-ring__circle-bg {
    stroke: rgba(0, 0, 0, 0.04);
}

.progress-ring__circle {
    transition: stroke-dashoffset 0.65s ease-out;
}

.grade-badge {
    position: absolute;
    font-family: var(--font-logo);
    font-size: 2.25rem;
    font-weight: 700;
    color: var(--text-main);
}

.grade-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Metrics Grid Cards */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.metric-card {
    background-color: #f9f9f9;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.metric-name {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.metric-value-container {
    display: flex;
    align-items: baseline;
}

.metric-value {
    font-size: 1.35rem;
    font-weight: 700;
    font-family: var(--font-logo);
    color: var(--text-main);
}

.metric-card .percent {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-left: 0.05rem;
}

/* Feedback Section Cards */
.feedback-section {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.feedback-section h3 {
    font-family: var(--font-logo);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.feedback-section h3 i {
    color: var(--primary);
}

.review-paragraph {
    background-color: rgba(26, 137, 23, 0.04);
    border-left: 3px solid var(--primary);
    padding: 1.2rem;
    border-radius: 0 6px 6px 0;
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--text-main);
    font-family: var(--font-serif);
}

.vocab-feedback-text {
    background-color: #f9f9f9;
    border: 1px dashed var(--border-color);
    padding: 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--text-main);
}

/* Grammar Corrections Card List */
.corrections-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.correction-card {
    background-color: #f9f9f9;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.correction-line {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
}

.correction-original {
    color: #b22222; /* Clean brick-red strikethrough */
    text-decoration: line-through;
    font-family: var(--font-mono);
}

.correction-arrow {
    color: var(--text-muted);
}

.correction-replacement {
    color: var(--success);
    font-weight: 600;
    font-family: var(--font-mono);
}

.correction-explanation {
    font-size: 0.825rem;
    color: var(--text-muted);
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    padding-top: 0.4rem;
    margin-top: 0.2rem;
}

/* Loading Overlay & Animations (Light theme loader) */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(255, 255, 255, 0.85); /* Light blur background */
    backdrop-filter: blur(8px);
    z-index: 200;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

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

.spinner-container {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.spinner-container p {
    font-family: var(--font-logo);
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--text-main);
}

.double-bounce1, .double-bounce2 {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: var(--primary);
    opacity: 0.6;
    position: absolute;
    animation: sk-bounce 2.0s infinite ease-in-out;
}

.double-bounce2 {
    animation-delay: -1.0s;
}

.spinner-container {
    position: relative;
    width: 250px;
    height: 150px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

@keyframes sk-bounce {
    0%, 100% { 
        transform: scale(0.0);
    } 50% { 
        transform: scale(1.0);
    }
}

/* Responsiveness */
@media (max-width: 768px) {
    .workspace {
        padding: 2rem 1rem;
    }
    
    .header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .prompt-selector-container {
        width: 100%;
        justify-content: space-between;
    }
    
    .feedback-drawer {
        width: 100%;
    }
}

/* Footer Credit */
.footer {
    border-top: 1px solid var(--border-color);
    padding-top: 1.5rem;
    margin-top: auto;
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-muted);
    font-family: var(--font-sans);
}

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

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