/**
 * Responsive Stylesheet with Dark/Light Themes
 * Default: Dark theme (Gruvbox-inspired)
 */

/* ============================================
   CSS Variables for Themes
   ============================================ */

:root {
    --transition-speed: 0.3s;
}

/* Dark Theme (Gruvbox-inspired) - Default */
body[data-theme="dark"],
body:not([data-theme]) {
    --bg-primary: #282828;
    --bg-secondary: #3c3836;
    --bg-tertiary: #504945;
    --text-primary: #ebdbb2;
    --text-secondary: #d5c4a1;
    --text-muted: #a89984;
    --accent-primary: #fe8019;
    --accent-secondary: #fabd2f;
    --border-color: #504945;
    --mood-very-negative: #fb4934;
    --mood-negative: #fe8019;
    --mood-neutral: #d5c4a1;
    --mood-positive: #b8bb26;
    --mood-very-positive: #8ec07c;
    --code-bg: #1d2021;
    --shadow: rgba(0, 0, 0, 0.3);
}

/* Light Theme */
body[data-theme="light"] {
    --bg-primary: #fbf1c7;
    --bg-secondary: #f2e5bc;
    --bg-tertiary: #ebdbb2;
    --text-primary: #3c3836;
    --text-secondary: #504945;
    --text-muted: #7c6f64;
    --accent-primary: #d65d0e;
    --accent-secondary: #af3a03;
    --border-color: #d5c4a1;
    --mood-very-negative: #cc241d;
    --mood-negative: #d65d0e;
    --mood-neutral: #7c6f64;
    --mood-positive: #79740e;
    --mood-very-positive: #427b58;
    --code-bg: #ebdbb2;
    --shadow: rgba(0, 0, 0, 0.1);
}

/* ============================================
   Reset & Base Styles
   ============================================ */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    transition: background-color var(--transition-speed), color var(--transition-speed);
    padding: 20px;
}

/* ============================================
   Container & Layout
   ============================================ */

.container {
    max-width: 900px;
    margin: 0 auto;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--border-color);
}

h1 {
    font-size: 2rem;
    color: var(--accent-primary);
}

/* ============================================
   App Download Banner
   ============================================ */

.app-download-banner {
    background: var(--bg-secondary);
    border: 2px solid var(--accent-primary);
    border-radius: 8px;
    padding: 12px 20px;
    margin-bottom: 25px;
    text-align: center;
}

.app-download-banner p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.app-download-banner a {
    color: var(--accent-primary);
    font-weight: bold;
    text-decoration: none;
    border-bottom: 2px solid var(--accent-primary);
    transition: all var(--transition-speed);
}

.app-download-banner a:hover {
    color: var(--accent-secondary);
    border-bottom-color: var(--accent-secondary);
}

footer {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 2px solid var(--border-color);
    text-align: center;
}

/* ============================================
   Theme Toggle Button
   ============================================ */

.theme-toggle {
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 10px 16px;
    cursor: pointer;
    font-size: 1.5rem;
    transition: all var(--transition-speed);
    display: flex;
    align-items: center;
    gap: 8px;
}

.theme-toggle:hover {
    background: var(--bg-tertiary);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px var(--shadow);
}

.theme-icon {
    display: inline-block;
}

/* ============================================
   Controls (Search & Sort)
   ============================================ */

.controls {
    display: flex;
    gap: 15px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.search-box {
    flex: 1;
    min-width: 200px;
}

.search-box input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1rem;
    transition: all var(--transition-speed);
}

.search-box input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--shadow);
}

.search-box input::placeholder {
    color: var(--text-muted);
}

.sort-box {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sort-box label {
    color: var(--text-secondary);
    font-weight: 500;
}

.sort-box select {
    padding: 12px 16px;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1rem;
    cursor: pointer;
    transition: all var(--transition-speed);
}

.sort-box select:focus {
    outline: none;
    border-color: var(--accent-primary);
}

/* ============================================
   Thoughts Container
   ============================================ */

.thoughts-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.thought-card {
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    transition: all var(--transition-speed);
    position: relative;
}

.thought-card:hover {
    border-color: var(--accent-primary);
    box-shadow: 0 4px 12px var(--shadow);
}

.thought-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 10px;
}

.thought-datetime {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.thought-mood {
    font-size: 1.5rem;
    padding: 4px 12px;
    border-radius: 20px;
    background: var(--bg-tertiary);
}

/* Mood colors */
.mood--2 { color: var(--mood-very-negative); }
.mood--1 { color: var(--mood-negative); }
.mood-0 { color: var(--mood-neutral); }
.mood-1 { color: var(--mood-positive); }
.mood-2 { color: var(--mood-very-positive); }

.thought-content {
    color: var(--text-primary);
    word-wrap: break-word;
}

/* ============================================
   Markdown Styling
   ============================================ */

.thought-content h1,
.thought-content h2,
.thought-content h3,
.thought-content h4,
.thought-content h5,
.thought-content h6 {
    color: var(--accent-secondary);
    margin-top: 1.5em;
    margin-bottom: 0.5em;
}

.thought-content h1 { font-size: 1.8rem; }
.thought-content h2 { font-size: 1.5rem; }
.thought-content h3 { font-size: 1.3rem; }

.thought-content p {
    margin-bottom: 1em;
}

.thought-content a {
    color: var(--accent-primary);
    text-decoration: none;
    border-bottom: 1px solid var(--accent-primary);
}

.thought-content a:hover {
    color: var(--accent-secondary);
}

.thought-content img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 1em 0;
}

.thought-content code {
    background: var(--code-bg);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: "Courier New", monospace;
    font-size: 0.9em;
}

.thought-content pre {
    background: var(--code-bg);
    padding: 15px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 1em 0;
}

.thought-content pre code {
    background: none;
    padding: 0;
}

.thought-content ul,
.thought-content ol {
    margin-left: 1.5em;
    margin-bottom: 1em;
}

.thought-content li {
    margin-bottom: 0.5em;
}

.thought-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1em 0;
    display: block;
    overflow-x: auto;
    white-space: nowrap;
}

.thought-content table th,
.thought-content table td {
    border: 1px solid var(--border-color);
    padding: 10px;
    text-align: left;
}

.thought-content table th {
    background: var(--bg-tertiary);
    font-weight: bold;
}

.thought-content blockquote {
    border-left: 4px solid var(--accent-primary);
    padding-left: 15px;
    margin: 1em 0;
    color: var(--text-secondary);
    font-style: italic;
}

/* ============================================
   Loading & Messages
   ============================================ */

.loading,
.error-message,
.no-results {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
    font-size: 1.1rem;
}

.error-message {
    color: var(--mood-very-negative);
    background: var(--bg-secondary);
    border: 2px solid var(--mood-very-negative);
    border-radius: 8px;
}

.expiration-info {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* ============================================
   Tester Page Specific Styles
   ============================================ */

.test-container {
    max-width: 700px;
    margin: 0 auto;
}

.test-controls {
    text-align: center;
    margin: 30px 0;
}

.test-button,
.primary-button {
    background: var(--accent-primary);
    color: var(--bg-primary);
    border: none;
    padding: 15px 30px;
    font-size: 1.1rem;
    font-weight: bold;
    border-radius: 8px;
    cursor: pointer;
    transition: all var(--transition-speed);
}

.test-button:hover,
.primary-button:hover {
    background: var(--accent-secondary);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px var(--shadow);
}

.test-button:disabled,
.primary-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.test-results {
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    margin-top: 20px;
}

.test-step {
    padding: 15px;
    margin: 10px 0;
    border-left: 4px solid var(--border-color);
    background: var(--bg-tertiary);
    border-radius: 4px;
}

.test-step.success {
    border-left-color: var(--mood-very-positive);
}

.test-step.error {
    border-left-color: var(--mood-very-negative);
}

.test-step h3 {
    margin-bottom: 8px;
    color: var(--accent-secondary);
}

.test-step pre {
    background: var(--code-bg);
    padding: 10px;
    border-radius: 4px;
    overflow-x: auto;
    font-size: 0.85rem;
    margin-top: 8px;
}

.test-link {
    color: var(--accent-primary);
    word-break: break-all;
}

/* ============================================
   Responsive Design
   ============================================ */

@media (max-width: 768px) {
    body {
        padding: 15px;
    }

    h1 {
        font-size: 1.5rem;
    }

    .controls {
        flex-direction: column;
    }

    .sort-box {
        width: 100%;
    }

    .sort-box select {
        flex: 1;
    }

    .thought-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .thought-card {
        padding: 15px;
    }

    .theme-toggle {
        padding: 8px 12px;
        font-size: 1.2rem;
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 1.3rem;
    }

    .thought-content h1 { font-size: 1.4rem; }
    .thought-content h2 { font-size: 1.2rem; }
    .thought-content h3 { font-size: 1.1rem; }
}
