/* ZVV Font-Einbindung */
@font-face {
    font-family: "ZVV Brown Narrow S Web Regular";
    src: url("/font/ZVVBrownNarrowSWeb-Regular.woff2") format("woff2"),
         url("/font/ZVVBrownNarrowSWeb-Regular.woff") format("woff");
}

@font-face {
    font-family: "ZVV Brown Narrow S Web Bold";
    src: url("/font/ZVVBrownNarrowSWeb-Bold.woff2") format("woff2"),
         url("/font/ZVVBrownNarrowSWeb-Bold.woff") format("woff");
}

:root {
    --zvv-blue: #0479cc;        /* ZVV Hauptblau */
    --zvv-red: #e2000f;         /* ZVV Rot */
    --zvv-pink: #e5007d;        /* ZVV Rosa */
    --zvv-green: #239c36;       /* ZVV Grün */
    --zvv-white: #ffffff;
    --zvv-gray: #f5f5f7;
    --text-gray: #636363;
    --text-black: #000000;
    
    /* Trägermedien Farben */
    --swisspass-color: #c51416;  /* Dunkelrot für SwissPass */
    --eticket-color: #8a2be2;    /* Violett für E-Ticket */
    --eticket-id-color: #ff69b4; /* Pink für E-Ticket mit Ausweisprüfung */
}

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

body {
    font-family: "ZVV Brown Narrow S Web Regular", sans-serif;
    background-color: var(--zvv-gray);
    color: var(--zvv-blue);
    line-height: 1.6;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    position: relative;
    min-height: 100vh;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url('gfx/zvv-bg.png');
    background-size: cover;
    background-position: center;
    opacity: 0.75;
    z-index: -2;
    pointer-events: none;
    mask-image: linear-gradient(to top, rgba(0,0,0,1), rgba(0,0,0,0));
    -webkit-mask-image: linear-gradient(to top, rgba(0,0,0,1), rgba(0,0,0,0));
}

.container {
    margin: 0 auto;
    padding: 1.5rem;
    padding-bottom: calc(60px + 4rem); /* Tab-Navigation + zusätzlicher Abstand */
}

.header {
    background-color: var(--zvv-blue);
    color: var(--zvv-white);
    padding: 0.875rem 1.25rem;
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.zvv-logo {
    height: 2.25rem;  /* 20% größer: 1.875 * 1.2 = 2.25 */
    width: auto;
    filter: brightness(0) invert(1);  /* Macht das Logo weiß */
}

.app-version {
    font-family: "ZVV Brown Narrow S Web Bold", sans-serif;
    font-size: 1.125rem;
    color: var(--zvv-white);
    text-align: right;
}

.header h1 {
    font-size: 1.5rem;
    font-family: "ZVV Brown Narrow S Web Bold", sans-serif;
    margin: 0;
    line-height: 1;
    padding-top: 1px;
}

.timer-card, .media-options, .measurements-card, .admin-card {
    background-color: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    padding: 1.5rem 2rem;
    margin: 1.5rem 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.timer {
    font-size: 3.5rem;
    font-family: "ZVV Brown Narrow S Web Bold", sans-serif;
    text-align: center;
    font-variant-numeric: tabular-nums;
    color: var(--text-black);
    margin: 1rem 0;
}

.timer.running {
    background: linear-gradient(
        45deg,
        var(--zvv-blue),
        var(--zvv-green),
        var(--zvv-pink)
    );
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.controls {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin: 1.5rem 0;
}

button {
    border: none;
    border-radius: 12px;
    padding: 1rem;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    -webkit-appearance: none;
    appearance: none;
}

button:active {
    transform: scale(0.98);
}

#startStop {
    background-color: var(--zvv-blue);
    color: var(--zvv-white);
    width: 180px;
    min-width: 180px;
}

#startStop.running {
    background-color: var(--zvv-blue);
}

#downloadCSV {
    background-color: var(--zvv-blue);
    color: var(--zvv-white);
    width: 100%;
    margin-top: 1rem;
}

#downloadCSV:hover {
    background-color: #0366ad;
}

#downloadXLS {
    background-color: #217346; /* Excel-Grün */
}

#downloadXLS:hover {
    background-color: #1e6e41;
}

.measurement-item {
    background: #f5f5f5;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 0.5rem;
    border-left: 4px solid var(--zvv-blue);
    position: relative;
    transition: background-color 0.2s;
    color: var(--text-gray);
}

.measurement-item.grün {
    background: rgba(35, 156, 54, 0.03); /* Sehr subtiles Grün */
    border-left-color: var(--zvv-green);
}

.measurement-item.orange {
    background: rgba(255, 152, 0, 0.03); /* Sehr subtiles Orange */
    border-left-color: #ff9800;
}

.measurement-item div {
    margin: 0.2rem 0;
    color: var(--text-gray);
}

.measurement-arrow {
    display: none;
}

.no-measurements {
    text-align: center;
    color: #666;
    padding: 1rem;
}

@media (max-width: 480px) {
    .timer {
        font-size: 3rem;
    }

    .controls {
        grid-template-columns: 1fr;
    }
}

/* iOS-specific Styles */
@supports (-webkit-touch-callout: none) {
    button {
        padding: 1rem;
    }
}

.media-dialog {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 2rem;
    border-radius: 15px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    z-index: 1001;
    width: 90%;
    max-width: 500px;
}

.media-dialog.hidden {
    display: none;
}

.media-buttons {
    display: grid;
    gap: 1rem;
    margin-top: 1.5rem;
}

.media-button {
    padding: 1.2rem;
    font-size: 1.1rem;
    background-color: var(--zvv-blue);
    color: var(--zvv-white);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: transform 0.2s ease;
}

/* Spezifische Stile für Trägermedium-Buttons */
.media-button[data-medium="SwissPass"] {
    background-color: var(--swisspass-color);
}

.media-button[data-medium="E-Ticket"] {
    background-color: var(--eticket-color);
}

.media-button[data-medium="E-Ticket mit Ausweisprüfung"] {
    background-color: var(--eticket-id-color);
}

.media-button:active {
    transform: scale(0.98);
}

.media-button.cancel {
    background: var(--zvv-red);
    color: var(--zvv-white);
    font-weight: 500;
}

.media-button.result-green {
    background-color: var(--zvv-green);
}

.media-button.result-orange {
    background-color: #ff9800;
}

.media-button i {
    margin-right: 8px;
}

.overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
}

.delete-button {
    background-color: var(--zvv-red) !important;
    color: white;
    width: 100%;
    margin: 1rem 0;
    padding: 1rem;
    border: none;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.delete-button:hover {
    background-color: #c82333;
}

.info-card {
    background-color: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    padding: 2rem;
    margin: 1.5rem 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.version-info {
}

.version-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.copyright {
    color: var(--text-gray);
}

.changelog-section {
    /* margin-top entfernt */
}

.changelog-section h3 {
    color: var(--text-black);
    font-size: 1.5rem;
    font-family: "ZVV Brown Narrow S Web Regular", sans-serif;
    margin-bottom: 0.5rem;
}

.changelog-entry {
    margin-bottom: 1.5rem;
    color: var(--text-gray);
}

.changelog-entry h4 {
    color: var(--text-black);
    margin-bottom: 0.5rem;
    font-family: "ZVV Brown Narrow S Web Regular", sans-serif;
    font-size: 1.1rem;
}

.changelog-entry ul {
    list-style-type: none;
    padding-left: 0;
}

.changelog-entry ul li {
    position: relative;
    padding-left: 0;
    margin-bottom: 0.3rem;
    color: var(--text-gray);
}

.changelog-entry.current {
    background: rgba(35, 156, 54, 0.05);
    padding: 1rem;
    border-radius: 8px;
    border-left: 4px solid var(--zvv-green);
}

.bottom-tabs {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--zvv-white);
    display: flex;
    justify-content: space-around;
    padding: 10px 0;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    z-index: 1000;
}

.tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: var(--text-black);
    opacity: 0.85;
    transition: opacity 0.3s;
    cursor: pointer;
}

.tab.active {
    opacity: 1;
    color: var(--zvv-blue);
}

.tab i {
    font-size: 24px;
    margin-bottom: 4px;
}

.tab span {
    font-size: 12px;
}

.view {
    display: none;
    opacity: 0;
    visibility: hidden;
    position: absolute;
    left: -9999px;
    transition: opacity 0.3s ease;
}

.view.active {
    display: block;
    opacity: 1;
    visibility: visible;
    position: relative;
    left: 0;
}

.result {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: inherit;
}

.result.grün {
    color: var(--zvv-green);
}

.result.orange {
    color: #e65100;
}

.result.cancelled {
    color: var(--zvv-red);
    opacity: 0.7;
}

.result i {
    font-size: 1.1em;
}

.stats-card {
    background-color: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    padding: 1.5rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    margin-bottom: 1.5rem;
}

.metrics-card, .chart-card {
    margin-bottom: 1.5rem;
}

.stats-view {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.stats-view:not(.active) {
    display: none;
}

.stats-header {
    display: none;
}

#statsChart {
    width: 100%;
    max-height: 300px;
    margin: 1rem 0;
}

.chart-controls {
    margin-top: 1rem;
    display: flex;
    justify-content: center;
}

.chart-title {
    color: var(--text-black);
    font-size: 1.2rem;
    font-family: "ZVV Brown Narrow S Web Regular", sans-serif;
    margin: 1rem 0;
    text-align: left;
}

.toggle-button {
    background-color: var(--zvv-blue);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1rem;
}

.toggle-button i {
    font-size: 1.1rem;
}

.stats-metrics {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-top: 1rem;
}

.metric {
    text-align: center;
}

.metric-label {
    color: var(--text-gray);
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
}

.metric-value {
    color: var(--text-black);
    font-size: 1.2rem;
    font-family: "ZVV Brown Narrow S Web Bold", sans-serif;
}

/* Container für das Chart */
#statsChart {
    width: 100%;
    height: 450px !important;
    margin-bottom: 2rem;
}

.stats-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin: 1rem 0;
    text-align: center;
}

@keyframes controlBorder {
    0% {
        box-shadow: 0 0 0 0px rgba(4, 121, 204, 0.2);
        border-image: linear-gradient(
            45deg,
            rgba(4, 121, 204, 0.8),
            rgba(35, 156, 54, 0.8),
            rgba(229, 0, 125, 0.8)
        ) 1;
    }
    50% {
        box-shadow: 0 0 30px 0px rgba(4, 121, 204, 0.4);
        border-image: linear-gradient(
            180deg,
            rgba(35, 156, 54, 0.8),
            rgba(229, 0, 125, 0.8),
            rgba(4, 121, 204, 0.8)
        ) 1;
    }
    100% {
        box-shadow: 0 0 0 0px rgba(4, 121, 204, 0.2);
        border-image: linear-gradient(
            315deg,
            rgba(229, 0, 125, 0.8),
            rgba(4, 121, 204, 0.8),
            rgba(35, 156, 54, 0.8)
        ) 1;
    }
}

.container.active-control {
    position: relative;
    border: 2px solid transparent;
    animation: controlBorder 3s infinite;
    border-radius: 12px;
    overflow: hidden;
}

.container.active-control::before {
    content: '';
    position: absolute;
    inset: -1px;
    background: linear-gradient(45deg, #0479cc, #239c36, #e5007d);
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask-composite: exclude;
    -webkit-mask-composite: xor;
    pointer-events: none;
    opacity: 0.8;
}

@keyframes breathe {
    0% {
        box-shadow: 0 0 30px 0px var(--zvv-blue);
        border: 3px solid rgba(4, 121, 204, 0.8);
        filter: brightness(1) drop-shadow(0 0 25px rgba(4, 121, 204, 0.4));
    }
    50% {
        box-shadow: 0 0 50px 15px var(--zvv-green);
        border: 3px solid rgba(35, 156, 54, 0.9);
        filter: brightness(1.05) drop-shadow(0 0 35px rgba(35, 156, 54, 0.5));
    }
    100% {
        box-shadow: 0 0 30px 0px var(--zvv-pink);
        border: 3px solid rgba(229, 0, 125, 0.8);
        filter: brightness(1) drop-shadow(0 0 25px rgba(229, 0, 125, 0.4));
    }
}

.timer-card {
    position: relative;
    padding: 1.5rem 2rem;
    border-radius: 24px;
    transition: all 0.3s ease;
    overflow: hidden;
}

.timer-card.active-control {
    animation: breathe 5s infinite ease-in-out;
    -webkit-animation: breathe 5s infinite ease-in-out;
    background: linear-gradient(
        45deg,
        rgba(4, 121, 204, 0.15),
        rgba(35, 156, 54, 0.15),
        rgba(229, 0, 125, 0.15)
    );
    transform: scale(1.02);
    will-change: transform, box-shadow, filter;
    -webkit-transform: scale(1.02);
}

.app-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 1.5rem;
    padding-bottom: calc(60px + 4rem);
}

.total-controls {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--text-gray);
}

.background-animation {
    position: fixed !important;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transform: scale(0.75) translateY(20%);
    z-index: -1;
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
    transition: all 0.5s ease-out;
}

.background-animation.active {
    visibility: visible;
    opacity: 1;
    transform: scale(0.75) translateY(0);
}

.background-animation.fade-out {
    opacity: 0;
    transform: scale(0.75) translateY(-20%);
}

.full-page-breathing {
    position: relative;
    min-height: 100vh;
    width: 100%;
    overflow: hidden;
}

.full-page-breathing.active-control {
    position: relative;
}

.full-page-breathing.active-control::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    animation: innerGlow 5s infinite ease-in-out;
    -webkit-animation: innerGlow 5s infinite ease-in-out;
}

@keyframes innerGlow {
    0% {
        box-shadow: inset 0 0 50px rgba(4, 121, 204, 0.3);
    }
    50% {
        box-shadow: inset 0 0 80px rgba(35, 156, 54, 0.3);
    }
    100% {
        box-shadow: inset 0 0 50px rgba(229, 0, 125, 0.3);
    }
}

.stats-summary div::after,
.metric-label::after {
    content: none;
}

.stats-summary,
.stats-metrics {
    text-align: center;
}

.stats-summary span {
    color: var(--text-gray);
    font-weight: 500;
}

.measurements-card h2,
.media-dialog h3,
.stats-card h2,
.admin-card h2 {
    color: var(--text-black);
    font-size: 1.5rem;
    font-family: "ZVV Brown Narrow S Web Regular", sans-serif;
    margin-bottom: 0.5rem;
}

.chart-title {
    color: var(--text-black);
    font-size: 1.2rem;
    font-family: "ZVV Brown Narrow S Web Regular", sans-serif;
    margin: 1rem 0;
    text-align: left;
}

/* Buttons in der Admin-View */
.admin-view button {
    margin: 10px 0;
    padding: 12px 20px;
    border-radius: 8px;
    background-color: var(--zvv-blue);
    color: white;
    border: none;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.3s;
    display: block;
    width: 100%;
    max-width: 100%;
    text-align: center;
    box-sizing: border-box;
}

.admin-view button i {
    margin-right: 8px;
}

#downloadCSV, #downloadXLS {
    background-color: var(--zvv-blue);
}

#downloadCSV:hover, #downloadXLS:hover {
    background-color: #0366ad;
}

.delete-button {
    background-color: var(--zvv-red) !important;
    color: white;
    margin-top: 20px !important;
}

.delete-button:hover {
    background-color: #c82333 !important;
}

.admin-view button:hover {
    background-color: #0366ad;
}

.media-dialog h3 {
    margin-top: 0;
    position: relative;
}

.close-button {
    position: absolute;
    right: 0;
    top: 0;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #666;
    padding: 0;
    margin: 0;
    line-height: 1;
}

.close-button:hover {
    color: #000;
}

.admin-card h2 {
    color: var(--text-black);
    font-size: 1.5rem;
    font-family: "ZVV Brown Narrow S Web Regular", sans-serif;
    margin-bottom: 1rem;
}

.admin-section {
    margin-bottom: 2rem;
}

.admin-section h3 {
    color: var(--text-black);
    font-size: 1.2rem;
    font-family: "ZVV Brown Narrow S Web Regular", sans-serif;
    margin-bottom: 0.5rem;
}

.admin-info {
    color: var(--text-gray);
    font-size: 0.95rem;
    margin-bottom: 1rem;
    line-height: 1.4;
}