/* === Age of Plans - Base Styles === */

:root {
    --bg-deep: #0B1628;
    --bg-card: #132035;
    --bg-card-hover: #1A2A45;
    --bg-input: #0E1B30;

    --teal: #5BB8B0;
    --teal-light: #7DD4CC;
    --teal-dark: #3A8A83;
    --teal-glow: rgba(91, 184, 176, 0.15);

    --pink: #E8709A;
    --pink-light: #F0A0BE;
    --pink-dark: #C45078;

    --sand: #E8DCC8;
    --sand-light: #F5EFE3;
    --sand-dark: #C4B8A4;

    --yellow: #F0D060;
    --green: #6BBF7A;
    --red-soft: #E07070;

    --text: #E0E8F0;
    --text-muted: #8899AA;
    --text-heading: #F0F4F8;

    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 20px;

    --shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);

    --nav-height: 70px;
    --header-height: 56px;
}

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

html {
    font-size: 16px;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Nunito', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-deep);
    color: var(--text);
    min-height: 100dvh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    transition: background 0.5s, color 0.5s;
}

/* Globaler Tag-Modus */
body.day {
    --bg-deep: #1A4A6E;
    --bg-card: rgba(15, 45, 75, 0.7);
    --bg-card-hover: rgba(20, 55, 85, 0.75);
    --bg-input: rgba(10, 35, 60, 0.8);
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.1);
    background: linear-gradient(180deg, #2E6A9E 0%, #4A90C0 40%, #5AACCC 70%, #6CC4D8 100%);
}

/* Globaler Nacht-Modus */
body.night {
    --bg-deep: #080E1A;
    --bg-card: #0E1828;
    --bg-card-hover: #142035;
}

a {
    color: var(--teal-light);
    text-decoration: none;
}

/* === Login === */
.login-wrapper {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    position: relative;
    overflow: hidden;
    background: var(--bg-deep);
    transition: background 0.5s;
}

/* Tag-Modus Login */
.login-wrapper.day {
    background: linear-gradient(180deg, #2E6A9E 0%, #4A90C0 25%, #5AACCC 50%, #6CC4D8 80%, #80D8E0 100%);
}

.login-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 40px 32px;
    width: 100%;
    max-width: 380px;
    box-shadow: var(--shadow);
    border: 1px solid rgba(91, 184, 176, 0.1);
    position: relative;
    z-index: 1;
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-title {
    font-size: 28px;
    font-weight: 800;
    color: var(--teal-light);
    letter-spacing: -0.5px;
}

.login-subtitle {
    color: var(--text-muted);
    font-size: 14px;
    margin-top: 4px;
}

/* Mond */
.login-moon {
    position: fixed;
    top: 8%;
    right: 15%;
    z-index: 0;
}

.moon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #F5F0D0, #E8E0B0);
    box-shadow: 0 0 20px rgba(245, 240, 208, 0.3), 0 0 60px rgba(245, 240, 208, 0.1);
}

.moon-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 140px;
    height: 140px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(245, 240, 208, 0.08) 0%, transparent 70%);
}

/* Sterne */
.login-stars {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
}

.star {
    position: absolute;
    width: var(--size);
    height: var(--size);
    background: rgba(210, 225, 245, 0.7);
    border-radius: 50%;
    animation: twinkle var(--dur) var(--delay) ease-in-out infinite alternate;
}

@keyframes twinkle {
    0% { opacity: 0.1; }
    100% { opacity: 0.8; }
}

/* Sonne */
.login-sun {
    position: fixed;
    top: 10%;
    right: 18%;
    z-index: 0;
}

.sun {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: radial-gradient(circle at 40% 40%, #FFFDE8, #FFE060, #FFC830);
    box-shadow: 0 0 40px rgba(255, 210, 60, 0.6), 0 0 100px rgba(255, 200, 50, 0.25), 0 0 200px rgba(255, 180, 40, 0.1);
}

.sun-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 300px;
    height: 300px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 230, 100, 0.2) 0%, rgba(255, 200, 60, 0.08) 40%, transparent 70%);
}

/* Wolken */
.login-clouds {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
}

.cloud {
    position: absolute;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 50px;
    animation: drift linear infinite;
}

.cloud::before,
.cloud::after {
    content: '';
    position: absolute;
    background: inherit;
    border-radius: 50%;
}

.cloud-1 {
    width: 160px;
    height: 30px;
    top: 12%;
    left: -160px;
    animation-duration: 45s;
}
.cloud-1::before {
    width: 50px;
    height: 40px;
    top: -20px;
    left: 30px;
}
.cloud-1::after {
    width: 70px;
    height: 45px;
    top: -25px;
    left: 60px;
}

.cloud-2 {
    width: 120px;
    height: 24px;
    top: 22%;
    left: -120px;
    animation-duration: 55s;
    animation-delay: -15s;
    opacity: 0.6;
}
.cloud-2::before {
    width: 40px;
    height: 32px;
    top: -16px;
    left: 20px;
}
.cloud-2::after {
    width: 55px;
    height: 36px;
    top: -20px;
    left: 45px;
}

.cloud-3 {
    width: 180px;
    height: 28px;
    top: 6%;
    left: -180px;
    animation-duration: 65s;
    animation-delay: -30s;
    opacity: 0.4;
}
.cloud-3::before {
    width: 60px;
    height: 44px;
    top: -22px;
    left: 40px;
}
.cloud-3::after {
    width: 80px;
    height: 50px;
    top: -28px;
    left: 75px;
}

@keyframes drift {
    0% { transform: translateX(0); }
    100% { transform: translateX(calc(100vw + 200px)); }
}

/* Tag-Modus: Login Card anpassen */
.day .login-card {
    background: rgba(15, 45, 75, 0.75);
    border-color: rgba(120, 210, 230, 0.2);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.15);
}

/* Insel + Meer Szene */
.login-scene {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 35vh;
    z-index: 0;
    pointer-events: none;
}

.scene-svg {
    width: 100%;
    height: 100%;
}

/* === Forms === */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 14px;
    background: var(--bg-input);
    border: 1px solid rgba(91, 184, 176, 0.15);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 16px;
    font-family: inherit;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--teal);
    box-shadow: 0 0 0 3px var(--teal-glow);
}

/* === Buttons === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    gap: 8px;
}

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

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

.btn-primary:active {
    transform: scale(0.98);
}

.btn-full {
    width: 100%;
}

/* === Alerts === */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    margin-bottom: 20px;
}

.alert-error {
    background: rgba(224, 112, 112, 0.15);
    color: var(--red-soft);
    border: 1px solid rgba(224, 112, 112, 0.2);
}

/* === App Layout === */
.app-container {
    padding-bottom: var(--nav-height);
    min-height: 100dvh;
}

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    height: var(--header-height);
}

.app-header h1 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-heading);
}

.header-link {
    font-size: 14px;
    color: var(--text-muted);
}

/* === Home === */
.home-content {
    padding: 40px 20px;
    text-align: center;
}

.home-welcome {
    font-size: 18px;
    color: var(--text);
    margin-bottom: 8px;
}

.home-hint {
    color: var(--text-muted);
    font-size: 14px;
}

/* === Bottom Nav === */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--nav-height);
    background: var(--bg-card);
    border-top: 1px solid rgba(91, 184, 176, 0.08);
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding-bottom: env(safe-area-inset-bottom, 0);
    z-index: 100;
    backdrop-filter: blur(12px);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    padding: 8px 12px;
    transition: color 0.2s;
    text-decoration: none;
}

.nav-item.active {
    color: var(--teal-light);
}

.nav-item svg {
    width: 22px;
    height: 22px;
}

/* === 404 === */
.error-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100dvh;
    text-align: center;
    padding: 24px;
}

.error-page h1 {
    font-size: 72px;
    font-weight: 800;
    color: var(--teal);
    opacity: 0.5;
}

.error-page p {
    color: var(--text-muted);
    margin: 8px 0 24px;
    font-size: 16px;
}

/* === Header Back === */
.header-back {
    font-size: 16px;
    color: var(--teal-light);
    min-width: 80px;
}

/* === Week View === */
.week-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
}

.week-nav-btn {
    font-size: 28px;
    color: var(--teal-light);
    padding: 4px 12px;
    text-decoration: none;
}

.week-header-center {
    text-align: center;
    flex: 1;
}

.week-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-heading);
}

.week-today-btn {
    font-size: 12px;
    color: var(--teal);
    border: 1px solid var(--teal);
    border-radius: 12px;
    padding: 2px 10px;
    display: inline-block;
    margin-top: 4px;
}

.week-filters {
    display: flex;
    gap: 4px;
    padding: 0 16px 12px;
}

.filter-tab {
    flex: 1;
    text-align: center;
    padding: 8px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--bg-card);
    text-decoration: none;
    transition: all 0.2s;
}

.filter-tab.active {
    background: var(--teal);
    color: #fff;
}

/* Week Grid */
.week-grid-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0 0 20px;
}

.week-day-headers {
    display: grid;
    grid-template-columns: 50px repeat(7, 1fr);
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--bg-deep);
    border-bottom: 1px solid rgba(91,184,176,0.1);
}

.time-gutter-header {
    width: 50px;
}

.day-header {
    text-align: center;
    padding: 8px 4px;
}

.day-header.today {
    color: var(--teal-light);
}

.day-header.today .day-num {
    background: var(--teal);
    color: #fff;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.day-name {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
}

.day-num {
    display: block;
    font-size: 15px;
    font-weight: 700;
    margin-top: 2px;
}

.week-grid {
    min-width: 600px;
}

.time-row {
    display: grid;
    grid-template-columns: 50px repeat(7, 1fr);
    min-height: 30px;
}

.time-row.hour-row {
    border-top: 1px solid rgba(91,184,176,0.25);
}

.time-row.half-row {
    /* Kein Border - gleicher Hintergrund wie hour-row */
}

/* Abwechselnde Stunden-Hintergruende */
.hour-group-even .time-cell {
    background: rgba(91,184,176,0.03);
}

.hour-group-odd .time-cell {
    background: rgba(91,184,176,0.07);
}

.hour-group-even .time-cell.today-col {
    background: rgba(91,184,176,0.06);
}

.hour-group-odd .time-cell.today-col {
    background: rgba(91,184,176,0.10);
}

.time-gutter {
    font-size: 11px;
    font-weight: 600;
    color: rgba(200,220,220,0.55);
    padding: 2px 8px 0 0;
    text-align: right;
    white-space: nowrap;
}

.time-cell {
    border-left: 1px solid rgba(91,184,176,0.05);
    padding: 1px 2px;
    cursor: pointer;
    min-height: 28px;
    position: relative;
}

.time-cell:hover {
    background: rgba(91,184,176,0.05);
}

.time-cell.today-col {
    background: rgba(91,184,176,0.03);
}

/* Event Blocks */
.event-block {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    color: #fff;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-height: 22px;
}

.event-block.status-tentative {
    opacity: 0.7;
    border: 1px dashed rgba(255,255,255,0.4);
}

.event-block.status-done {
    opacity: 0.5;
    text-decoration: line-through;
}

.event-block.status-cancelled {
    opacity: 0.3;
    text-decoration: line-through;
}

.event-title {
    overflow: hidden;
    text-overflow: ellipsis;
}

.event-user-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* FAB */
.fab {
    position: fixed;
    bottom: calc(var(--nav-height) + 16px);
    right: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--teal);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(91,184,176,0.4);
    z-index: 50;
    transition: transform 0.2s;
}

.fab:active {
    transform: scale(0.92);
}

/* === Event Form === */
.form-page {
    padding: 16px 20px 40px;
}

.form-row {
    display: flex;
    gap: 12px;
}

.form-half {
    flex: 1;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: var(--teal);
}

.category-picker, .status-picker, .energy-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.cat-option input, .status-option input, .energy-option input {
    display: none;
}

.cat-chip {
    display: inline-block;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    background: rgba(91,184,176,0.1);
    color: var(--text-muted);
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
}

.cat-option input:checked + .cat-chip {
    background: var(--cat-color);
    color: #fff;
    border-color: var(--cat-color);
}

.status-chip, .energy-chip {
    display: inline-block;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    background: rgba(91,184,176,0.1);
    color: var(--text-muted);
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
}

.status-option input:checked + .status-chip.planned { background: var(--teal); color: #fff; }
.status-option input:checked + .status-chip.tentative { background: var(--yellow); color: #1a1a2e; }
.energy-option input:checked + .energy-chip.low { background: var(--green); color: #fff; }
.energy-option input:checked + .energy-chip.medium { background: var(--yellow); color: #1a1a2e; }
.energy-option input:checked + .energy-chip.high { background: var(--red-soft); color: #fff; }

.form-actions {
    margin-top: 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.btn-danger {
    background: rgba(224,112,112,0.15);
    color: var(--red-soft);
    border: 1px solid rgba(224,112,112,0.2);
}

.form-section-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-heading);
    margin: 24px 0 12px;
}

/* === Emergency Widget === */
.emergency-widget {
    position: fixed;
    top: 12px;
    right: 70px;
    z-index: 9999;
}

.emergency-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(224,112,112,0.2);
    border: 1px solid rgba(224,112,112,0.3);
    color: var(--red-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.emergency-btn:hover {
    background: rgba(224,112,112,0.3);
}

.emergency-panel {
    position: absolute;
    top: 48px;
    right: 0;
    width: 260px;
    background: var(--bg-card);
    border: 1px solid rgba(224,112,112,0.15);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 12px;
    display: none;
}

.emergency-panel.open {
    display: block;
}

.emergency-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-heading);
    margin-bottom: 8px;
}

.emergency-edit {
    font-size: 12px;
    color: var(--teal-light);
}

.emergency-contact {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    margin: 4px 0;
    background: rgba(224,112,112,0.08);
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--text);
}

.emergency-name {
    font-size: 14px;
    font-weight: 600;
}

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

.emergency-empty {
    font-size: 13px;
    color: var(--text-muted);
    text-align: center;
    padding: 8px;
}

/* === Settings === */
.settings-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.settings-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
}

.settings-detail {
    display: block;
    font-size: 13px;
    color: var(--text-muted);
}

.btn-icon {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
}

.btn-icon:hover {
    color: var(--red-soft);
}

/* === Responsive === */
@media (min-width: 768px) {
    .login-card {
        padding: 48px 40px;
    }

    .bottom-nav {
        max-width: 500px;
        left: 50%;
        transform: translateX(-50%);
        border-radius: var(--radius) var(--radius) 0 0;
    }

    .week-grid {
        min-width: auto;
    }
}

/* === Globale Meer-Szene === */
.scene-wrapper {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 180px;
    pointer-events: none;
    z-index: 0;
}

.scene-bg {
    width: 100%;
    height: 100%;
}

.scene-bg .scene-svg {
    width: 100%;
    height: 100%;
}

/* Szene nicht auf Login (hat eigene) */
.login-wrapper ~ .scene-wrapper {
    display: none;
}

/* Szene hinter Bottom-Nav */
.bottom-nav {
    z-index: 100;
}

/* Content muss ueber Szene liegen */
.app-container {
    position: relative;
    z-index: 1;
}
