/* Hausmeister ToDo – mobile-first, graues Design */

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

:root {
    --bg: #e8e8e8;
    --bg-card: #f5f5f5;
    --bg-input: #fff;
    --text: #333;
    --text-muted: #777;
    --border: #ccc;
    --primary: #555;
    --primary-hover: #444;
    --danger: #b33;
    --danger-hover: #922;
    --status-offen: #4a7c59;
    --status-bearbeitung: #b8860b;
    --status-geschlossen: #888;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,.12);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100dvh;
    padding-bottom: calc(1rem + var(--safe-bottom));
}

a {
    color: inherit;
    text-decoration: none;
}

/* Login */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100dvh;
    padding: 1rem;
}

.login-box {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2rem 1.5rem;
    width: 100%;
    max-width: 360px;
}

.login-box h1 {
    font-size: 1.25rem;
    text-align: center;
    margin-bottom: 1.5rem;
    color: var(--primary);
}

/* Toolbar (Index) */
.toolbar {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .75rem;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}

.search-form {
    flex: 1;
}

.search-form input[type="search"] {
    width: 100%;
    padding: .6rem .75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-input);
    font-size: 1rem;
    -webkit-appearance: none;
}

.btn-add {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: var(--primary);
    color: #fff;
    border-radius: var(--radius);
    font-size: 1.75rem;
    font-weight: 300;
    line-height: 1;
    flex-shrink: 0;
}

.btn-add:active {
    background: var(--primary-hover);
}

/* Todo list */
.todo-list {
    padding: 0;
}

.status-divider {
    padding: .5rem .75rem .25rem;
    font-size: .75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-muted);
    background: var(--bg);
}

.todo-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: .85rem .75rem;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    -webkit-tap-highlight-color: transparent;
}

.todo-item:active {
    background: #ddd;
}

.todo-name {
    font-size: 1rem;
    font-weight: 500;
}

.todo-date {
    font-size: .8rem;
    color: var(--text-muted);
    flex-shrink: 0;
    margin-left: .75rem;
}

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

/* Page header (subpages) */
.page-header {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .75rem;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}

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

.back-link {
    font-size: 1.25rem;
    padding: .25rem .5rem;
    color: var(--primary);
}

.container {
    padding: .75rem;
    max-width: 640px;
    margin: 0 auto;
}

/* Forms */
.form-card, .detail-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1rem;
    margin-bottom: .75rem;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: .85rem;
    font-weight: 600;
    margin-bottom: .35rem;
    color: var(--text-muted);
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="search"],
.form-group textarea,
.note-form textarea {
    width: 100%;
    padding: .65rem .75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-input);
    font-size: 1rem;
    font-family: inherit;
    -webkit-appearance: none;
}

.form-group textarea,
.note-form textarea {
    resize: vertical;
    min-height: 80px;
}

.hint {
    font-size: .8rem;
    color: var(--text-muted);
    margin-top: .25rem;
}

.file-input {
    width: 100%;
    font-size: .9rem;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: .7rem 1.25rem;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-family: inherit;
    cursor: pointer;
    text-align: center;
    -webkit-appearance: none;
}

.btn-block {
    display: block;
    width: 100%;
}

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

.btn-primary:active {
    background: var(--primary-hover);
}

.btn-secondary {
    background: #ddd;
    color: var(--text);
    margin-top: .5rem;
}

.btn-secondary:active {
    background: #ccc;
}

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

.btn-danger:active {
    background: var(--danger-hover);
}

.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    font-size: 1.25rem;
    color: var(--primary);
    border-radius: var(--radius);
}

.btn-icon:active {
    background: #ddd;
}

/* Alerts */
.alert {
    padding: .75rem;
    border-radius: var(--radius);
    margin-bottom: .75rem;
    font-size: .9rem;
}

.alert-error {
    background: #fdd;
    color: var(--danger);
    border: 1px solid #faa;
}

/* Detail view */
.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: .5rem;
}

.detail-title {
    font-size: 1.15rem;
    font-weight: 600;
}

.detail-meta {
    font-size: .85rem;
    color: var(--text-muted);
    margin-top: .15rem;
}

.detail-section {
    margin-top: 1rem;
}

.detail-section h3,
.detail-card > h3 {
    font-size: .8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-muted);
    margin-bottom: .5rem;
}

.detail-text {
    font-size: .95rem;
    white-space: pre-wrap;
}

/* Photos */
.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: .5rem;
}

.photo-thumb {
    display: block;
    border-radius: var(--radius);
    overflow: hidden;
    aspect-ratio: 1;
}

.photo-thumb img,
.photo-grid img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.photo-grid-edit label {
    position: relative;
    border-radius: var(--radius);
    overflow: hidden;
    aspect-ratio: 1;
}

.photo-delete-label img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.delete-check {
    display: block;
    text-align: center;
    font-size: .75rem;
    padding: .25rem;
    background: #eee;
}

/* Status buttons */
.status-buttons {
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
}

.status-btn {
    flex: 1;
    min-width: 0;
    padding: .55rem .5rem;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-input);
    font-size: .8rem;
    font-family: inherit;
    cursor: pointer;
    -webkit-appearance: none;
}

.status-btn.active {
    font-weight: 600;
}

.status-offen.active {
    border-color: var(--status-offen);
    background: #e8f0ea;
    color: var(--status-offen);
}

.status-in-bearbeitung.active {
    border-color: var(--status-bearbeitung);
    background: #fdf6e3;
    color: var(--status-bearbeitung);
}

.status-geschlossen.active {
    border-color: var(--status-geschlossen);
    background: #eee;
    color: var(--status-geschlossen);
}

/* Timeline */
.timeline-day {
    margin-bottom: 1rem;
}

.timeline-date {
    font-size: .85rem;
    font-weight: 600;
    color: var(--primary);
    padding: .5rem 0 .35rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: .5rem;
}

.timeline-note,
.timeline-photo {
    padding: .5rem 0;
}

.timeline-time {
    font-size: .75rem;
    color: var(--text-muted);
}

.timeline-note p {
    margin-top: .15rem;
    font-size: .95rem;
}

.timeline-status {
    padding: .5rem 0;
}

.timeline-status p {
    margin-top: .15rem;
    font-size: .95rem;
}

.timeline-status-offen strong { color: var(--status-offen); }
.timeline-status-in-bearbeitung strong { color: var(--status-bearbeitung); }
.timeline-status-geschlossen strong { color: var(--status-geschlossen); }

.timeline-photo img {
    max-width: 100%;
    border-radius: var(--radius);
    margin-top: .25rem;
}

.add-entry {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.photo-form {
    margin-top: .75rem;
}

.danger-zone {
    margin-top: 1.5rem;
}

/* Photo preview */
.photo-preview {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    margin-top: .5rem;
}

.photo-preview img {
    width: 72px;
    height: 72px;
    object-fit: cover;
    border-radius: var(--radius);
}

/* Desktop tweaks */
@media (min-width: 640px) {
    .toolbar, .page-header {
        padding: .75rem 1.5rem;
    }

    .todo-list, .container {
        max-width: 640px;
        margin-left: auto;
        margin-right: auto;
    }

    .todo-item {
        border-radius: var(--radius);
        margin: .25rem .75rem;
        border: 1px solid var(--border);
    }

    .status-divider {
        max-width: 640px;
        margin: 0 auto;
        padding-left: 1.5rem;
    }
}
