/* === CSS VARIABLES === */
:root {
  --primary-color: #377ba8;
  --secondary-color: #04AA6D;
  --background-light: #f0f0f0;
  --border-color: #ddd;
  --text-gray: slategray;
  --spacing-sm: 0.5rem;
  --spacing-md: 1rem;
  --spacing-lg: 1.5rem;
  --border-radius: 8px;
  --box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

/* === RESET & BASE === */
html {
  font-family: sans-serif;
  background: #eee;
  padding: var(--spacing-md);
}

body {
  margin: 0 auto;
  background: white;
}

/* === TYPOGRAPHY === */
h1 {
  font-family: serif;
  color: var(--primary-color);
  margin: var(--spacing-md) 0;
}

a {
  color: var(--primary-color);
  text-decoration: none;
}

hr {
  border: none;
  border-top: 1px solid lightgray;
}

/* === LAYOUT === */
.container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: var(--spacing-md);
}

/* Section Headers - erzwingen neue Zeile */
.mycontainer {
  grid-column: 1 / -1; /* Nimmt gesamte Grid-Breite */
  width: 100%;
  overflow: auto;
  
  /* Spacing */
  margin-top: var(--spacing-lg);
  margin-bottom: var(--spacing-md);
  padding: var(--spacing-sm) 0;
  
  /* Visual Separation */
  border-bottom: 2px solid var(--primary-color);
  background: linear-gradient(90deg, var(--primary-color) 0%, transparent 100%);
  background-size: 100% 2px;
  background-repeat: no-repeat;
  background-position: bottom;
}

.mycontainer:first-child {
  margin-top: 0;
}

.mycontainer h2 {
  margin: 0;
  color: var(--primary-color);
  font-size: 1.5rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.tile {
  min-width: 0;
  aspect-ratio: 5/3;
  padding: 20px;
  background-color: var(--background-light);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  box-shadow: var(--box-shadow);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  transition: all 0.2s ease;
}

/* === COMPONENTS === */
.content {
  padding: 0 var(--spacing-md) var(--spacing-md);
  margin-bottom: var(--spacing-md);
}

.content > header {
  border-bottom: 1px solid lightgray;
  display: flex;
  align-items: flex-end;
}

.content > header h1 {
  flex: auto;
  margin: var(--spacing-md) 0 0.25rem 0;
}

.flash {
  margin: 1em 0;
  padding: 1em;
  background: #cae6f6;
  border: 1px solid var(--primary-color);
  margin-bottom: var(--spacing-md);
}

.post {
  margin-bottom: var(--spacing-md);
}

.post > header {
  display: flex;
  align-items: flex-end;
  font-size: 0.85em;
}

.post > header > div:first-of-type {
  flex: auto;
}

.post > header h1 {
  font-size: 1.5em;
  margin-bottom: 0;
}

.post .about {
  color: var(--text-gray);
  font-style: italic;
}

.post .body {
  white-space: pre-line;
}

/* === FORMS === */
.content form {
  margin: 1em 0;
  display: flex;
  flex-direction: column;
}

.content label {
  font-weight: bold;
  margin-bottom: var(--spacing-sm);
}

.content input,
.content textarea {
  margin-bottom: 1em;
}

.content textarea {
  min-height: 12em;
  resize: vertical;
}

/* === BUTTONS === */
.btn {
  padding: 0.75rem 1.5rem;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: all 0.2s ease;
  align-self: start;
  width: 45%;
}

.btn--primary {
  background-color: var(--primary-color);
  color: white;
}

.btn--danger {
  background-color: #cc2f2e;
  color: white;
}

input[type=submit] {
  align-self: start;
  min-width: 10em;
}

input.danger {
  color: #cc2f2e;
}

/* === NAVIGATION === */
.topnav {
  overflow: hidden;
  background-color: lightgray;
}

.topnav::after {
  content: "";
  display: table;
  clear: both;
}

.topnav a {
  float: left;
  color: var(--primary-color);
  text-align: center;
  padding: 14px 16px;
  text-decoration: none;
  font-size: 17px;
}

.topnav a:hover {
  background-color: #ddd;
  color: black;
}

.topnav a.active {
  background-color: var(--secondary-color);
  color: white;
}

.topnav-right {
  float: right;
}

/* === INTERACTIONS === */
a:focus,
input:focus,
textarea:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

.tile:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
  html {
    padding: var(--spacing-sm);
  }
  
  .topnav a {
    padding: 10px 12px;
    font-size: 16px;
  }
  
  .container {
    grid-template-columns: 1fr;
  }
}

/* === ACCESSIBILITY === */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

* === CHART & FORMS (RESPONSIVE) === */

/* Chart Container */
#chart {
	width: 100%;
	height: auto;
	min-height: 400px;
	margin: var(--spacing-lg) 0;
	border-radius: var(--border-radius);
	box-shadow: var(--box-shadow);
}

/* Form Styling */
form {
	display: flex;
	flex-direction: column;
	gap: var(--spacing-md);
}

.description {
	margin: var(--spacing-md) 0;
	color: var(--text-gray);
	font-size: clamp(0.9rem, 2vw, 1rem);
}

.radio-group {
	display: flex;
	gap: var(--spacing-lg);
	flex-wrap: wrap;
	align-items: center;
}

.radio-group input[type="radio"] {
	cursor: pointer;
}

.radio-group label {
	cursor: pointer;
	user-select: none;
	margin-right: var(--spacing-sm);
}

/* Date Inputs */
.date-inputs {
	display: flex;
	flex-direction: column;
	gap: var(--spacing-md);
}

.date-input-row {
	display: flex;
	gap: var(--spacing-md);
	align-items: center;
	flex-wrap: wrap;
}

.date-input-row label {
	font-weight: bold;
	min-width: 50px;
	font-size: clamp(0.9rem, 2vw, 1rem);
}

.date-input-row input[type="date"] {
	padding: var(--spacing-sm) var(--spacing-md);
	border: 1px solid var(--border-color);
	border-radius: var(--border-radius);
	font-size: clamp(0.9rem, 2vw, 1rem);
	flex: 1;
	min-width: 150px;
	max-width: 250px;
	cursor: pointer;
}

.date-input-row input[type="date"]:focus {
	outline: 2px solid var(--primary-color);
	outline-offset: 2px;
	border-color: var(--primary-color);
}

/* Submit Button */
form > button[type="submit"] {
	padding: var(--spacing-md) var(--spacing-lg);
	background-color: var(--secondary-color);
	color: white;
	border: none;
	border-radius: var(--border-radius);
	font-size: clamp(1rem, 3vw, 1.2rem);
	font-weight: bold;
	cursor: pointer;
	transition: all 0.2s ease;
	max-width: 300px;
	align-self: flex-start;
}

form > button[type="submit"]:hover {
	background-color: #038f5a;
	transform: translateY(-2px);
	box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

form > button[type="submit"]:active {
	transform: translateY(0);
}

/* === RESPONSIVE ADJUSTMENTS === */

/* Tablet (768px und größer) */
@media (min-width: 768px) {
	.date-inputs {
		flex-direction: row;
		gap: var(--spacing-lg);
	}

	.date-input-row {
		flex: 1;
	}

	.date-input-row input[type="date"] {
		max-width: 100%;
	}

	#chart {
		min-height: 500px;
	}

	form > button[type="submit"] {
		max-width: 400px;
	}
}

/* Desktop (1024px und größer) */
@media (min-width: 1024px) {
	#chart {
		min-height: 600px;
	}

	form > button[type="submit"] {
		max-width: 500px;
		padding: 0.75rem 2rem;
	}
}

/* Mobile (480px und kleiner) */
@media (max-width: 480px) {
	.date-inputs {
		gap: var(--spacing-sm);
	}

	.date-input-row {
		flex-direction: column;
		align-items: flex-start;
	}

	.date-input-row input[type="date"] {
		width: 100%;
		max-width: 100%;
	}

	.radio-group {
		gap: var(--spacing-md);
	}

	#chart {
		min-height: 350px;
	}

	form > button[type="submit"] {
		width: 100%;
		max-width: 100%;
		font-size: 1rem;
	}
}

/* === BUTTON GRID (für Smarthome Buttons) === */

.button-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
	gap: var(--spacing-md);
	margin: var(--spacing-md) 0;
}

.button-grid .btn {
	width: 100%;
	padding: var(--spacing-md) var(--spacing-sm);
	align-self: auto;
	text-align: center;
	font-size: clamp(0.9rem, 2vw, 1rem);
}

.button-grid .btn:hover {
	background-color: #ddd;
	transform: translateY(-2px);
}

/* Tablet und Desktop: maximal 2 Buttons nebeneinander */
@media (min-width: 600px) {
	.button-grid {
		grid-template-columns: repeat(2, 1fr);
	}
}

/* Mobile: 1 Button pro Zeile */
@media (max-width: 599px) {
	.button-grid {
		grid-template-columns: 1fr;
	}
}