/* GastosApp — Dark Theme, Mobile-first */

:root {
    --bg: #1a1a2e;
    --bg-card: #16213e;
    --bg-input: #0f3460;
    --text: #e8e8e8;
    --text-muted: #8b8fa3;
    --ruben: #3B82F6;
    --ruben-bg: rgba(59, 130, 246, 0.15);
    --alexa: #EC4899;
    --alexa-bg: rgba(236, 72, 153, 0.15);
    --green: #22C55E;
    --green-bg: rgba(34, 197, 94, 0.15);
    --red: #EF4444;
    --orange: #F59E0B;
    --border: rgba(255, 255, 255, 0.08);
    --radius: 12px;
    --nav-height: 70px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100dvh;
    overflow-x: hidden;
    user-select: none;
}

.hidden { display: none !important; }

/* ===== PIN-Screen ===== */
.pin-screen {
    position: fixed;
    inset: 0;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.pin-container {
    text-align: center;
    width: 100%;
    max-width: 300px;
    padding: 20px;
}

.pin-icon { font-size: 48px; margin-bottom: 8px; }

.pin-container h1 {
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 30px;
    color: var(--text);
}

.pin-dots {
    display: flex;
    justify-content: center;
    gap: 14px;
    margin-bottom: 30px;
}

.dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid var(--text-muted);
    transition: all 0.2s;
}

.dot.filled {
    background: var(--text);
    border-color: var(--text);
}

.dot.error {
    border-color: var(--red);
    background: var(--red);
    animation: shake 0.4s;
}

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

.pin-pad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    max-width: 260px;
    margin: 0 auto;
}

.pin-btn {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text);
    font-size: 26px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    margin: 0 auto;
}

.pin-btn:active { background: var(--bg-input); }
.pin-btn-empty { visibility: hidden; }
.pin-btn-del { font-size: 22px; }

.pin-error {
    color: var(--red);
    font-size: 14px;
    margin-top: 16px;
    min-height: 20px;
}

/* ===== App-Layout ===== */
.app {
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
}

/* Header */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
}

.header-title {
    font-size: 20px;
    font-weight: 700;
}

/* Sync-Indikator */
.sync-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.05);
}

.sync-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--green);
    transition: background 0.3s;
}

.sync-dot.syncing {
    background: var(--orange);
    animation: pulse 1s infinite;
}

.sync-dot.offline {
    background: var(--red);
}

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

/* Main Content */
.main {
    flex: 1;
    padding: 16px;
    padding-bottom: calc(var(--nav-height) + 20px);
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-width: 500px;
    margin: 0 auto;
    width: 100%;
}

/* ===== Eingabeformular ===== */
.entry-form {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.person-select, .type-select {
    display: flex;
    gap: 8px;
}

.person-btn, .type-btn {
    flex: 1;
    padding: 12px;
    border-radius: 8px;
    border: 2px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.person-btn.ruben.active {
    border-color: var(--ruben);
    background: var(--ruben-bg);
    color: var(--ruben);
}

.person-btn.alexa.active {
    border-color: var(--alexa);
    background: var(--alexa-bg);
    color: var(--alexa);
}

.type-btn.active {
    border-color: var(--text);
    background: rgba(255, 255, 255, 0.1);
    color: var(--text);
}

.input-row {
    display: flex;
    gap: 8px;
}

.amount-group {
    flex: 1;
    display: flex;
    align-items: center;
    background: var(--bg-input);
    border-radius: 8px;
    padding: 0 12px;
}

.currency-prefix {
    color: var(--text-muted);
    font-size: 18px;
    font-weight: 600;
    margin-right: 4px;
}

.amount-group input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text);
    font-size: 18px;
    font-weight: 600;
    padding: 12px 4px;
    outline: none;
    width: 100%;
    min-width: 0;
}

.amount-group input::placeholder { color: var(--text-muted); }

/* Spinner entfernen */
.amount-group input::-webkit-inner-spin-button,
.amount-group input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.amount-group input[type="number"] { -moz-appearance: textfield; }

.desc-input {
    background: var(--bg-input);
    border: none;
    border-radius: 8px;
    color: var(--text);
    font-size: 15px;
    padding: 12px;
    outline: none;
    width: 100%;
}

.desc-input::placeholder { color: var(--text-muted); }

/* Split-Einstellung */
.split-select {
    background: var(--bg);
    border-radius: 8px;
    padding: 10px 12px;
}

.split-header {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

#split-label { font-weight: 600; color: var(--text); }

.split-range {
    width: 100%;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: linear-gradient(to right, var(--ruben), var(--alexa));
    border-radius: 3px;
    outline: none;
}

.split-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--text);
    cursor: pointer;
    border: 2px solid var(--bg);
}

.split-range::-moz-range-thumb {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--text);
    cursor: pointer;
    border: 2px solid var(--bg);
}

.split-names {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    margin-top: 4px;
}

.split-ruben { color: var(--ruben); }
.split-alexa { color: var(--alexa); }

.date-input {
    background: var(--bg-input);
    border: none;
    border-radius: 8px;
    color: var(--text);
    padding: 12px;
    font-size: 14px;
    width: 140px;
    outline: none;
    color-scheme: dark;
}

.add-btn {
    background: var(--bg-input);
    border: 2px dashed var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 16px;
    font-weight: 600;
    padding: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.add-btn:active {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--text-muted);
}

/* ===== Einträge-Liste ===== */
.entries-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.entry-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: var(--bg-card);
    border-radius: 10px;
    border-left: 4px solid;
    animation: slideIn 0.2s ease-out;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.entry-item.ruben { border-left-color: var(--ruben); }
.entry-item.alexa { border-left-color: var(--alexa); }

.entry-person {
    font-weight: 600;
    font-size: 14px;
    min-width: 50px;
}

.entry-item.ruben .entry-person { color: var(--ruben); }
.entry-item.alexa .entry-person { color: var(--alexa); }

.entry-info {
    flex: 1;
    min-width: 0;
}

.entry-amount {
    font-weight: 700;
    font-size: 16px;
}

.entry-desc {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.entry-split {
    font-size: 11px;
    color: var(--text-muted);
    padding: 1px 5px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.06);
}

.entry-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}

.entry-date {
    font-size: 12px;
    color: var(--text-muted);
}

.entry-type {
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-muted);
}

.entry-delete {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: all 0.15s;
}

.entry-delete:active {
    background: rgba(239, 68, 68, 0.2);
    color: var(--red);
}

/* ===== Zusammenfassung ===== */
.summary {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 15px;
}

.summary-value { font-weight: 700; font-size: 16px; }

.ruben-row .summary-value { color: var(--ruben); }
.alexa-row .summary-value { color: var(--alexa); }

.summary-debt {
    text-align: center;
    padding: 12px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 15px;
    background: var(--green-bg);
    color: var(--green);
    margin-top: 4px;
}

.summary-debt.owes-ruben {
    background: var(--alexa-bg);
    color: var(--alexa);
}

.summary-debt.owes-alexa {
    background: var(--ruben-bg);
    color: var(--ruben);
}

/* ===== Aktions-Buttons ===== */
.actions {
    display: flex;
    gap: 10px;
}

.history-btn, .settle-btn, .monthly-btn {
    flex: 1;
    padding: 16px;
    border: none;
    border-radius: var(--radius);
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s;
}

.history-btn, .monthly-btn {
    background: var(--bg-card);
    color: var(--text);
    border: 1px solid var(--border);
}

.monthly-btn:active { background: var(--bg-input); }

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

.settle-btn:active { filter: brightness(0.85); }
.history-btn:active { background: var(--bg-input); }

/* ===== Tab-Navigation ===== */
.tab-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--nav-height);
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    display: flex;
    z-index: 50;
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.tab-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 12px;
    cursor: pointer;
    transition: color 0.2s;
    position: relative;
}

.tab-btn.active { color: var(--text); }

.tab-btn.active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 30%;
    right: 30%;
    height: 3px;
    background: var(--green);
    border-radius: 0 0 3px 3px;
}

.tab-icon { font-size: 22px; }
.tab-label { font-weight: 600; }

/* ===== Modal ===== */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 100;
    animation: fadeIn 0.2s;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: var(--bg-card);
    border-radius: 16px 16px 0 0;
    width: 100%;
    max-width: 500px;
    max-height: 80dvh;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.modal-small {
    border-radius: var(--radius);
    margin: 20px;
    max-height: none;
    position: absolute;
    bottom: auto;
    top: 50%;
    transform: translateY(-50%);
    animation: none;
}

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

.modal-header h2 {
    font-size: 18px;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 28px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

.modal-body {
    padding: 16px 20px;
    overflow-y: auto;
    flex: 1;
}

/* Historie-Einträge */
.history-item {
    background: var(--bg);
    border-radius: 10px;
    padding: 14px;
    margin-bottom: 10px;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.history-date {
    font-size: 13px;
    color: var(--text-muted);
}

.history-total {
    font-weight: 700;
    font-size: 16px;
}

.history-detail {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    margin-bottom: 4px;
}

.history-debt {
    font-weight: 600;
    font-size: 14px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}

.history-entries-toggle {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 13px;
    cursor: pointer;
    margin-top: 8px;
    padding: 4px 0;
}

.history-entries {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.history-entry-row {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: var(--text-muted);
}

.history-empty {
    text-align: center;
    color: var(--text-muted);
    padding: 40px 20px;
    font-size: 15px;
}

/* Bestätigungs-Dialog */
.confirm-buttons {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.btn-cancel, .btn-confirm {
    flex: 1;
    padding: 14px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
}

.btn-cancel {
    background: var(--bg);
    color: var(--text);
}

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

#confirm-text {
    font-size: 15px;
    line-height: 1.5;
    color: var(--text-muted);
}

/* ===== Einkaufsliste (Lista) ===== */
.lista-text-input {
    flex: 1;
    background: var(--bg-input);
    border: none;
    border-radius: 8px;
    color: var(--text);
    font-size: 16px;
    padding: 14px 12px;
    outline: none;
}

.lista-text-input::placeholder { color: var(--text-muted); }

.lista-add-btn {
    width: 50px;
    min-width: 50px;
    padding: 14px;
    font-size: 22px;
    border-radius: 8px;
    border: none;
    background: var(--green);
    color: #fff;
    cursor: pointer;
    font-weight: 700;
}

.lista-add-btn:active { filter: brightness(0.85); }

.lista-items {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.lista-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    border-radius: 10px;
    transition: all 0.3s ease;
    animation: slideIn 0.2s ease-out;
}

.lista-item.open {
    background: rgba(239, 68, 68, 0.12);
    border-left: 4px solid var(--red);
}

.lista-item.done {
    background: rgba(34, 197, 94, 0.12);
    border-left: 4px solid var(--green);
    order: 1;
}

.lista-checkbox {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    border: 2px solid var(--text-muted);
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s;
    font-size: 14px;
    color: transparent;
}

.lista-item.done .lista-checkbox {
    border-color: var(--green);
    background: var(--green);
    color: #fff;
}

.lista-item-text {
    flex: 1;
    font-size: 16px;
    font-weight: 500;
}

.lista-item.done .lista-item-text {
    text-decoration: line-through;
    color: var(--text-muted);
}

.lista-item-delete {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
}

.lista-item-delete:active {
    background: rgba(239, 68, 68, 0.2);
    color: var(--red);
}

.terminar-btn { width: 100%; }

/* ===== Monatsübersicht ===== */
.monthly-item {
    background: var(--bg);
    border-radius: 10px;
    padding: 14px;
    margin-bottom: 10px;
}

.monthly-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.monthly-month {
    font-weight: 700;
    font-size: 16px;
    text-transform: capitalize;
}

.monthly-total {
    font-weight: 700;
    font-size: 18px;
}

.monthly-bar {
    height: 8px;
    border-radius: 4px;
    background: var(--bg-card);
    overflow: hidden;
    display: flex;
    margin: 10px 0;
}

.monthly-bar-ruben {
    background: var(--ruben);
    height: 100%;
    transition: width 0.3s;
}

.monthly-bar-alexa {
    background: var(--alexa);
    height: 100%;
    transition: width 0.3s;
}

.monthly-detail {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
}

/* ===== Desktop ===== */
@media (min-width: 600px) {
    .tab-nav {
        top: 0;
        bottom: auto;
        height: 50px;
        border-top: none;
        border-bottom: 1px solid var(--border);
        padding-bottom: 0;
    }

    .tab-btn { flex-direction: row; gap: 6px; }
    .tab-icon { font-size: 18px; }
    .tab-label { font-size: 14px; }

    .tab-btn.active::before {
        top: auto;
        bottom: 0;
        border-radius: 3px 3px 0 0;
    }

    .header { padding-top: 60px; }

    .main {
        padding-top: 16px;
        padding-bottom: 30px;
    }

    .modal-content {
        border-radius: var(--radius);
        max-height: 70vh;
        margin: auto;
    }
}
