/* Custom CSS */
:root {
    --primary: #0f172a;
    --primary-light: #1e293b;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --bg-color: #f8fafc;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border: #e2e8f0;
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.5);
    --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);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Sarabun', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    background-image: 
        radial-gradient(at 0% 0%, hsla(253,16%,7%,0.03) 0, transparent 50%), 
        radial-gradient(at 50% 0%, hsla(225,39%,30%,0.03) 0, transparent 50%), 
        radial-gradient(at 100% 0%, hsla(339,49%,30%,0.03) 0, transparent 50%);
}

.app-container {
    width: 100%;
    max-width: 900px;
    padding: 2rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* Typography */
h1, h2, h3 {
    font-weight: 600;
    color: var(--primary);
    letter-spacing: -0.025em;
}

h1 {
    font-size: 2.25rem;
    margin-bottom: 0.5rem;
}

h2 {
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.text-center {
    text-align: center;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
}

/* Header */
.header {
    margin-bottom: 1rem;
}

.logo-container {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3.5rem;
    height: 3.5rem;
    background: white;
    border-radius: 1rem;
    box-shadow: var(--shadow-sm);
    margin-bottom: 1rem;
    color: var(--accent);
}

.brand-icon {
    width: 1.75rem;
    height: 1.75rem;
}

/* Reusable Components */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.glass-panel:hover {
    box-shadow: var(--shadow-md);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

/* Buttons */
button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    border-radius: 0.5rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
    padding: 0.75rem 2rem;
    font-size: 1.1rem;
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    margin-top: 1rem;
}

.btn-primary:hover {
    background-color: var(--primary-light);
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-primary:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.btn-outline:hover {
    background: var(--bg-color);
    border-color: var(--text-secondary);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.btn-ghost:hover {
    background: rgba(0,0,0,0.05);
    color: var(--text-primary);
}

.btn-small {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
}

/* Forms & Inputs */
.textarea-wrapper {
    position: relative;
    border-radius: 0.75rem;
    background: white;
    border: 1px solid var(--border);
    overflow: hidden;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.textarea-wrapper:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

textarea {
    width: 100%;
    min-height: 200px;
    padding: 1rem;
    border: none;
    resize: vertical;
    font-family: inherit;
    font-size: 1rem;
    color: var(--text-primary);
    background: transparent;
    outline: none;
}

textarea::placeholder {
    color: #94a3b8;
}

/* Results Section */
.results-section {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    animation: slideUp 0.4s ease-out;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.hidden {
    display: none !important;
}

/* Corrected Text */
.corrected-text-container {
    background: white;
    padding: 1.5rem;
    border-radius: 0.75rem;
    border: 1px solid var(--border);
    min-height: 100px;
}

.final-text {
    white-space: pre-wrap;
    font-size: 1.1rem;
    line-height: 1.8;
}

/* Analysis Deck */
.analysis-deck {
    margin-top: 1rem;
}

.deck-title {
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.filters {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.filter-btn {
    background: white;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 0.4rem 1rem;
    border-radius: 2rem;
    font-size: 0.875rem;
}

.filter-btn:hover {
    background: var(--bg-color);
}

.filter-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.changes-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Change Cards */
.change-card {
    background: white;
    border-radius: 0.75rem;
    padding: 1.25rem;
    border: 1px solid var(--border);
    border-left-width: 4px;
    box-shadow: var(--shadow-sm);
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

.type-spelling { border-left-color: var(--error); }
.type-classifier { border-left-color: var(--warning); }
.type-spacing { border-left-color: var(--accent); }
.type-formality { border-left-color: var(--success); }

/* Change Card Layout */
.change-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.change-type-badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.25rem 0.6rem;
    border-radius: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge-spelling { background: #fee2e2; color: #b91c1c; }
.badge-classifier { background: #fef3c7; color: #b45309; }
.badge-spacing { background: #dbeafe; color: #1d4ed8; }
.badge-formality { background: #d1fae5; color: #047857; }

.change-comparison {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    background: var(--bg-color);
    padding: 0.75rem;
    border-radius: 0.5rem;
}

@media (min-width: 640px) {
    .change-comparison {
        flex-direction: row;
        align-items: center;
    }
}

.comparison-item {
    flex: 1;
}

.comparison-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
    text-transform: uppercase;
}

.comparison-text {
    font-size: 1rem;
    font-weight: 500;
    padding: 0.4rem 0.75rem;
    border-radius: 0.375rem;
    display: inline-block;
    background: white;
    border: 1px solid var(--border);
    word-break: break-all;
}

.text-error { color: var(--error); background: #fef2f2; border-color: #fecaca; }
.text-success { color: var(--success); background: #f0fdf4; border-color: #bbf7d0; }

.comparison-arrow {
    display: none;
    color: var(--text-secondary);
}

@media (min-width: 640px) {
    .comparison-arrow { display: block; margin: 0 1rem; }
}

.change-reason {
    font-size: 0.9rem;
    color: var(--text-secondary);
    border-top: 1px dashed var(--border);
    padding-top: 0.75rem;
    margin-top: 0.5rem;
}

/* Loading Spinner */
.loading-spinner {
    width: 24px;
    height: 24px;
    animation: rotate 2s linear infinite;
}

.loading-spinner .path {
    stroke: currentColor;
    stroke-linecap: round;
    animation: dash 1.5s ease-in-out infinite;
}

@keyframes rotate { 100% { transform: rotate(360deg); } }
@keyframes dash {
    0% { stroke-dasharray: 1, 150; stroke-dashoffset: 0; }
    50% { stroke-dasharray: 90, 150; stroke-dashoffset: -35; }
    100% { stroke-dasharray: 90, 150; stroke-dashoffset: -124; }
}

/* Footer */
.footer {
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--primary);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 0.5rem;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 1rem;
    z-index: 50;
    animation: slideLeft 0.3s ease-out;
}

.toast.error { background: var(--error); }
.toast.success { background: var(--success); }

.toast-close {
    background: transparent;
    color: white;
    font-size: 1.25rem;
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

@keyframes slideLeft {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

/* Interactive Text Highlights (for future feature) */
.highlight-spelling { background-color: #fee2e2; border-bottom: 2px solid var(--error); cursor: pointer; }
.highlight-classifier { background-color: #fef3c7; border-bottom: 2px solid var(--warning); cursor: pointer; }
.highlight-spacing { background-color: #dbeafe; border-bottom: 2px solid var(--accent); cursor: pointer; }
.highlight-formality { background-color: #d1fae5; border-bottom: 2px solid var(--success); cursor: pointer; }
