/* MyLink – mobile-first, responsives Design */

:root {
    --bg: #0f172a;
    --surface: #16213a;
    --surface-2: #1c2b4a;
    --text: #eef1f8;
    --text-muted: #9aa5c0;
    --accent: #4f8cff;
    --accent-2: #3a6fe0;
    --danger: #e5484d;
    --danger-2: #c53d41;
    --border: #263457;
    --radius: 12px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

a { color: var(--accent); text-decoration: none; }
a:active { opacity: 0.8; }

.app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ---------- Topbar ---------- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: calc(var(--safe-top) + 10px) 14px 10px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.brand {
    font-weight: 700;
    font-size: 1.15rem;
    color: var(--text);
    flex: 1;
}

.icon-btn {
    background: none;
    border: none;
    color: var(--text);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
}
.icon-btn:active { background: var(--surface-2); }

.hamburger, .hamburger::before, .hamburger::after {
    content: "";
    display: block;
    width: 20px;
    height: 2px;
    background: var(--text);
    border-radius: 2px;
}
.hamburger { position: relative; }
.hamburger::before { position: absolute; top: -6px; }
.hamburger::after { position: absolute; top: 6px; }

.top-nav {
    display: none;
    gap: 18px;
    align-items: center;
}
.top-nav a { color: var(--text-muted); font-size: 0.95rem; }
.top-nav a.active { color: var(--accent); }
.top-nav a.logout { color: var(--danger); }

/* ---------- Layout / Drawer ---------- */
.layout {
    flex: 1;
    display: flex;
    position: relative;
}

.theme-drawer {
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    width: 82%;
    max-width: 320px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    z-index: 40;
    padding-top: var(--safe-top);
    overflow-y: auto;
}
.theme-drawer.open { transform: translateX(0); }

.theme-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    font-weight: 600;
    border-bottom: 1px solid var(--border);
}
.close-btn { font-size: 1.4rem; line-height: 1; }

.theme-list { list-style: none; margin: 0; padding: 8px; }
.theme-list li a {
    display: block;
    padding: 12px 12px;
    border-radius: 8px;
    color: var(--text);
}
.theme-list li a.active { background: var(--accent); color: #fff; }
.theme-list li a:active { background: var(--surface-2); }
.theme-empty { color: var(--text-muted); padding: 12px; }

.drawer-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
    z-index: 30;
}
.drawer-backdrop.open { opacity: 1; pointer-events: auto; }

.content {
    flex: 1;
    width: 100%;
    padding: 18px 16px calc(24px + var(--safe-bottom));
    max-width: 720px;
    margin: 0 auto;
}

.page-title { font-size: 1.3rem; margin: 4px 0 16px; }
.hint { color: var(--text-muted); }

/* ---------- Alerts ---------- */
.alert {
    padding: 12px 14px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 0.95rem;
}
.alert-error { background: rgba(229,72,77,0.15); color: #ff9a9d; border: 1px solid rgba(229,72,77,0.4); }
.alert-success { background: rgba(79,140,255,0.15); color: #9dc0ff; border: 1px solid rgba(79,140,255,0.4); }

/* ---------- Link list ---------- */
.link-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.link-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
}
.link-main {
    min-width: 0;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}
.link-favicon {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    border-radius: 5px;
    margin-top: 2px;
    background: var(--surface-2);
    object-fit: contain;
}
.link-text { min-width: 0; }
.link-name { font-weight: 600; word-break: break-word; }
.link-comment { margin: 4px 0 0; color: var(--text-muted); font-size: 0.88rem; }
.link-actions {
    /* Auf schmalen Screens (iPhone) bewusst ausgeblendet - Bearbeiten/Loeschen
       gibt es dort nicht, nur am Desktop (siehe Media Query unten). */
    display: none;
}

.btn-small {
    display: inline-block;
    padding: 8px 10px;
    border-radius: 8px;
    background: var(--surface-2);
    color: var(--text);
    font-size: 0.85rem;
    border: none;
}
.btn-danger { background: rgba(229,72,77,0.18); color: #ff9a9d; }
.inline-form { display: inline; }

/* ---------- Forms ---------- */
.link-form, .login-card form {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.link-form label { margin-top: 10px; font-size: 0.88rem; color: var(--text-muted); }
.link-form input,
.login-card input {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 12px 12px;
    border-radius: 10px;
    font-size: 1rem;
    width: 100%;
}
.link-form input:focus, .login-card input:focus {
    outline: none;
    border-color: var(--accent);
}

.btn-primary {
    margin-top: 18px;
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 13px;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
}
.btn-primary:active { background: var(--accent-2); }

/* ---------- Login ---------- */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 16px;
}
.login-card {
    width: 100%;
    max-width: 360px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 32px 24px;
    text-align: center;
}
.login-card h1 { margin: 0 0 4px; }
.login-card .subtitle { color: var(--text-muted); margin: 0 0 20px; }
.login-card button {
    margin-top: 14px;
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 13px;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    width: 100%;
}
.sr-only {
    position: absolute;
    width: 1px; height: 1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
}

/* ---------- Desktop / grosse Screens ---------- */
@media (min-width: 860px) {
    .icon-btn#menuToggle { display: none; }
    .top-nav { display: flex; }
    .theme-drawer {
        position: sticky;
        top: 57px;
        transform: none;
        width: 240px;
        max-width: none;
        height: calc(100vh - 57px);
        border-right: 1px solid var(--border);
        flex-shrink: 0;
    }
    .close-btn { display: none; }
    .drawer-backdrop { display: none; }
    .layout { align-items: flex-start; }
    .content { padding: 28px 32px; max-width: 760px; }

    /* Bearbeiten/Loeschen gibt es nur am Desktop, dort wieder neben den Eintrag */
    .link-item {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }
    .link-actions {
        display: flex;
        gap: 8px;
        flex-shrink: 0;
    }
}
