/* CSS Variables */
:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --primary-light: #e0e7ff;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --background: #f8fafc;
    --surface: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: all 0.2s ease;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

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

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

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

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

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

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

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

/* Section Styles */
section {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow);
}

section h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

section h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--text-secondary);
}

/* Template Grid */
.template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
}

.template-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem;
    background: var(--background);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
}

.template-btn:hover {
    border-color: var(--primary-color);
    background: var(--primary-light);
}

.template-btn.active {
    border-color: var(--primary-color);
    background: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.template-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.template-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.template-desc {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

/* Input Section */
.input-controls {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

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

textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

textarea::placeholder {
    color: var(--text-secondary);
}

.input-stats {
    display: flex;
    gap: 1rem;
    margin: 0.75rem 0;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius-sm);
    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;
    width: 100%;
    padding: 1rem;
    font-size: 1.1rem;
}

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

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

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

.btn-export {
    background: var(--surface);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
    flex: 1;
    min-width: 140px;
}

.btn-export:hover {
    border-color: var(--primary-color);
    background: var(--primary-light);
}

/* Results Section */
.results-section {
    animation: fadeIn 0.3s ease;
}

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

/* Visualization */
.visualization-container {
    margin-bottom: 2rem;
}

.visualization-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.viz-tab {
    padding: 0.5rem 1rem;
    background: var(--background);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.875rem;
    transition: var(--transition);
}

.viz-tab:hover {
    background: var(--primary-light);
}

.viz-tab.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.visualization {
    background: var(--background);
    border-radius: var(--radius-sm);
    padding: 1rem;
    min-height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#vizCanvas {
    max-width: 100%;
    height: auto;
}

/* Plot Points */
.plot-points {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.plot-point {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    background: var(--background);
    border-radius: var(--radius-sm);
    border-left: 4px solid var(--primary-color);
}

.plot-point-number {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
}

.plot-point-content {
    flex: 1;
}

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

.plot-point-description {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.plot-point-excerpt {
    font-size: 0.875rem;
    color: var(--text-primary);
    background: var(--surface);
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    font-style: italic;
}

.plot-point-status {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    margin-top: 0.5rem;
}

.status-found {
    background: #d1fae5;
    color: #065f46;
}

.status-partial {
    background: #fef3c7;
    color: #92400e;
}

.status-missing {
    background: #fee2e2;
    color: #991b1b;
}

/* Summary */
.summary {
    background: var(--background);
    padding: 1rem;
    border-radius: var(--radius-sm);
}

.summary-item {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
}

.summary-item:last-child {
    border-bottom: none;
}

.summary-label {
    color: var(--text-secondary);
}

.summary-value {
    font-weight: 600;
    color: var(--text-primary);
}

/* Export Section */
.export-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

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

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

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

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

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

    .tagline {
        font-size: 0.9rem;
    }

    .main-content {
        padding: 1rem;
    }

    section {
        padding: 1rem;
    }

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

    .template-btn {
        padding: 0.75rem;
    }

    .template-icon {
        font-size: 1.5rem;
    }

    .template-name {
        font-size: 0.8rem;
    }

    .template-desc {
        font-size: 0.7rem;
    }

    .input-controls {
        flex-direction: column;
    }

    .btn-secondary {
        width: 100%;
    }

    textarea {
        min-height: 150px;
    }

    .visualization-tabs {
        flex-wrap: wrap;
    }

    .viz-tab {
        flex: 1;
        text-align: center;
    }

    .export-buttons {
        flex-direction: column;
    }

    .btn-export {
        width: 100%;
    }

    .plot-point {
        flex-direction: column;
    }
}

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

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

    .visualization {
        min-height: 250px;
    }
}

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

    .template-section,
    .input-section,
    .export-section,
    .visualization-tabs {
        display: none;
    }

    .results-section {
        display: block !important;
        box-shadow: none;
    }

    .footer {
        background: none;
        color: var(--text-primary);
    }
}

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

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 24px;
    height: 24px;
    margin: -12px 0 0 -12px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

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

:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

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

::-webkit-scrollbar-track {
    background: var(--background);
}

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

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