/*
 * static/css/app.css
 * Główny arkusz stylów pH Monitor
 * Paleta: ciemno-granatowe tło, jasne litery
 */

@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@300;400;500;600;700&family=Syne:wght@400;500;600;700;800&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Sansation:wght@300;400;500;600;700');

/* ── Zmienne ────────────────────────────────────────────────────────────────── */
:root {
    --bg:          #0b1528;
    --surface:     #112040;
    --surface2:    #163055;
    --surface3:    #1c3d6a;
    --border:      #1e4a7a;
    --border2:     #2a5f99;

    --accent:      #5bc8ff;
    --accent-dim:  rgba(91, 200, 255, 0.18);
    --accent2:     #4dffa0;
    --accent2-dim: rgba(77, 255, 160, 0.15);
    --warning:     #ffd166;
    --danger:      #ff5c6e;

    --text:        #e8f4ff;
    --text-dim:    #a8c8e8;
    --muted:       #5a82a8;

    --mono:   'Sansation', 'Syne', 'JetBrains Mono', monospace;
    --sans:   'Sansation', 'Syne', 'JetBrains Mono', sans-serif;

    --radius: 10px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
}

/* ── Reset ──────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

/* ── Body ───────────────────────────────────────────────────────────────────── */
body {
    background-color: var(--bg);
    background-image:
        radial-gradient(ellipse at 15% 10%, rgba(91, 200, 255, 0.07) 0%, transparent 55%),
        radial-gradient(ellipse at 85% 85%, rgba(77, 255, 160, 0.05) 0%, transparent 55%),
        radial-gradient(ellipse at 50% 50%, rgba(17, 32, 64, 0.6) 0%, transparent 80%);
    font-family: var(--sans);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ── Nawigacja ──────────────────────────────────────────────────────────────── */
nav {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    display: flex;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 0;
    margin-right: 24px;
    text-decoration: none;
}

.nav-brand img { width: 32px; height: 32px; }

.nav-brand-text {
    font-size: 17px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    white-space: nowrap;
}

.nav-links { display: flex; gap: 2px; flex: 1; }

.nav-link {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 7px;
    color: var(--text-dim);
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.15s;
    white-space: nowrap;
    border: 1px solid transparent;
}

.nav-link svg { flex-shrink: 0; }
.nav-link:hover { background: var(--surface3); color: var(--text); }
.nav-link.active {
    background: var(--accent-dim);
    color: var(--accent);
    border-color: rgba(91, 200, 255, 0.25);
}

.nav-logout {
    margin-left: auto;
    font-size: 12px;
    color: var(--muted);
    text-decoration: none;
    padding: 6px 12px;
    border-radius: 6px;
    border: 1px solid var(--border);
    transition: all 0.15s;
}

.nav-logout:hover { color: var(--danger); border-color: var(--danger); }

/* ── Treść główna ───────────────────────────────────────────────────────────── */
main {
    flex: 1;
    padding: 28px 24px;
    max-width: 1600px;
    width: 100%;
    margin: 0 auto;
}

/* ── Nagłówek strony ────────────────────────────────────────────────────────── */
.page-header { margin-bottom: 24px; }
.page-header h1 { font-size: 22px; font-weight: 800; color: var(--text); }
.page-header p  { font-size: 13px; color: var(--text-dim); margin-top: 4px; }

/* ── Karty ──────────────────────────────────────────────────────────────────── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
}

.card-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--muted);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-title svg { color: var(--accent); }

/* ── Karty statystyk ────────────────────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    inset: 0 0 auto 0;
    height: 2px;
    background: linear-gradient(90deg, var(--accent), var(--accent2));
}

.stat-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--muted);
    margin-bottom: 6px;
}

.stat-value {
    font-family: var(--mono);
    font-size: 22px;
    font-weight: 700;
    color: var(--accent);
}

.stat-unit { font-size: 11px; color: var(--muted); margin-left: 4px; }

.stat-sub {
    font-size: 11px;
    color: var(--text-dim);
    margin-top: 4px;
    font-family: var(--mono);
}

/* ── Tabela ─────────────────────────────────────────────────────────────────── */
.table-wrap {
    overflow-x: auto;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    font-family: var(--mono);
}

thead th {
    background: var(--surface2);
    padding: 10px 14px;
    text-align: left;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-dim);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    transition: color 0.15s;
}

thead th:hover { color: var(--accent); }
thead th.sort-asc::after  { content: ' ↑'; color: var(--accent); }
thead th.sort-desc::after { content: ' ↓'; color: var(--accent); }

tbody tr {
    border-bottom: 1px solid rgba(30, 74, 122, 0.35);
    transition: background 0.1s;
}

tbody tr:last-child  { border-bottom: none; }
tbody tr:hover       { background: var(--surface2); }

tbody td { padding: 9px 14px; color: var(--text); }

.td-ts   { color: var(--text-dim); font-size: 12px; }
.td-num  { color: var(--accent); }
.td-num2 { color: var(--accent2); }

/* ── Przyciski ──────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 7px;
    font-family: var(--sans);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.15s;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), #2299cc);
    color: #0b1528;
}

.btn-primary:hover { opacity: 0.9; transform: translateY(-1px); }

.btn-outline {
    background: transparent;
    border: 1px solid var(--border2);
    color: var(--text-dim);
}

.btn-outline:hover { border-color: var(--accent); color: var(--accent); }

.btn-sm { padding: 5px 10px; font-size: 12px; }

.btn-danger {
    background: rgba(255, 92, 110, 0.15);
    border: 1px solid rgba(255, 92, 110, 0.35);
    color: var(--danger);
}

.btn-danger:hover { background: rgba(255, 92, 110, 0.28); }

/* ── Formularze ─────────────────────────────────────────────────────────────── */
.form-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: flex-end;
    margin-bottom: 16px;
}

.form-group { display: flex; flex-direction: column; gap: 6px; }

.form-group label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--muted);
}

.form-group input,
.form-group select {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 7px;
    padding: 8px 12px;
    color: var(--text);
    font-family: var(--mono);
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s;
}

.form-group input::placeholder { color: var(--muted); }
.form-group input:focus,
.form-group select:focus { border-color: var(--accent); }

.form-group select option { background: var(--surface2); }

/* ── Alerty ─────────────────────────────────────────────────────────────────── */
.alert {
    padding: 10px 16px;
    border-radius: 7px;
    font-size: 13px;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.alert-success { background: rgba(77, 255, 160, 0.10); border: 1px solid rgba(77, 255, 160, 0.28); color: var(--accent2); }
.alert-danger  { background: rgba(255, 92, 110, 0.10); border: 1px solid rgba(255, 92, 110, 0.28); color: var(--danger);  }
.alert-info    { background: rgba(91, 200, 255, 0.10); border: 1px solid rgba(91, 200, 255, 0.28); color: var(--accent);  }

/* ── Odznaki ────────────────────────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-ok  { background: var(--accent2-dim); color: var(--accent2); }
.badge-err { background: rgba(255, 92, 110, 0.15); color: var(--danger); }
.badge-warn { background: rgba(255, 209, 102, 0.15); color: var(--warning); }

/* ── Tooltip ────────────────────────────────────────────────────────────────── */
[data-tip] { position: relative; }

[data-tip]::after {
    content: attr(data-tip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--surface3);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 4px 8px;
    border-radius: 5px;
    font-size: 11px;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
    z-index: 50;
}

[data-tip]:hover::after { opacity: 1; }

/* ── Przełącznik kolumn ─────────────────────────────────────────────────────── */
.col-toggle-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
    align-items: center;
}

.col-toggle-label {
    font-size: 11px;
    color: var(--muted);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-right: 4px;
}

.col-toggle {
    font-size: 11px;
    padding: 4px 10px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-dim);
    cursor: pointer;
    font-family: var(--sans);
    font-weight: 600;
    transition: all 0.15s;
}

.col-toggle.active {
    background: var(--accent-dim);
    border-color: var(--accent);
    color: var(--accent);
}

/* ── Stopka ─────────────────────────────────────────────────────────────────── */
footer {
    text-align: center;
    padding: 16px;
    font-size: 11px;
    color: var(--muted);
    border-top: 1px solid var(--border);
}

/* ── Wiersz ukryty (visibility view) ───────────────────────────────────────── */
.row-hidden td { opacity: 0.42; }

/* ── Przycisk oka ───────────────────────────────────────────────────────────── */
.eye-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    transition: background 0.15s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.eye-btn:hover { background: rgba(255, 255, 255, 0.06); }

/* ── Strefa drag & drop ─────────────────────────────────────────────────────── */
.drop-zone {
    border: 2px dashed var(--border2);
    border-radius: var(--radius);
    padding: 40px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.drop-zone:hover,
.drop-zone.drag-over {
    border-color: var(--accent);
    background: rgba(91, 200, 255, 0.04);
}

.drop-zone svg { display: block; margin: 0 auto 12px; }
.drop-zone input[type="file"] { position: absolute; opacity: 0; width: 1px; height: 1px; }

/* ── Blok kodu ──────────────────────────────────────────────────────────────── */
pre.code-block {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    font-family: var(--mono);
    font-size: 12px;
    color: var(--text);
    overflow-x: auto;
    line-height: 1.6;
}

/* ── Paginacja ──────────────────────────────────────────────────────────────── */
.pagination {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 14px;
    justify-content: center;
    flex-wrap: wrap;
}

.pagination-info {
    font-size: 13px;
    color: var(--text-dim);
    font-family: var(--mono);
}

/* ── Login ──────────────────────────────────────────────────────────────────── */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--bg);
    background-image:
        radial-gradient(ellipse at 20% 40%, rgba(91, 200, 255, 0.09) 0%, transparent 55%),
        radial-gradient(ellipse at 80% 60%, rgba(77, 255, 160, 0.06) 0%, transparent 55%);
}

.login-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 48px 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 0 60px rgba(91, 200, 255, 0.07);
}

.login-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 32px;
    justify-content: center;
}

.login-logo img { width: 48px; height: 48px; }

.login-logo-text {
    font-size: 24px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.login-subtitle {
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 2px;
    text-align: center;
    margin-bottom: 28px;
}

.login-field { margin-bottom: 0; }
.login-field label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
}

.login-field input {
    width: 100%;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 16px;
    color: var(--text);
    font-family: var(--mono);
    font-size: 15px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.login-field input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(91, 200, 255, 0.12);
}

.login-field input::placeholder { color: var(--muted); }

.btn-login {
    width: 100%;
    margin-top: 24px;
    padding: 14px;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    border: none;
    border-radius: 8px;
    color: #0b1528;
    font-family: var(--sans);
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s;
}

.btn-login:hover  { opacity: 0.9; }
.btn-login:active { transform: scale(0.98); }

/* ── Flatpickr override ─────────────────────────────────────────────────────── */
.flatpickr-calendar {
    background: var(--surface2) !important;
    border-color: var(--border) !important;
    box-shadow: var(--shadow) !important;
}

.flatpickr-day { color: var(--text-dim) !important; }
.flatpickr-day:hover { background: var(--surface3) !important; }
.flatpickr-day.selected { background: var(--accent) !important; color: #0b1528 !important; }
.flatpickr-months, .flatpickr-weekdays { background: var(--surface3) !important; }
.flatpickr-current-month, .flatpickr-weekday { color: var(--text) !important; }
.flatpickr-prev-month svg, .flatpickr-next-month svg { fill: var(--text-dim) !important; }

/* ── Panel rozwijany (filtry zaawansowane) ──────────────────────────────────── */
details.filter-details {
    margin-top: 4px;
}

details.filter-details > summary {
    cursor: pointer;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--accent);
    list-style: none;
    padding: 8px 0;
    display: flex;
    align-items: center;
    gap: 6px;
    user-select: none;
}

details.filter-details > summary::-webkit-details-marker { display: none; }

details.filter-details > summary::before {
    content: '▸';
    display: inline-block;
    transition: transform 0.15s;
    font-size: 10px;
}

details.filter-details[open] > summary::before {
    transform: rotate(90deg);
}

.filter-badge {
    background: var(--accent-dim);
    color: var(--accent);
    border-radius: 20px;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 8px;
    font-family: var(--mono);
}

/* ── Filtry zakresu wartości ────────────────────────────────────────────────── */
.value-filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.value-filter-group-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--muted);
    margin-bottom: 10px;
}

.value-filter-fields {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.value-filter-field label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-dim);
    margin-bottom: 5px;
}

.vf-unit {
    color: var(--muted);
    font-weight: 400;
    font-size: 11px;
}

.value-filter-inputs {
    display: flex;
    align-items: center;
    gap: 6px;
}

.value-filter-inputs input {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 7px;
    padding: 7px 10px;
    color: var(--text);
    font-family: var(--mono);
    font-size: 12px;
    outline: none;
    width: 100%;
    min-width: 0;
    transition: border-color 0.2s;
}

.value-filter-inputs input::placeholder { color: var(--muted); }
.value-filter-inputs input:focus { border-color: var(--accent); }

.vf-sep {
    color: var(--muted);
    font-size: 12px;
    flex-shrink: 0;
}

/* ── Chip aktywnego filtru wartości ─────────────────────────────────────────── */
.active-filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--surface2);
    border: 1px solid var(--border2);
    border-radius: 20px;
    padding: 4px 10px;
    font-size: 11px;
    font-family: var(--mono);
    color: var(--text-dim);
}

.active-filter-chip .chip-remove {
    color: var(--danger);
    text-decoration: none;
    font-weight: 700;
    margin-left: 2px;
}

.active-filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 14px;
}
