/* ── TIMEaTRON Styles ────────────────────────────────── */
/* Täglicher Aktivitäts-Tracker — Dark Theme             */
/* ─────────────────────────────────────────────────────── */

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

:root {
    --bg: #0d0d1a;
    --bg-card: #16162a;
    --bg-card-hover: #1c1c36;
    --bg-running: #151a2e;
    --accent: #6c63ff;
    --accent-hover: #5a52d5;
    --accent-glow: rgba(108, 99, 255, 0.25);
    --green: #4ade80;
    --green-glow: rgba(74, 222, 128, 0.3);
    --red: #ef4444;
    --red-hover: #dc2626;
    --text: #e2e8f0;
    --text-muted: #94a3b8;
    --text-dim: #64748b;
    --border: #2a2a45;
    --radius: 14px;
    --radius-sm: 8px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
    --transition: 0.2s ease;
}

html {
    font-size: 16px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* ── Layout ──────────────────────────────────────────── */
.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 24px 16px 48px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ── Header ───────────────────────────────────────────── */
header {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

/* Date Navigation */
.date-nav {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
}

.date-nav button {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    padding: 6px 12px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all var(--transition);
}

.date-nav button:hover {
    background: var(--bg-card-hover);
    color: var(--text);
    border-color: var(--accent);
}

.date-nav button:active {
    transform: scale(0.96);
}

#date-display {
    flex: 1;
    text-align: center;
    font-weight: 600;
    font-size: 1rem;
    color: var(--text);
    letter-spacing: 0.01em;
}

#date-picker {
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    font-size: 0.85rem;
    cursor: pointer;
    outline: none;
    transition: border-color var(--transition);
}

#date-picker:focus {
    border-color: var(--accent);
}

#date-picker::-webkit-calendar-picker-indicator {
    filter: invert(0.7);
    cursor: pointer;
}

/* Timer Section */
.timer-section {
    text-align: center;
    padding: 16px 0;
    margin-bottom: 16px;
}

#timer-display {
    font-size: 3.2rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.04em;
    color: var(--text-dim);
    transition: color 0.3s ease;
}

#timer-display.running {
    color: var(--green);
    text-shadow: 0 0 40px var(--green-glow);
}

#timer-label {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-top: 4px;
    min-height: 1.4em;
}

/* Header Actions */
.header-actions {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
}

.header-actions button {
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    border: none;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}

#btn-add {
    background: var(--accent);
    color: #fff;
}

#btn-add:hover {
    background: var(--accent-hover);
    box-shadow: 0 0 20px var(--accent-glow);
}

#btn-export,
#btn-import {
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text-muted);
}

#btn-export:hover,
#btn-import:hover {
    background: var(--bg-card-hover);
    color: var(--text);
    border-color: var(--text-dim);
}

.header-actions button:active {
    transform: scale(0.97);
}

/* ── Activity List ────────────────────────────────────── */
#activity-list {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.empty-state {
    text-align: center;
    color: var(--text-dim);
    padding: 48px 24px;
    font-size: 1.05rem;
    line-height: 1.8;
}

.empty-state strong {
    color: var(--accent);
}

/* Activity Card */
.activity-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    transition: all var(--transition);
}

.activity-card:hover {
    background: var(--bg-card-hover);
    border-color: #3a3a5a;
}

.activity-card.running {
    background: var(--bg-running);
    border-color: var(--green);
    box-shadow: 0 0 20px var(--green-glow), inset 0 0 20px rgba(74, 222, 128, 0.03);
    animation: pulse-border 2s ease-in-out infinite;
}

@keyframes pulse-border {
    0%, 100% { border-color: var(--green); }
    50% { border-color: rgba(74, 222, 128, 0.4); }
}

/* Activity Header */
.activity-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.activity-status {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--text-dim);
    flex-shrink: 0;
    transition: background 0.3s ease;
}

.activity-status.active {
    background: var(--green);
    box-shadow: 0 0 10px var(--green-glow);
    animation: blink 1.5s ease-in-out infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.activity-name {
    flex: 1;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.activity-time {
    font-size: 1.2rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--text-muted);
    flex-shrink: 0;
}

.activity-card.running .activity-time {
    color: var(--green);
}

/* Activity Description (Markdown) */
.activity-description {
    padding: 12px 16px;
    margin-bottom: 12px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.7;
    max-height: 200px;
    overflow-y: auto;
    cursor: text;
    transition: border-color var(--transition);
}

.activity-description:hover {
    border-color: #3a3a5a;
}

.activity-description .no-desc {
    color: var(--text-dim);
    font-style: italic;
}

/* Inline edit: textarea + live preview (split) */
.inline-edit-overlay {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.inline-edit-textarea {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg);
    border: 1px solid var(--accent);
    border-radius: 6px 6px 0 0;
    color: var(--text);
    caret-color: var(--accent);
    font-family: 'Cascadia Code', 'Fira Code', 'JetBrains Mono', 'Consolas', monospace;
    font-size: 0.85rem;
    line-height: 1.6;
    resize: none;
    overflow-y: auto;
    outline: none;
    box-shadow: 0 0 0 3px var(--accent-glow);
    min-height: 60px;
    max-height: 300px;
}

.inline-edit-textarea::selection {
    background: rgba(108, 99, 255, 0.3);
    color: var(--text);
}

.inline-edit-preview {
    padding: 10px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-top: 1px dashed var(--border);
    border-radius: 0 0 6px 6px;
    font-size: 0.9rem;
    line-height: 1.7;
    min-height: 40px;
    max-height: 250px;
    overflow-y: auto;
    color: var(--text-muted);
}

/* Markdown body styles */
.markdown-body h1, .markdown-body h2, .markdown-body h3 {
    color: var(--text);
    margin-top: 8px;
    margin-bottom: 4px;
}

.markdown-body h1 { font-size: 1.2rem; }
.markdown-body h2 { font-size: 1.1rem; }
.markdown-body h3 { font-size: 1rem; }

.markdown-body p {
    margin-bottom: 6px;
}

.markdown-body ul, .markdown-body ol {
    padding-left: 20px;
    margin-bottom: 6px;
}

.markdown-body li {
    margin-bottom: 2px;
}

.markdown-body code {
    background: var(--bg-card);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.85em;
    color: var(--accent);
}

.markdown-body pre {
    background: var(--bg-card);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    margin-bottom: 6px;
}

.markdown-body pre code {
    background: none;
    padding: 0;
}

.markdown-body strong {
    color: var(--text);
}

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

.markdown-body a:hover {
    text-decoration: underline;
}

.markdown-body blockquote {
    border-left: 3px solid var(--accent);
    padding-left: 12px;
    color: var(--text-dim);
    margin-bottom: 6px;
}

/* Activity Actions */
.activity-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.activity-actions button {
    padding: 7px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text-muted);
    font-size: 0.82rem;
    cursor: pointer;
    transition: all var(--transition);
}

.activity-actions button:hover {
    background: var(--bg-card-hover);
    color: var(--text);
}

.btn-timer-start {
    border-color: var(--green) !important;
    color: var(--green) !important;
    font-weight: 600;
}

.btn-timer-start:hover {
    background: rgba(74, 222, 128, 0.1) !important;
    box-shadow: 0 0 12px rgba(74, 222, 128, 0.15);
}

.btn-timer-stop {
    border-color: var(--red) !important;
    color: var(--red) !important;
    font-weight: 600;
}

.btn-timer-stop:hover {
    background: rgba(239, 68, 68, 0.1) !important;
    box-shadow: 0 0 12px rgba(239, 68, 68, 0.15);
}

.btn-delete-act {
    margin-left: auto;
    border-color: transparent !important;
    color: var(--text-dim) !important;
    padding: 7px 10px !important;
}

.btn-delete-act:hover {
    color: var(--red) !important;
    background: rgba(239, 68, 68, 0.1) !important;
    border-color: rgba(239, 68, 68, 0.3) !important;
}

/* ── Footer ───────────────────────────────────────────── */
footer {
    margin-top: 20px;
    padding: 14px 20px;
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-dim);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

/* ── Modals ───────────────────────────────────────────── */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.65);
    z-index: 100;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.modal-overlay.visible {
    display: flex;
    animation: fade-in 0.2s ease;
}

@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    width: 90%;
    max-width: 520px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.5);
    animation: slide-up 0.25s ease;
}

.modal-small {
    max-width: 400px;
}

@keyframes slide-up {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal h2 {
    font-size: 1.25rem;
    margin-bottom: 16px;
    color: var(--text);
}

.modal p {
    color: var(--text-muted);
    margin-bottom: 16px;
    font-size: 0.9rem;
    line-height: 1.6;
}

.modal label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

.label-hint {
    color: var(--text-dim);
    font-weight: 400;
    font-size: 0.8rem;
}

.modal input[type="text"],
.modal textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 0.95rem;
    font-family: inherit;
    outline: none;
    transition: border-color var(--transition);
    margin-bottom: 14px;
}

.modal input[type="text"]:focus,
.modal textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.modal input.error {
    border-color: var(--red);
    animation: shake 0.4s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-6px); }
    75% { transform: translateX(6px); }
}

.modal textarea {
    resize: vertical;
    min-height: 100px;
}

.modal .file-label {
    display: inline-block;
    padding: 10px 18px;
    background: var(--bg);
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.9rem;
    transition: all var(--transition);
}

.modal .file-label:hover {
    border-color: var(--accent);
    color: var(--text);
}

.modal input[type="file"] {
    width: 100%;
    margin-top: 10px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.modal input[type="file"]::file-selector-button {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    padding: 6px 14px;
    cursor: pointer;
    margin-right: 10px;
    transition: all var(--transition);
}

.modal input[type="file"]::file-selector-button:hover {
    background: var(--bg-card-hover);
}

/* Modal Action Buttons */
.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 8px;
}

.modal-actions button {
    padding: 9px 20px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all var(--transition);
}

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

.btn-primary:hover {
    background: var(--accent-hover);
    box-shadow: 0 0 20px var(--accent-glow);
}

.btn-secondary {
    background: var(--bg);
    border: 1px solid var(--border) !important;
    color: var(--text-muted);
}

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

.btn-danger {
    background: var(--red);
    color: #fff;
}

.btn-danger:hover {
    background: var(--red-hover);
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.3);
}

/* ── Scrollbar ────────────────────────────────────────── */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

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

/* ── Responsive ───────────────────────────────────────── */
@media (max-width: 600px) {
    .container {
        padding: 12px 8px 32px;
    }

    header {
        padding: 16px;
        border-radius: var(--radius-sm);
    }

    #timer-display {
        font-size: 2.4rem;
    }

    .header-actions button {
        padding: 8px 14px;
        font-size: 0.82rem;
    }

    .date-nav {
        gap: 4px;
    }

    .date-nav button {
        padding: 5px 8px;
        font-size: 0.8rem;
    }

    #date-display {
        font-size: 0.85rem;
    }

    .activity-card {
        padding: 14px;
    }

    .activity-name {
        font-size: 0.95rem;
    }

    .activity-time {
        font-size: 1rem;
    }

    .modal {
        padding: 20px;
        width: 95%;
    }
}

/* ── Print ────────────────────────────────────────────── */
@media print {
    body {
        background: #fff;
        color: #000;
    }

    header, footer, .activity-actions, .modal-overlay {
        display: none !important;
    }

    .activity-card {
        border: 1px solid #ccc;
        break-inside: avoid;
    }
}
