/* ============================================================================
   UC2/openUC2 Standalone CSS Framework
   Works completely offline on ESP32 AP - no Bootstrap/CDN required
   ============================================================================ */

/* Reset and Base */
*, *::before, *::after { box-sizing: border-box; }

:root {
  --uc2-blue: #023773;
  --uc2-green: #85b918;
  --uc2-turquoise: #1f9c7c;
  --uc2-light: #faf9f9;
  --uc2-grey: #666666;
  --uc2-grey-light: #999999;
  --uc2-border: #dddddd;
  --uc2-white: #ffffff;
  --uc2-danger: #dc3545;
  --uc2-warning: #ffc107;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--uc2-grey);
  background-color: var(--uc2-light);
  margin: 0;
  padding: 0;
  min-height: 100vh;
}

/* Typography */
h1, h2, h3, h4, h5, h6 { color: var(--uc2-blue); margin: 0 0 0.5rem 0; font-weight: 600; }
h1 { font-size: 2rem; }
h2 { font-size: 1.75rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }
h5 { font-size: 1rem; }
h6 { font-size: 0.875rem; }

p { margin: 0 0 1rem 0; }
small { font-size: 0.8rem; color: var(--uc2-grey-light); }

a { color: var(--uc2-blue); text-decoration: none; }
a:hover { color: var(--uc2-turquoise); }

/* ============================================================================
   Navigation
   ============================================================================ */
.navbar {
  background: var(--uc2-blue);
  padding: 0.5rem 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.navbar a,
.navbar-brand,
.nav-link { 
  color: #fff !important; 
  text-decoration: none; 
  padding: 0.5rem 0.75rem;
  display: inline-block;
}
.navbar a:hover,
.nav-link:hover { color: var(--uc2-turquoise) !important; }
.navbar a.active,
.nav-link.active { color: var(--uc2-green) !important; }
.navbar-brand { font-weight: bold; font-size: 1.2rem; }

.nav-links,
.navbar-nav { 
  display: flex; 
  flex-wrap: wrap; 
  gap: 0.25rem; 
  list-style: none;
  margin: 0;
  padding: 0;
}
.navbar-nav .nav-item { list-style: none; }

/* Mobile nav toggle - hidden by default, show in responsive */
.navbar-toggler { display: none; }
.navbar-collapse { display: flex; }

/* ============================================================================
   Layout - Container and Grid
   ============================================================================ */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
  width: 100%;
}

.container-fluid {
  width: 100%;
  padding: 0 1rem;
}

.row {
  display: flex;
  flex-wrap: wrap;
  margin: 0 -0.5rem;
}

/* Columns */
[class*="col-"] {
  padding: 0.5rem;
  width: 100%;
}
.col-md-4 { flex: 0 0 33.333%; max-width: 33.333%; }
.col-md-6 { flex: 0 0 50%; max-width: 50%; }
.col-md-8 { flex: 0 0 66.666%; max-width: 66.666%; }
.col-lg-4 { flex: 0 0 33.333%; max-width: 33.333%; }
.col-lg-6 { flex: 0 0 50%; max-width: 50%; }
.col-lg-8 { flex: 0 0 66.666%; max-width: 66.666%; }
.col-12 { flex: 0 0 100%; max-width: 100%; }

/* Custom layout */
.col-left { flex: 1; min-width: 280px; max-width: 350px; }
.col-right { flex: 2; min-width: 300px; }

/* ============================================================================
   Cards
   ============================================================================ */
.card {
  background: var(--uc2-white);
  border: 1px solid var(--uc2-border);
  border-radius: 8px;
  margin-bottom: 1rem;
  overflow: hidden;
}

.card-header {
  background: #f8f9fa;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--uc2-border);
  font-weight: 600;
  color: var(--uc2-blue);
}

.card-body {
  padding: 1rem;
}

.card-footer {
  background: #f8f9fa;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--uc2-border);
}

/* ============================================================================
   Form Elements
   ============================================================================ */
label {
  display: block;
  margin-bottom: 0.25rem;
  font-weight: 500;
  color: var(--uc2-blue);
}

input[type="text"],
input[type="number"],
input[type="email"],
input[type="password"],
textarea,
select,
.form-control,
.form-select {
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: 1rem;
  border: 1px solid var(--uc2-border);
  border-radius: 4px;
  background-color: var(--uc2-white);
  color: var(--uc2-grey);
  transition: border-color 0.15s;
}

input:focus,
textarea:focus,
select:focus,
.form-control:focus,
.form-select:focus {
  outline: none;
  border-color: var(--uc2-blue);
  box-shadow: 0 0 0 2px rgba(2, 55, 115, 0.1);
}

input:disabled,
select:disabled,
.form-control:disabled {
  background-color: #e9ecef;
  cursor: not-allowed;
}

/* Input Group */
.input-group {
  display: flex;
  align-items: stretch;
}
.input-group input,
.input-group .form-control {
  border-radius: 4px 0 0 4px;
  flex: 1;
}
.input-group-text,
.input-group .suffix {
  background: #e9ecef;
  border: 1px solid var(--uc2-border);
  border-left: none;
  padding: 0.5rem 0.75rem;
  border-radius: 0 4px 4px 0;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
}

/* Range/Slider */
input[type="range"],
.slider {
  width: 100%;
  margin: 0.5rem 0;
  cursor: pointer;
}

/* Form Group */
.form-group,
.mb-3 {
  margin-bottom: 1rem;
}

/* Checkbox/Radio as toggle buttons */
.btn-group {
  display: flex;
  width: 100%;
}
.btn-group input[type="radio"],
.btn-group input[type="checkbox"] {
  display: none;
}
.btn-group label {
  flex: 1;
  text-align: center;
  padding: 0.5rem;
  background: var(--uc2-white);
  border: 1px solid var(--uc2-blue);
  cursor: pointer;
  margin: 0;
  font-weight: normal;
  transition: all 0.15s;
}
.btn-group label:first-of-type { border-radius: 4px 0 0 4px; }
.btn-group label:last-of-type { border-radius: 0 4px 4px 0; border-left: none; }
.btn-group input[type="radio"]:checked + label,
.btn-group input[type="checkbox"]:checked + label {
  background: var(--uc2-blue);
  color: #fff;
}

/* ============================================================================
   Buttons
   ============================================================================ */
.btn,
.Button {
  display: inline-block;
  padding: 0.5rem 1rem;
  font-size: 1rem;
  font-weight: 500;
  text-align: center;
  text-decoration: none;
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
  line-height: 1.5;
}

.btn:disabled,
.Button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn:hover:not(:disabled),
.Button:hover:not(:disabled) {
  opacity: 0.9;
}

/* Button variants */
.btn-primary,
.Button {
  background-color: var(--uc2-blue);
  color: #fff;
  border-color: var(--uc2-blue);
}
.btn-primary:hover { background-color: #012a5c; }

.btn-success {
  background-color: var(--uc2-green);
  color: #fff;
  border-color: var(--uc2-green);
}

.btn-danger {
  background-color: var(--uc2-danger);
  color: #fff;
  border-color: var(--uc2-danger);
}

.btn-warning {
  background-color: var(--uc2-warning);
  color: #212529;
  border-color: var(--uc2-warning);
}

.btn-secondary {
  background-color: #6c757d;
  color: #fff;
  border-color: #6c757d;
}

.btn-info {
  background-color: var(--uc2-turquoise);
  color: #fff;
  border-color: var(--uc2-turquoise);
}

.btn-outline-primary,
.btn-outline {
  background: var(--uc2-white);
  border: 1px solid var(--uc2-blue);
  color: var(--uc2-blue);
}
.btn-outline-primary:hover,
.btn-outline:hover {
  background: var(--uc2-blue);
  color: #fff;
}

.btn-outline-secondary {
  background: var(--uc2-white);
  border: 1px solid #6c757d;
  color: #6c757d;
}

/* Button sizes */
.btn-sm { padding: 0.25rem 0.5rem; font-size: 0.875rem; }
.btn-lg { padding: 0.75rem 1.5rem; font-size: 1.25rem; }

/* Full width button */
.btn-block { width: 100%; display: block; }

/* ============================================================================
   Tables
   ============================================================================ */
.table,
.data-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1rem;
}

.table th,
.table td,
.data-table th,
.data-table td {
  padding: 0.75rem;
  border-bottom: 1px solid var(--uc2-border);
  text-align: left;
}

.table th {
  background: #f8f9fa;
  font-weight: 600;
  color: var(--uc2-blue);
}

.table-striped tbody tr:nth-of-type(odd) {
  background-color: rgba(0, 0, 0, 0.02);
}

/* ============================================================================
   Alerts & Info Boxes
   ============================================================================ */
.alert,
.info-box {
  padding: 0.75rem 1rem;
  border-radius: 4px;
  margin-bottom: 1rem;
}

.alert-info,
.info-box {
  background: #e7f3ff;
  border-left: 4px solid var(--uc2-blue);
  color: var(--uc2-blue);
}

.alert-success {
  background: #d4edda;
  border-left: 4px solid var(--uc2-green);
  color: #155724;
}

.alert-warning {
  background: #fff3cd;
  border-left: 4px solid var(--uc2-warning);
  color: #856404;
}

.alert-danger {
  background: #f8d7da;
  border-left: 4px solid var(--uc2-danger);
  color: #721c24;
}

/* ============================================================================
   Status Indicators
   ============================================================================ */
.status-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.status-dot,
.status-indicator {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #6c757d;
  border: 2px solid #dee2e6;
}

.status-dot.running,
.status-indicator.running {
  background: var(--uc2-green);
  animation: pulse 1s infinite;
}

.status-dot.error {
  background: var(--uc2-danger);
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ============================================================================
   Badges
   ============================================================================ */
.badge {
  display: inline-block;
  padding: 0.25em 0.5em;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 4px;
}

.badge-primary,
.bg-primary { background: var(--uc2-blue); color: #fff; }
.badge-success,
.bg-success { background: var(--uc2-green); color: #fff; }
.badge-danger,
.bg-danger { background: var(--uc2-danger); color: #fff; }
.badge-warning,
.bg-warning { background: var(--uc2-warning); color: #212529; }
.badge-secondary,
.bg-secondary { background: #6c757d; color: #fff; }

/* ============================================================================
   Special Display Elements
   ============================================================================ */
.ratio-display {
  font-size: 3rem;
  font-weight: bold;
  color: var(--uc2-blue);
  text-align: center;
  padding: 1.5rem;
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  border-radius: 10px;
  margin: 0.5rem 0;
  font-family: "Courier New", monospace;
}
.ratio-display.positive { color: var(--uc2-green); }
.ratio-display.negative { color: var(--uc2-danger); }

.intensity-value {
  font-size: 2.5rem;
  font-weight: bold;
  color: var(--uc2-blue);
  font-family: "Courier New", monospace;
}

/* ============================================================================
   Footer
   ============================================================================ */
footer {
  background: var(--uc2-blue);
  color: #fff;
  text-align: center;
  padding: 1rem;
  margin-top: 2rem;
  font-size: 0.85rem;
}

footer a {
  color: #fff;
}

/* ============================================================================
   Utility Classes
   ============================================================================ */
/* Margin */
.m-0 { margin: 0 !important; }
.m-1 { margin: 0.25rem !important; }
.m-2 { margin: 0.5rem !important; }
.m-3 { margin: 1rem !important; }
.m-4 { margin: 1.5rem !important; }
.m-5 { margin: 3rem !important; }

.mt-0 { margin-top: 0 !important; }
.mt-1 { margin-top: 0.25rem !important; }
.mt-2 { margin-top: 0.5rem !important; }
.mt-3 { margin-top: 1rem !important; }
.mt-4 { margin-top: 1.5rem !important; }

.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: 0.25rem !important; }
.mb-2 { margin-bottom: 0.5rem !important; }
.mb-3 { margin-bottom: 1rem !important; }
.mb-4 { margin-bottom: 1.5rem !important; }
.mb-5 { margin-bottom: 3rem !important; }

.ms-auto { margin-left: auto !important; }
.me-auto { margin-right: auto !important; }

/* Padding */
.p-0 { padding: 0 !important; }
.p-1 { padding: 0.25rem !important; }
.p-2 { padding: 0.5rem !important; }
.p-3 { padding: 1rem !important; }
.p-4 { padding: 1.5rem !important; }
.p-5 { padding: 3rem !important; }

.py-2 { padding-top: 0.5rem !important; padding-bottom: 0.5rem !important; }
.py-3 { padding-top: 1rem !important; padding-bottom: 1rem !important; }
.px-3 { padding-left: 1rem !important; padding-right: 1rem !important; }

/* Text alignment */
.text-center { text-align: center !important; }
.text-left { text-align: left !important; }
.text-right { text-align: right !important; }

/* Text styling */
.fw-bold { font-weight: bold !important; }
.fw-normal { font-weight: normal !important; }
.text-muted { color: var(--uc2-grey-light) !important; }
.lead { font-size: 1.25rem; font-weight: 300; }

/* Display */
.d-none { display: none !important; }
.d-block { display: block !important; }
.d-flex { display: flex !important; }
.d-inline { display: inline !important; }
.d-inline-block { display: inline-block !important; }

.flex-wrap { flex-wrap: wrap !important; }
.justify-content-between { justify-content: space-between !important; }
.justify-content-center { justify-content: center !important; }
.align-items-center { align-items: center !important; }
.gap-1 { gap: 0.25rem !important; }
.gap-2 { gap: 0.5rem !important; }
.gap-3 { gap: 1rem !important; }

/* Width */
.w-100 { width: 100% !important; }
.w-auto { width: auto !important; }

/* Shadow */
.shadow-sm { box-shadow: 0 2px 4px rgba(0,0,0,0.075) !important; }
.shadow { box-shadow: 0 4px 8px rgba(0,0,0,0.1) !important; }

/* Border radius */
.rounded { border-radius: 4px !important; }
.rounded-lg { border-radius: 8px !important; }

/* ============================================================================
   Responsive Design
   ============================================================================ */
@media (max-width: 992px) {
  .col-lg-4, .col-lg-6, .col-lg-8 { flex: 0 0 100%; max-width: 100%; }
  .navbar-collapse { flex-basis: 100%; }
}

@media (max-width: 768px) {
  .col-md-4, .col-md-6, .col-md-8 { flex: 0 0 100%; max-width: 100%; }
  .col-left, .col-right { max-width: 100%; flex: 1 1 100%; }
  
  h1 { font-size: 1.5rem; }
  .ratio-display { font-size: 2rem; padding: 1rem; }
  .intensity-value { font-size: 2rem; }
  
  .navbar {
    flex-direction: column;
    align-items: flex-start;
  }
  .nav-links, .navbar-nav {
    flex-direction: column;
    width: 100%;
    margin-top: 0.5rem;
  }
  .nav-links a, .navbar-nav .nav-link {
    padding: 0.5rem 0;
  }
}

/* ============================================================================
   Legacy Grid Support (for messung.html etc.)
   ============================================================================ */
.grid-container {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 1rem;
  margin: auto;
  padding: 0;
}

.grid1 { grid-area: 1 / 1 / 5 / 2; padding: 1rem; }
.grid2, .grid3, .grid4, .grid5, .grid6 { padding: 1rem; }

.inputField {
  background-color: #fff;
  padding: 10px;
  margin: 5px 0;
  border-radius: 4px;
  border: 1px solid #ddd;
}

.inputFieldWide { width: 100%; }

/* ============================================================================
   Dropdown Menu (simplified)
   ============================================================================ */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu {
  display: none;
  position: absolute;
  background: #fff;
  border: 1px solid var(--uc2-border);
  border-radius: 4px;
  min-width: 150px;
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
  z-index: 1000;
  list-style: none;
  padding: 0.5rem 0;
  margin: 0;
}
.dropdown:hover .dropdown-menu,
.dropdown-menu.show { display: block; }
.dropdown-item {
  display: block;
  padding: 0.5rem 1rem;
  color: var(--uc2-grey);
  text-decoration: none;
}
.dropdown-item:hover {
  background: #f8f9fa;
  color: var(--uc2-blue);
}
