/* ========================================
   Persönliche Seite v3.1.0 - Mobile First
   ======================================== */

:root {
    --bg: #0f172a;
    --bg2: #1e293b;
    --bg3: #334155;
    --text: #f1f5f9;
    --muted: #94a3b8;
    --border: rgba(255,255,255,0.1);
    --accent: #4ecca3;
    --accent2: #3db892;
    --danger: #ef4444;
    --warning: #f59e0b;
    --success: #22c55e;
    --radius: 10px;
    --radius-lg: 16px;
}

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

html { 
    font-size: 16px; 
    -webkit-text-size-adjust: 100%;
}

body { 
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
}

/* ========================================
   Header
   ======================================== */
.header {
    position: sticky;
    top: 0;
    height: 56px;
    background: var(--bg2);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo {
    font-weight: 600;
    font-size: 1rem;
}

.nav {
    display: flex;
    gap: 0.25rem;
}

.nav a {
    color: var(--muted);
    text-decoration: none;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    font-size: 1rem;
}

.nav a:hover, .nav a.active { 
    background: var(--bg3); 
    color: var(--text); 
}

/* ========================================
   Main Content
   ======================================== */
.main-content {
    min-height: calc(100vh - 56px);
    min-height: calc(100dvh - 56px);
}

/* ========================================
   Buttons
   ======================================== */
.btn, .ts-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.75rem 1.25rem;
    font-size: 0.9rem;
    font-weight: 500;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    background: var(--bg3);
    color: var(--text);
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.btn:hover, .ts-btn:hover { background: var(--bg); }
.btn:active, .ts-btn:active { transform: scale(0.98); }

.btn-primary, .ts-btn-primary { background: var(--accent); color: var(--bg); }
.btn-primary:hover, .ts-btn-primary:hover { background: var(--accent2); }

.btn-danger, .ts-btn-danger { background: var(--danger); color: white; }

.btn-sm, .ts-btn-sm { padding: 0.5rem 0.875rem; font-size: 0.8rem; }

.ts-btn-icon {
    background: none;
    border: none;
    color: var(--muted);
    font-size: 1.25rem;
    padding: 0.5rem;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.ts-btn-icon:hover { color: var(--text); }
.ts-btn-icon:disabled { opacity: 0.3; }

.ts-btn-back {
    background: none;
    border: none;
    color: var(--accent);
    font-size: 1.75rem;
    font-weight: 300;
    padding: 0;
    cursor: pointer;
    line-height: 1;
    text-decoration: none;
}

/* ========================================
   Forms
   ======================================== */
.form-group { margin-bottom: 1rem; }
.form-group label { 
    display: block; 
    margin-bottom: 0.35rem; 
    font-size: 0.8rem; 
    color: var(--muted); 
}

.form-input, .form-select, .form-textarea,
.ts-modal input, .ts-modal textarea, .ts-modal select {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text);
    -webkit-appearance: none;
}

.form-input:focus, .ts-modal input:focus,
.form-textarea:focus, .ts-modal textarea:focus {
    outline: none;
    border-color: var(--accent);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

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

/* ========================================
   Toast
   ======================================== */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--success);
    color: white;
    padding: 0.875rem 1.5rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    z-index: 1000;
    opacity: 0;
    transition: all 0.3s;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast.error { background: var(--danger); }

/* ========================================
   Settings
   ======================================== */
.settings-container { 
    max-width: 600px; 
    margin: 0 auto; 
    padding: 1rem; 
}

.settings-card { 
    background: var(--bg2); 
    border-radius: var(--radius-lg); 
    padding: 1.25rem; 
    margin-bottom: 1rem; 
}

.settings-card h3 { 
    display: flex; 
    align-items: center; 
    gap: 0.5rem; 
    margin-bottom: 0.5rem; 
    font-size: 1rem;
    flex-wrap: wrap;
}

.settings-card p { 
    color: var(--muted); 
    font-size: 0.85rem; 
    margin-bottom: 0.75rem; 
}

.info-row { 
    display: flex; 
    justify-content: space-between; 
    padding: 0.625rem 0; 
    border-bottom: 1px solid var(--border); 
    font-size: 0.9rem; 
}
.info-row:last-child { border-bottom: none; }
.info-label { color: var(--muted); }

.toggle-row { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    padding: 0.5rem 0; 
}

.toggle { 
    position: relative; 
    width: 52px; 
    height: 28px; 
    flex-shrink: 0;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider { 
    position: absolute; 
    cursor: pointer; 
    inset: 0; 
    background: var(--bg3); 
    border-radius: 28px; 
    transition: 0.3s; 
}
.toggle-slider:before { 
    position: absolute; 
    content: ""; 
    height: 22px; 
    width: 22px; 
    left: 3px; 
    bottom: 3px; 
    background: var(--muted); 
    border-radius: 50%; 
    transition: 0.3s; 
}
.toggle input:checked + .toggle-slider { background: var(--accent); }
.toggle input:checked + .toggle-slider:before { 
    transform: translateX(24px); 
    background: white; 
}

.status-indicator { 
    font-size: 0.75rem; 
    padding: 0.25rem 0.625rem; 
    border-radius: 6px; 
}
.status-active { background: rgba(34,197,94,0.2); color: var(--success); }
.status-inactive { background: rgba(239,68,68,0.2); color: var(--danger); }

hr { border: none; border-top: 1px solid var(--border); margin: 1rem 0; }

/* Module Cards */
.module-card {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.875rem;
    background: var(--bg);
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
}
.module-icon { font-size: 1.5rem; }
.module-info { flex: 1; min-width: 0; }
.module-name { font-size: 0.95rem; font-weight: 500; }
.module-desc { font-size: 0.8rem; color: var(--muted); }

/* HTTPS Guide */
.https-status { 
    padding: 1rem; 
    border-radius: var(--radius); 
    margin-bottom: 1rem; 
}
.https-status.active { background: rgba(34,197,94,0.15); border: 1px solid rgba(34,197,94,0.3); }
.https-status.inactive { background: rgba(239,68,68,0.15); border: 1px solid rgba(239,68,68,0.3); }
.https-status h4 { font-size: 1rem; margin-bottom: 0.25rem; }
.https-status p { margin: 0; font-size: 0.85rem; }

.cloudflare-link { 
    display: inline-flex; 
    align-items: center; 
    gap: 0.5rem; 
    background: #f38020; 
    color: white; 
    padding: 0.625rem 1rem; 
    border-radius: var(--radius); 
    text-decoration: none; 
    font-weight: 500; 
    font-size: 0.9rem; 
    margin-bottom: 1rem;
}

.guide-steps { margin-top: 1rem; counter-reset: step; }
.guide-step { 
    position: relative; 
    padding: 0.875rem 1rem 0.875rem 3rem; 
    background: var(--bg3); 
    border-radius: var(--radius); 
    margin-bottom: 0.5rem; 
}
.guide-step::before { 
    counter-increment: step; 
    content: counter(step); 
    position: absolute; 
    left: 0.875rem; 
    top: 0.875rem; 
    width: 24px; 
    height: 24px; 
    background: var(--accent); 
    color: var(--bg); 
    border-radius: 50%; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    font-size: 0.75rem; 
    font-weight: 600; 
}
.guide-step h5 { font-size: 0.9rem; margin-bottom: 0.2rem; }
.guide-step p { font-size: 0.8rem; color: var(--muted); margin: 0; }
.guide-step code { 
    background: var(--bg); 
    padding: 0.15rem 0.5rem; 
    border-radius: 4px; 
    font-size: 0.8rem; 
}
.domain-box { 
    background: var(--bg); 
    padding: 0.25rem 0.5rem; 
    border-radius: 6px; 
    font-family: monospace; 
}

/* ========================================
   TEXTSCHMIEDE
   ======================================== */
.ts {
    height: calc(100vh - 56px);
    height: calc(100dvh - 56px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.ts-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Header */
.ts-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: var(--bg2);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.ts-header h1 {
    flex: 1;
    font-size: 1.1rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Content */
.ts-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    -webkit-overflow-scrolling: touch;
}

/* Cards */
.ts-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--bg2);
    border-radius: var(--radius-lg);
    margin-bottom: 0.75rem;
    cursor: pointer;
    transition: transform 0.15s, background 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.ts-card:hover { background: var(--bg3); }
.ts-card:active { transform: scale(0.98); }

.ts-card-icon {
    font-size: 2rem;
    flex-shrink: 0;
}

.ts-card-num {
    width: 32px;
    height: 32px;
    background: var(--bg3);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 600;
    flex-shrink: 0;
}

.ts-card-body {
    flex: 1;
    min-width: 0;
}

.ts-card-title {
    font-size: 1rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ts-card-meta {
    font-size: 0.8rem;
    color: var(--muted);
    margin-top: 0.15rem;
}

.ts-card-arrow {
    font-size: 1.5rem;
    color: var(--muted);
    flex-shrink: 0;
}

/* Empty State */
.ts-empty {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--muted);
}

.ts-empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.ts-empty p {
    margin-bottom: 1rem;
}

/* Tabs */
.ts-tabs {
    display: flex;
    background: var(--bg2);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.ts-tabs button {
    flex: 1;
    padding: 0.875rem;
    background: none;
    border: none;
    color: var(--muted);
    font-size: 0.9rem;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.ts-tabs button:hover { color: var(--text); }
.ts-tabs button.active { 
    color: var(--accent); 
    border-bottom-color: var(--accent); 
}

/* Wiki Sections */
.ts-wiki-section {
    background: var(--bg2);
    border-radius: var(--radius);
    margin-bottom: 0.75rem;
    overflow: hidden;
}

.ts-wiki-header {
    display: flex;
    align-items: center;
    padding: 1rem;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.ts-wiki-header span:first-child { flex: 1; font-weight: 500; }
.ts-wiki-count { 
    background: var(--bg3); 
    padding: 0.15rem 0.5rem; 
    border-radius: 10px; 
    font-size: 0.75rem; 
    margin-right: 0.5rem;
}
.ts-wiki-toggle { 
    color: var(--muted); 
    font-size: 1.25rem; 
    width: 24px; 
    text-align: center; 
}

.ts-wiki-content {
    padding: 0 1rem 1rem;
}

.ts-wiki-item {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem;
    background: var(--bg);
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
    cursor: pointer;
}

.ts-wiki-item:hover { background: var(--bg3); }
.ts-wiki-item strong { font-weight: 500; }
.ts-wiki-item span { color: var(--muted); font-size: 0.85rem; }

/* Editor Screen */
.ts-screen-editor {
    background: var(--bg);
}

.ts-header-editor {
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}

.ts-title-input {
    flex: 1;
    background: none;
    border: none;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    min-width: 0;
}

.ts-title-input:focus { outline: none; }

.ts-save-status {
    font-size: 1rem;
    width: 24px;
    text-align: center;
}

.ts-saved { color: var(--success); }
.ts-error { color: var(--danger); }

.ts-editor-wrap {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.ts-editor {
    flex: 1;
    border: none;
    background: var(--bg);
    color: var(--text);
    font-size: 1.05rem;
    line-height: 1.8;
    padding: 1.25rem;
    resize: none;
    -webkit-overflow-scrolling: touch;
}

.ts-editor:focus { outline: none; }

.ts-footer {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.625rem 1rem;
    background: var(--bg2);
    border-top: 1px solid var(--border);
    font-size: 0.8rem;
    color: var(--muted);
    flex-shrink: 0;
}

.ts-footer .ts-btn-icon {
    font-size: 1rem;
    padding: 0.25rem;
}

.ts-spacer { flex: 1; }

/* ========================================
   Modals
   ======================================== */
.ts-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.75);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 200;
    padding: 0;
}

@media (min-width: 600px) {
    .ts-modal-overlay {
        align-items: center;
        padding: 1rem;
    }
}

.ts-modal {
    background: var(--bg2);
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

@media (min-width: 600px) {
    .ts-modal {
        border-radius: var(--radius-lg);
    }
}

.ts-modal-sm { max-width: 360px; }

.ts-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.ts-modal-header h2 { font-size: 1.1rem; }
.ts-modal-header button { 
    background: none; 
    border: none; 
    color: var(--muted); 
    font-size: 1.5rem; 
    cursor: pointer; 
}

.ts-modal-body {
    padding: 1.25rem;
    overflow-y: auto;
    flex: 1;
}

.ts-modal-body label {
    display: block;
    font-size: 0.8rem;
    color: var(--muted);
    margin-bottom: 0.35rem;
    margin-top: 1rem;
}

.ts-modal-body label:first-child { margin-top: 0; }

.ts-modal-body input,
.ts-modal-body textarea {
    margin-bottom: 0;
}

.ts-modal-body textarea {
    resize: vertical;
    min-height: 80px;
}

.ts-modal-footer {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

[x-cloak] { display: none !important; }

/* Collapse animation helper */
[x-collapse] { overflow: hidden; }

/* ========================================
   Tasks Module
   ======================================== */
.module-tasks { padding: 1rem; }

.module-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.module-header h2 { font-size: 1.1rem; }

.header-actions { display: flex; gap: 0.5rem; }

.task-filters {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    overflow-x: auto;
    padding-bottom: 0.25rem;
}

.filter-btn {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    background: var(--bg2);
    border: none;
    border-radius: var(--radius);
    color: var(--muted);
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}

.filter-btn.active { background: var(--accent); color: var(--bg); }

.task-list { display: flex; flex-direction: column; gap: 0.5rem; }

.task-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: var(--bg2);
    border-radius: var(--radius);
    cursor: pointer;
}

.task-item .task-priority {
    width: 4px;
    height: 40px;
    border-radius: 2px;
    flex-shrink: 0;
}

.priority-low { background: var(--success); }
.priority-medium { background: var(--warning); }
.priority-high { background: var(--danger); }

.task-item .task-content { flex: 1; min-width: 0; }
.task-item .task-title { font-size: 0.95rem; }
.task-item .task-meta { 
    display: flex; 
    gap: 0.5rem; 
    margin-top: 0.25rem; 
    flex-wrap: wrap; 
}

.task-status {
    font-size: 0.7rem;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    background: var(--bg3);
}

.status-todo { color: var(--muted); }
.status-inprogress { color: var(--warning); background: rgba(245,158,11,0.2); }
.status-done { color: var(--success); background: rgba(34,197,94,0.2); }

.task-category {
    font-size: 0.7rem;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    color: white;
}

.task-actions { flex-shrink: 0; }

/* Kanban Board - Default hidden on mobile */
.kanban-board {
    display: none;
}

/* Desktop Kanban */
@media (min-width: 900px) {
    .kanban-board {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 1rem;
        padding: 1rem;
        min-height: calc(100vh - 200px);
    }
    
    .kanban-column {
        background: var(--bg2);
        border-radius: var(--radius-lg);
        display: flex;
        flex-direction: column;
    }
    
    .column-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 1rem;
        border-bottom: 1px solid var(--border);
        font-weight: 600;
    }
    
    .badge {
        background: var(--bg3);
        padding: 0.15rem 0.5rem;
        border-radius: 10px;
        font-size: 0.75rem;
    }
    
    .column-tasks {
        flex: 1;
        padding: 0.75rem;
        overflow-y: auto;
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .task-card {
        background: var(--bg);
        border-radius: var(--radius);
        padding: 0.875rem;
        padding-left: 1rem;
        cursor: pointer;
        position: relative;
        transition: background 0.2s;
    }
    
    .task-card:hover {
        background: var(--bg3);
    }
    
    .task-card .task-priority {
        position: absolute;
        left: 0;
        top: 0;
        bottom: 0;
        width: 4px;
        border-radius: var(--radius) 0 0 var(--radius);
    }
    
    .task-card .task-title {
        font-size: 0.9rem;
        margin-bottom: 0.35rem;
    }
    
    .task-card .task-meta {
        display: flex;
        gap: 0.5rem;
        flex-wrap: wrap;
    }
    
    .task-date {
        font-size: 0.7rem;
        color: var(--muted);
    }
    
    /* Hide mobile list on desktop */
    .task-list.mobile-only {
        display: none !important;
    }
}

/* Modal generisch */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.75);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 200;
}

@media (min-width: 600px) {
    .modal-overlay {
        align-items: center;
        padding: 1rem;
    }
}

.modal {
    background: var(--bg2);
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    overflow-y: auto;
}

@media (min-width: 600px) {
    .modal { border-radius: var(--radius-lg); }
}

.modal-sm { max-width: 360px; }

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 { font-size: 1.05rem; }

.btn-close {
    background: none;
    border: none;
    color: var(--muted);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
}

.modal-body { padding: 1.25rem; }
.modal-footer {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border);
}

.spacer { flex: 1; }

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--muted);
}

/* Category form */
.category-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    border-radius: var(--radius);
}
.category-color { width: 18px; height: 18px; border-radius: 4px; }
.category-name { flex: 1; }

.category-form { display: flex; gap: 0.5rem; align-items: center; }
.color-picker { width: 40px; height: 40px; border: none; border-radius: var(--radius); cursor: pointer; }

/* Desktop nav visible */
@media (min-width: 600px) {
    .nav a { font-size: 0.9rem; }
}

/* Mobile only / Desktop only */
.mobile-only { display: block; }
.desktop-only { display: none; }

@media (min-width: 900px) {
    .mobile-only { display: none !important; }
    .desktop-only { display: block; }
}
