/**
 * Cognitive Reframer - Styles
 * Modern, accessible, and responsive design
 */

:root {
    --primary-color: #ff9900;
    --primary-dark: #e88600;
    --secondary-color: #232f3e;
    --accent-color: #00a8e1;
    --success-color: #16a34a;
    --warning-color: #f59e0b;
    --error-color: #dc2626;
    --bg-color: #f8f9fa;
    --card-bg: #ffffff;
    --text-primary: #1a1a1a;
    --text-secondary: #6b7280;
    --border-color: #e5e7eb;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.1);
    --radius: 12px;
    --radius-sm: 8px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    padding: 24px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 32px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--primary-color);
}

.logo svg {
    width: 32px;
    height: 32px;
}

.logo h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
}

.nav {
    display: flex;
    gap: 8px;
}

.nav-btn {
    padding: 10px 20px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.nav-btn:hover {
    background: var(--bg-color);
    color: var(--text-primary);
}

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

/* Main Content */
.main {
    flex: 1;
    padding-bottom: 40px;
}

.view {
    display: none;
}

.view.active {
    display: block;
}

/* Hero Section */
.hero {
    text-align: center;
    margin-bottom: 40px;
}

.hero h2 {
    font-size: 36px;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.subtitle {
    font-size: 18px;
    color: var(--text-secondary);
    font-weight: 400;
}

/* Card */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 32px;
    box-shadow: var(--shadow);
    margin-bottom: 32px;
}

/* Input Section */
.input-label {
    display: block;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.thought-input {
    width: 100%;
    padding: 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 16px;
    font-family: inherit;
    resize: vertical;
    transition: border-color 0.2s;
}

.thought-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.input-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 12px 0 24px;
    font-size: 14px;
    color: var(--text-secondary);
}

.tone-selector {
    display: flex;
    align-items: center;
    gap: 8px;
}

.tone-select {
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    background: white;
    cursor: pointer;
}

/* Buttons */
.btn {
    padding: 14px 28px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 16px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

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

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

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

.btn-secondary:hover:not(:disabled) {
    background: #1a252f;
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--border-color);
    color: var(--text-primary);
}

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

.btn-text {
    background: transparent;
    color: var(--accent-color);
    padding: 8px 12px;
    font-size: 14px;
}

.btn-text:hover {
    background: var(--bg-color);
}

/* Spinner */
.spinner {
    animation: rotate 1s linear infinite;
    width: 20px;
    height: 20px;
}

.spinner circle {
    stroke-dasharray: 1, 150;
    stroke-dashoffset: 0;
    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; }
}

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

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

.results-header {
    margin-bottom: 24px;
}

.results-header h3 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 12px;
}

.original-thought {
    font-size: 15px;
    color: var(--text-secondary);
    font-style: italic;
}

/* Reframes Grid */
.reframes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.reframe-card {
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    padding: 24px;
    transition: all 0.2s;
}

.reframe-card:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.reframe-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.model-badge {
    background: var(--accent-color);
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
}

.reframe-number {
    width: 32px;
    height: 32px;
    background: var(--bg-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--text-secondary);
}

.reframe-text {
    font-size: 18px;
    font-weight: 600;
    line-height: 1.4;
    margin-bottom: 12px;
    color: var(--primary-dark);
}

.reframe-explanation {
    font-size: 15px;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.action-steps {
    background: var(--bg-color);
    padding: 16px;
    border-radius: var(--radius-sm);
    border-left: 4px solid var(--success-color);
}

.action-steps strong {
    display: block;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.action-steps ol {
    margin-left: 20px;
}

.action-steps li {
    margin-bottom: 8px;
    color: var(--text-primary);
}

/* Results Footer */
.results-footer {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.summary-card {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 20px;
    border-radius: var(--radius);
}

.summary-card strong {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    opacity: 0.9;
}

.summary-card p {
    font-size: 16px;
    line-height: 1.5;
}

.action-buttons {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.action-buttons .btn {
    flex: 1;
    min-width: 180px;
}

/* Safety Message */
.safety-message {
    background: #fef2f2;
    border: 2px solid var(--error-color);
    border-radius: var(--radius);
    padding: 24px;
    display: flex;
    gap: 20px;
    margin-top: 24px;
}

.safety-icon {
    font-size: 32px;
}

.safety-content h4 {
    font-size: 18px;
    color: var(--error-color);
    margin-bottom: 12px;
}

.safety-content p {
    margin-bottom: 16px;
}

.crisis-resources {
    background: white;
    padding: 16px;
    border-radius: var(--radius-sm);
}

.crisis-resources strong {
    display: block;
    margin-bottom: 8px;
}

.crisis-resources ul {
    list-style: none;
    padding: 0;
}

.crisis-resources li {
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}

.crisis-resources li:last-child {
    border-bottom: none;
}

/* History View */
.history-header {
    text-align: center;
    margin-bottom: 32px;
}

.history-header h2 {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 12px;
}

.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.loading-state .spinner {
    width: 40px;
    height: 40px;
    margin-bottom: 16px;
}

.history-container {
    display: grid;
    gap: 16px;
}

.history-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 20px;
    transition: all 0.2s;
}

.history-card:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow);
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.history-date {
    font-size: 13px;
    color: var(--text-secondary);
}

.history-models {
    display: flex;
    gap: 6px;
}

.history-models .model-badge {
    font-size: 11px;
    padding: 4px 8px;
}

.history-input {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.history-summary {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.empty-state {
    text-align: center;
    padding: 80px 20px;
    color: var(--text-secondary);
}

.empty-state svg {
    margin-bottom: 24px;
    color: var(--border-color);
}

.empty-state h3 {
    font-size: 20px;
    margin-bottom: 8px;
    color: var(--text-primary);
}

/* Footer */
.footer {
    border-top: 1px solid var(--border-color);
    padding: 24px 0;
    margin-top: auto;
    text-align: center;
    font-size: 14px;
    color: var(--text-secondary);
}

.footer p {
    margin-bottom: 8px;
}

.footer a {
    color: var(--accent-color);
    text-decoration: none;
}

.footer a:hover {
    text-decoration: underline;
}

.footer-credits {
    font-size: 13px;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--secondary-color);
    color: white;
    padding: 16px 24px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 1000;
    max-width: 400px;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast.toast-success {
    background: var(--success-color);
}

.toast.toast-error {
    background: var(--error-color);
}

.toast.toast-warning {
    background: var(--warning-color);
}

.toast.toast-info {
    background: var(--accent-color);
}

/* Responsive */
@media (max-width: 768px) {
    .header {
        flex-direction: column;
        gap: 16px;
    }

    .hero h2 {
        font-size: 28px;
    }

    .subtitle {
        font-size: 16px;
    }

    .card {
        padding: 20px;
    }

    .reframes-grid {
        grid-template-columns: 1fr;
    }

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

    .action-buttons .btn {
        width: 100%;
        min-width: 0;
    }

    .toast {
        left: 16px;
        right: 16px;
        bottom: 16px;
    }
}

@media print {
    .header, .footer, .btn, .nav {
        display: none;
    }
}

