/* ── Reset & Base ────────────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; }

html, body {
    height: 100%;
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans",
                 Helvetica, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--gh-fg-default);
    background: var(--gh-canvas-default);
}

/* ── GitHub Design Tokens (Light) ────────────────────────────────────────── */

:root {
    --gh-header-bg:        #24292f;
    --gh-header-fg:        #f0f6fc;
    --gh-header-fg-muted:  #8b949e;
    --gh-header-hover:     rgba(255,255,255,0.1);

    --gh-canvas-default:   #ffffff;
    --gh-canvas-subtle:    #f6f8fa;
    --gh-canvas-inset:     #f0f2f4;

    --gh-fg-default:       #1f2328;
    --gh-fg-muted:         #636c76;
    --gh-fg-subtle:        #6e7781;
    --gh-fg-onEmphasis:    #ffffff;

    --gh-border-default:   #d0d7de;
    --gh-border-muted:     #d8dee4;
    --gh-border-subtle:    rgba(31,35,40,.15);

    --gh-accent-fg:        #0969da;
    --gh-accent-emphasis:  #0969da;
    --gh-accent-subtle:    #ddf4ff;

    --gh-success-fg:       #1a7f37;
    --gh-success-emphasis: #1f883d;
    --gh-success-subtle:   #dafbe1;

    --gh-danger-fg:        #d1242f;
    --gh-danger-emphasis:  #cf222e;
    --gh-danger-subtle:    #ffebe9;

    --gh-open-dot:         #1a7f37;
    --gh-closed-dot:       #8250df;

    --gh-shadow-small:     0 1px 0 rgba(31,35,40,.04);
    --gh-shadow-medium:    0 3px 6px rgba(140,149,159,.15);
    --gh-radius:           6px;
}

/* Dark mode override */
@media (prefers-color-scheme: dark) {
    :root {
        --gh-header-bg:        #161b22;

        --gh-canvas-default:   #0d1117;
        --gh-canvas-subtle:    #161b22;
        --gh-canvas-inset:     #010409;

        --gh-fg-default:       #e6edf3;
        --gh-fg-muted:         #7d8590;
        --gh-fg-subtle:        #6e7681;

        --gh-border-default:   #30363d;
        --gh-border-muted:     #21262d;
        --gh-border-subtle:    rgba(240,246,252,.1);

        --gh-accent-fg:        #2f81f7;
        --gh-accent-subtle:    rgba(56,139,253,.1);

        --gh-success-fg:       #3fb950;
        --gh-success-subtle:   rgba(63,185,80,.1);

        --gh-danger-fg:        #f85149;
        --gh-danger-subtle:    rgba(248,81,73,.1);

        --gh-open-dot:         #3fb950;
        --gh-closed-dot:       #a371f7;

        --gh-shadow-small:     0 0 transparent;
        --gh-shadow-medium:    0 3px 6px #010409;
    }
}

/* Dark forced via FluentUI toggle */
[data-theme="dark"] {
    --gh-header-bg:        #161b22;
    --gh-canvas-default:   #0d1117;
    --gh-canvas-subtle:    #161b22;
    --gh-canvas-inset:     #010409;
    --gh-fg-default:       #e6edf3;
    --gh-fg-muted:         #7d8590;
    --gh-fg-subtle:        #6e7681;
    --gh-border-default:   #30363d;
    --gh-border-muted:     #21262d;
    --gh-border-subtle:    rgba(240,246,252,.1);
    --gh-accent-fg:        #2f81f7;
    --gh-accent-subtle:    rgba(56,139,253,.1);
    --gh-success-fg:       #3fb950;
    --gh-success-subtle:   rgba(63,185,80,.1);
    --gh-danger-fg:        #f85149;
    --gh-danger-subtle:    rgba(248,81,73,.1);
    --gh-open-dot:         #3fb950;
    --gh-closed-dot:       #a371f7;
}

/* ── Header ──────────────────────────────────────────────────────────────── */

.gh-header {
    background: var(--gh-header-bg);
    padding: 0;
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid rgba(255,255,255,.1);
}

.gh-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 16px;
    height: 48px;
}

.gh-header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.gh-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.gh-logo-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: var(--gh-radius);
    color: var(--gh-header-fg);
    transition: background 0.12s ease;
    text-decoration: none;
}

.gh-logo-btn:hover {
    background: var(--gh-header-hover);
}

.gh-logo-icon {
    width: 32px;
    height: 32px;
    fill: var(--gh-header-fg);
    flex-shrink: 0;
}

.gh-logo-text {
    font-size: 15px;
    font-weight: 600;
    color: var(--gh-header-fg);
    white-space: nowrap;
}

.gh-icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: none;
    border: none;
    cursor: pointer;
    border-radius: var(--gh-radius);
    color: var(--gh-header-fg-muted);
    transition: color 0.12s ease, background 0.12s ease;
}

.gh-icon-btn:hover {
    color: var(--gh-header-fg);
    background: var(--gh-header-hover);
}

.gh-icon-btn svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

/* ── Main Content ────────────────────────────────────────────────────────── */

.gh-main {
    max-width: 1280px;
    margin: 0 auto;
    padding: 24px 16px;
}

/* ── Page Header (Seitentitel-Zeile) ─────────────────────────────────────── */

.gh-page-header {
    padding-bottom: 16px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--gh-border-default);
}

.gh-page-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--gh-fg-default);
    margin: 0;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */

.gh-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    font-size: 14px;
    font-weight: 500;
    line-height: 20px;
    border-radius: var(--gh-radius);
    border: 1px solid;
    cursor: pointer;
    transition: background 0.12s ease;
    text-decoration: none;
}

.gh-btn--default {
    background: var(--gh-canvas-subtle);
    border-color: var(--gh-border-default);
    color: var(--gh-fg-default);
}

.gh-btn--default:hover {
    background: var(--gh-border-muted);
}

.gh-btn--primary {
    background: var(--gh-success-emphasis);
    border-color: rgba(31,35,40,.15);
    color: var(--gh-fg-onEmphasis);
}

.gh-btn--primary:hover {
    background: #1a7f37;
}

.gh-btn--danger {
    background: var(--gh-danger-subtle);
    border-color: var(--gh-border-default);
    color: var(--gh-danger-fg);
}

/* ── Box / Card ──────────────────────────────────────────────────────────── */

.gh-box {
    border: 1px solid var(--gh-border-default);
    border-radius: var(--gh-radius);
    background: var(--gh-canvas-default);
}

.gh-box-header {
    padding: 16px;
    border-bottom: 1px solid var(--gh-border-default);
    background: var(--gh-canvas-subtle);
    border-radius: var(--gh-radius) var(--gh-radius) 0 0;
    font-weight: 600;
    font-size: 14px;
}

.gh-box-body {
    padding: 16px;
}

/* ── Projekt-Grid ────────────────────────────────────────────────────────── */

.project-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
}

.project-card {
    border: 1px solid var(--gh-border-default);
    border-radius: var(--gh-radius);
    padding: 16px;
    background: var(--gh-canvas-default);
    cursor: pointer;
    transition: box-shadow 0.12s ease, border-color 0.12s ease;
    box-shadow: var(--gh-shadow-small);
}

.project-card:hover {
    border-color: var(--gh-accent-fg);
    box-shadow: var(--gh-shadow-medium);
}

.project-card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--gh-accent-fg);
    margin: 0 0 4px 0;
}

.project-card-repo {
    font-size: 12px;
    color: var(--gh-fg-muted);
}

/* ── Issues Layout ───────────────────────────────────────────────────────── */

.issues-layout {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 16px;
    align-items: start;
}

/* Issue List (GitHub-Stil: Box mit Zeilen) */
.issues-box {
    border: 1px solid var(--gh-border-default);
    border-radius: var(--gh-radius);
    background: var(--gh-canvas-default);
    overflow: hidden;
}

.issues-box-header {
    padding: 12px 16px;
    background: var(--gh-canvas-subtle);
    border-bottom: 1px solid var(--gh-border-default);
    font-weight: 600;
    font-size: 14px;
    color: var(--gh-fg-default);
}

.issue-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--gh-border-muted);
    cursor: pointer;
    transition: background 0.1s ease;
}

.issue-row:last-child {
    border-bottom: none;
}

.issue-row:hover {
    background: var(--gh-canvas-subtle);
}

.issue-row--selected {
    background: var(--gh-accent-subtle);
}

.issue-row--selected:hover {
    background: var(--gh-accent-subtle);
}

/* Open-Issue Dot (grüner Kreis mit Ausschnitt wie GitHub) */
.issue-dot {
    width: 16px;
    height: 16px;
    margin-top: 2px;
    flex-shrink: 0;
    color: var(--gh-open-dot);
}

.issue-dot svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

.issue-content {
    flex: 1;
    min-width: 0;
}

.issue-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--gh-fg-default);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
}

.issue-meta {
    font-size: 12px;
    color: var(--gh-fg-muted);
    margin-top: 2px;
}

.issue-labels {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
}

.issue-label {
    display: inline-block;
    padding: 0 7px;
    font-size: 12px;
    font-weight: 500;
    line-height: 18px;
    border-radius: 2em;
    border: 1px solid transparent;
    background: var(--gh-accent-subtle);
    color: var(--gh-accent-fg);
}

/* ── Tracker Panel ───────────────────────────────────────────────────────── */

.tracker-panel {
    position: sticky;
    top: 64px;
    border: 1px solid var(--gh-border-default);
    border-radius: var(--gh-radius);
    background: var(--gh-canvas-default);
    overflow: hidden;
    box-shadow: var(--gh-shadow-small);
}

.tracker-header {
    padding: 12px 16px;
    background: var(--gh-canvas-subtle);
    border-bottom: 1px solid var(--gh-border-default);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.tracker-header-title {
    font-weight: 600;
    font-size: 14px;
    color: var(--gh-fg-default);
    display: flex;
    align-items: center;
    gap: 6px;
}

.tracker-header-link {
    font-size: 12px;
    color: var(--gh-accent-fg);
    text-decoration: none;
}

.tracker-header-link:hover {
    text-decoration: underline;
}

.tracker-body {
    padding: 16px;
}

.time-tracker {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ── Timer Badge ─────────────────────────────────────────────────────────── */

.timer-running-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 10px;
    border-radius: 2em;
    font-size: 12px;
    font-weight: 600;
    background: var(--gh-success-subtle);
    color: var(--gh-success-fg);
    border: 1px solid var(--gh-success-fg);
}

.timer-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--gh-success-fg);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.4; }
}

/* ── Zeiteinträge Tabelle ────────────────────────────────────────────────── */

.time-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.time-table th {
    padding: 6px 8px;
    text-align: left;
    font-weight: 600;
    color: var(--gh-fg-muted);
    border-bottom: 1px solid var(--gh-border-default);
    white-space: nowrap;
}

.time-table td {
    padding: 6px 8px;
    border-bottom: 1px solid var(--gh-border-muted);
    color: var(--gh-fg-default);
}

.time-table tr:last-child td {
    border-bottom: none;
}

/* ── Setup Overlay ───────────────────────────────────────────────────────── */

.setup-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
}

.setup-box {
    background: var(--gh-canvas-default);
    border: 1px solid var(--gh-border-default);
    border-radius: var(--gh-radius);
    padding: 24px;
    width: 400px;
    max-width: calc(100vw - 32px);
    box-shadow: var(--gh-shadow-medium);
}

.setup-box-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--gh-fg-default);
    margin: 0 0 16px 0;
}

/* ── Form Elements (GitHub-Stil) ─────────────────────────────────────────── */

.gh-form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 12px;
}

.gh-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--gh-fg-default);
}

.gh-input {
    padding: 5px 12px;
    font-size: 14px;
    line-height: 20px;
    color: var(--gh-fg-default);
    background: var(--gh-canvas-default);
    border: 1px solid var(--gh-border-default);
    border-radius: var(--gh-radius);
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.gh-input:focus {
    border-color: var(--gh-accent-fg);
    box-shadow: 0 0 0 3px rgba(9,105,218,.3);
}

/* ── Select (GitHub-Stil) ────────────────────────────────────────────────── */

.gh-select {
    padding: 5px 24px 5px 12px;
    font-size: 14px;
    color: var(--gh-fg-default);
    background: var(--gh-canvas-subtle);
    border: 1px solid var(--gh-border-default);
    border-radius: var(--gh-radius);
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='%236e7781' d='M4.427 7.427l3.396 3.396a.25.25 0 00.354 0l3.396-3.396A.25.25 0 0011.396 7H4.604a.25.25 0 00-.177.427z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 16px;
    outline: none;
    min-width: 180px;
}

.gh-select:focus {
    border-color: var(--gh-accent-fg);
    box-shadow: 0 0 0 3px rgba(9,105,218,.3);
}

/* ── Search Input ────────────────────────────────────────────────────────── */

.gh-search-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    max-width: 480px;
    width: 100%;
}

.gh-search-icon {
    position: absolute;
    left: 10px;
    width: 16px;
    height: 16px;
    fill: var(--gh-fg-muted);
    pointer-events: none;
}

.gh-search {
    width: 100%;
    padding: 5px 12px 5px 32px;
    font-size: 14px;
    color: var(--gh-fg-default);
    background: var(--gh-canvas-default);
    border: 1px solid var(--gh-border-default);
    border-radius: var(--gh-radius);
    outline: none;
}

.gh-search:focus {
    border-color: var(--gh-accent-fg);
    box-shadow: 0 0 0 3px rgba(9,105,218,.3);
}

/* ── Flash / Alert ───────────────────────────────────────────────────────── */

.gh-flash {
    padding: 12px 16px;
    border-radius: var(--gh-radius);
    border: 1px solid transparent;
    font-size: 14px;
    margin-bottom: 16px;
}

.gh-flash--error {
    background: var(--gh-danger-subtle);
    border-color: var(--gh-danger-fg);
    color: var(--gh-danger-fg);
}

.gh-flash--success {
    background: var(--gh-success-subtle);
    border-color: var(--gh-success-fg);
    color: var(--gh-success-fg);
}

/* ── Toolbar ─────────────────────────────────────────────────────────────── */

.gh-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

/* ── Loading / Empty States ──────────────────────────────────────────────── */

.gh-empty {
    padding: 40px 16px;
    text-align: center;
    color: var(--gh-fg-muted);
    font-size: 14px;
}

.gh-spinner {
    display: flex;
    justify-content: center;
    padding: 32px;
}

/* ── Bottom Sheet (Mobile) ───────────────────────────────────────────────── */

.sheet-backdrop {
    display: none;
}

@media (max-width: 768px) {

    /* Issues: kein Grid, nur die Liste */
    .issues-layout {
        display: block;
    }

    /* Backdrop */
    .sheet-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 200;
        background: rgba(0, 0, 0, 0);
        pointer-events: none;
        transition: background 0.3s ease;
    }

    .sheet-backdrop--open {
        background: rgba(0, 0, 0, 0.45);
        pointer-events: auto;
    }

    /* Tracker Panel → Bottom Sheet */
    .tracker-panel {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        top: auto;
        z-index: 201;
        max-height: 85dvh;
        overflow-y: auto;
        border-radius: 12px 12px 0 0;
        border-left: none;
        border-right: none;
        border-bottom: none;
        transform: translateY(100%);
        transition: transform 0.32s cubic-bezier(0.32, 0.72, 0, 1);
        box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.18);
    }

    .tracker-panel--open {
        transform: translateY(0);
    }

    /* Drag-Handle Indikator oben im Sheet */
    .tracker-panel::before {
        content: '';
        display: block;
        width: 36px;
        height: 4px;
        border-radius: 2px;
        background: var(--gh-border-default);
        margin: 10px auto 0;
    }

    /* Schließen-Button im Header anzeigen */
    .tracker-close-btn {
        display: flex !important;
    }

    /* Toolbar auf Mobile: untereinander stapeln */
    .gh-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .gh-toolbar .gh-input,
    .gh-toolbar .gh-select,
    .gh-toolbar .gh-btn {
        width: 100%;
    }

    /* Page Header auf Mobile: untereinander */
    .gh-page-header {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* Desktop: Schließen-Button versteckt */
.tracker-close-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: none;
    border: none;
    cursor: pointer;
    border-radius: var(--gh-radius);
    color: var(--gh-fg-muted);
    transition: color 0.12s, background 0.12s;
    flex-shrink: 0;
}

.tracker-close-btn:hover {
    color: var(--gh-fg-default);
    background: var(--gh-canvas-inset);
}

.tracker-close-btn svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}
