/* ====================================================================
   FINALNY MINIMALISTYCZNY DARK UI - Zwiększony Kontrast i Jaskrawy Akcent
   ==================================================================== */

:root {
    /* Ciemne tło */
    --bg-color: #1a1a2e;
    /* Jaśniejsze tło dla bloków/kart (lepszy kontrast) */
    --surface-bg: #2b3548;
    
    --text-main: #ffffff;        /* Biały tekst */
    --text-muted: #c3c9d7;       /* Jasnoszary tekst pomocniczy */
    
    /* Jaskrawy Akcent: Nowy, wyraźny niebieski */
    --primary-vivid: #00bcd4;
    --primary-vivid-hover: #00a0b0;

    /* Ciemniejsza linia/ramka */
    --border: #445570;
    --danger: #d9534f; /* Blado-czerwony */
    --shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    font-family: sans-serif;
    margin: 0;
    padding: 20px;
}

/* --- KONTENERY (main-box i box-table) --- */
/* Zastąpienie starych klas nowymi (energia-box, energia-box-logowanie)*/
.energia-box, .energia-box-logowanie {
    background-color: var(--surface-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
	overflow-x: auto;   /* przewijanie w poziomie */
    box-shadow: var(--shadow);
    padding: 15px;
    margin: 15px auto;
}

.energia-box {
    max-width: 600px;
}

.energia-box-logowanie {
    max-width: 350px;
    text-align: center;
    padding: 20px;
}

.energia-tabela {
  width: 100%;          /* tabela zajmuje całą dostępną szerokość */
  max-width: 600px;    /* maksymalna szerokość tabeli */
  border-collapse: collapse;
  margin: 0 auto;       /* wyśrodkowanie tabeli */
}


/* --- TYPOGRAFIA i LINKI --- */
h1 {
    color: var(--primary-vivid);
    margin: 0 0 10px 0;
    font-size: 1.8em;
}

h2 {
    color: var(--primary-vivid);
    margin: 10px 0;
    font-size: 1.5em;
}

a {
    color: var(--primary-vivid);
    text-decoration: none;
    transition: 0.2s;
}
a:hover {
    text-decoration: underline;
}

.error-message {
    color: var(--danger);
    background: #3a0000;
    border: 1px solid var(--danger);
    padding: 8px;
    margin-bottom: 10px;
    border-radius: 4px;
    text-align: center;
}

/* --- FORMULARZE I INPUTY --- */
.form-table {
    width: 100%;
    border-collapse: collapse;
}
.form-table td {
    padding: 4px 6px;   /* było np. 8–10px, zmniejszamy */
    border-top: 1px solid var(--border);
	line-height: 1.2;   /* ciaśniejsze wiersze */
}

.label-td {
    color: var(--text-muted);
    font-size: 0.95em;
    width: 40%; /* Zmienione na 40% dla lepszego dopasowania formularza dodawania */
    text-align: right;
    padding-right: 10px;
    vertical-align: top;
    font-weight: bold;
}

input[type="text"],
input[type="password"],
input[type="date"],
input[type="number"],
select {
    width: 95%;
    padding: 8px 10px; /* Zwiększony padding dla lepszego wyglądu */
    /* Tło inputów jeszcze ciemniejsze niż tło strony, by się nie zlewało */
    background-color: #121a28;
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-main);
    font-family: inherit;
    box-sizing: border-box;
    transition: border-color 0.2s;
}

input[name="stan_w"] {
  background: #2a2a3e;   /* lekko inne tło niż pozostałe */
  color: #f0f0f0;
  border: 2px solid #444466;
}

input:focus, select:focus {
    border-color: var(--primary-vivid);
    outline: none;
}

/* --- PRZYCISKI GŁÓWNE --- */
.btn-primary {
    display: inline-block;
    padding: 8px 15px;
    border-radius: 4px;
    border: none;
    font-weight: bold;
    cursor: pointer;
    font-size: 0.9rem;
    text-align: center;
    background: var(--primary-vivid);
    color: var(--surface-bg); /* Ciemny tekst na jaskrawym akcencie */
    transition: background 0.2s;
}
.btn-primary:hover {
    background: var(--primary-vivid-hover);
    text-decoration: none;
}
.btn-primary.green { /* Styl dla przycisku Rejestracja */
    background: #28a745;
}
.btn-primary.green:hover {
    background: #218838;
}

#btnTop {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: #4a90e2;   /* niebieskie tło */
  color: #fff;           /* biały tekst */
  border: none;
  border-radius: 8px;    /* lekko zaokrąglone rogi */
  padding: 10px 16px;    /* więcej miejsca na tekst */
  font-size: 14px;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
  z-index: 9999;         /* zawsze na wierzchu */
  display: none;         /* domyślnie ukryty */
}

#btnTop:hover {
  background: #5aa0f0;   /* jaśniejszy niebieski przy hover */
}


/* ====================================================================
   PRZYCISK USUŃ (klasa: btn-del)
   ==================================================================== */

.btn-del {
    padding: 4px 8px;
    font-size: 0.8em;
    /* Tło blado-czerwone */
    background: var(--danger);
    color: white;
    border: 1px solid var(--danger);
    border-radius: 4px;
    cursor: pointer;
    transition: 0.2s;
    font-weight: bold;
}
.btn-del:hover {
    /* Ciemniejszy czerwony po najechaniu */
    background: #c9302c;
    border-color: #c9302c;
    color: white;
}

/* --- USTAWIENIA WIDOKU i TABELA DANYCH (energia-tabela) --- */
.ustawienia-form {
    display: flex;
    flex-wrap: wrap; /* Zapewnia, że elementy się łamią na mniejszych ekranach */
    gap: 15px;
    justify-content: center;
    align-items: center;
    padding: 10px;
}
.ustawienia-form label {
    color: var(--text-muted);
    font-size: 0.95em;
    margin-right: 5px;
}
.ustawienia-form select {
    width: auto;
    min-width: 100px;
    padding: 5px;
}

.sekcja-tytul {
  color: #f0f0f0;
  padding: 6px 10px;
  margin-bottom: 10px;
  border-radius: 4px;
  text-align: center;
  font-size: 15px;
}

/* TABELA WYNIKÓW */
.energia-tabela {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9em;
    margin-top: 20px;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: var(--shadow);
    background-color: var(--surface-bg);
}

.tabela-naglowek {
    background-color: #1f2a3a; /* Ciemniejszy nagłówek dla kontrastu */
    color: var(--primary-vivid);
    padding: 10px 15px;
    margin: 0;
    font-size: 1.1em;
    font-weight: normal;
    text-align: center;
    border-bottom: 1px solid var(--border);
}

.energia-tabela thead th {
    text-align: center;
    padding: 8px 5px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    font-weight: normal;
}

.energia-tabela tbody td {
    padding: 8px 5px;
    border-bottom: 1px solid var(--border);
    text-align: center;
}
.energia-tabela tbody tr:last-child td {
    border-bottom: none; /* Usuwamy dolną ramkę dla ostatniego wiersza */
}
.energia-tabela tbody tr:hover td {
    background-color: rgba(255,255,255, 0.05);
}

/* Pola wyboru i wpisywania danych */
.form-table input[type="date"],
.form-table input[type="number"],
.form-table select {
  background: #1a1a2e;
  color: #f0f0f0;
  border: 2px solid #444466;
  border-radius: 4px;
  padding: 4px 6px;
}

/* Pole Licznik – węższe */
select[name="licz1"] {
  width: 140px;   /* ustaw węższą szerokość */
  max-width: 160px;
}

/* Pole Godzina – też kompaktowe */
select[name="godz_w"] {
  width: 80px;
}

/* Pole Stan licznika – trochę szersze */
input[name="stan_w"] {
  width: 120px;
}

/* Pola Okres i Ilość w drugim formularzu */
select[name="okres"],
select[name="ilosc"] {
  width: 100px;
}

/* Dodatkowe style */
hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 15px 0;
}

/* ====================================================================
   TABY - Historia i Wykres
   ==================================================================== */

.tabs-container {
    max-width: 600px;
    margin: 20px auto;
    background: linear-gradient(135deg, #1a1a2e 0%, #232338 100%);
    border: 3px solid #00bfff;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 8px 25px rgba(0, 191, 255, 0.3);
}

.tabs-header {
    display: flex;
    background: rgba(0, 0, 0, 0.3);
    border-bottom: 3px solid #00bfff;
}

.tab-btn {
    flex: 1;
    padding: 15px;
    background: transparent;
    color: #00bfff;
    border: none;
    cursor: pointer;
    font-size: 1em;
    font-weight: 600;
    transition: all 0.3s;
    text-transform: uppercase;
}

.tab-btn:hover {
    background: rgba(0, 191, 255, 0.1);
}

.tab-btn.active {
    background: linear-gradient(135deg, #00bfff, #00ffcc);
    color: #1a1a2e;
    box-shadow: 0 0 15px rgba(0, 191, 255, 0.6);
}

.tab-content {
    display: none;
    padding: 20px;
}

.tab-content.active {
    display: block;
}

.historia-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

.historia-table th {
    background: rgba(0, 191, 255, 0.2);
    color: #00bfff;
    padding: 10px;
    text-align: left;
    border-bottom: 2px solid #00bfff;
    font-weight: 600;
}

.historia-table td {
    padding: 10px;
    border-bottom: 1px solid #333;
    color: #f0f0f0;
}

.historia-table tr:hover {
    background: rgba(0, 191, 255, 0.1);
}

.btn-delete {
    background: #ff4444;
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.85em;
    transition: all 0.3s;
}

.btn-delete:hover {
    background: #ff0000;
    box-shadow: 0 0 10px rgba(255, 0, 0, 0.5);
}

/* ====================================================================
   PRZYCISK MIKROFONU
   ==================================================================== */

.btn-microphone {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #ff9800, #ff6f00);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 10px;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-shadow: 0 4px 10px rgba(255, 107, 0, 0.3);
}

.btn-microphone:hover {
    background: linear-gradient(135deg, #ff6f00, #ff5500);
    box-shadow: 0 6px 15px rgba(255, 107, 0, 0.5);
}

.btn-microphone.recording {
    background: linear-gradient(135deg, #ff0000, #cc0000);
    box-shadow: 0 0 20px rgba(255, 0, 0, 0.8);
    animation: pulse 0.5s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.status-mikrofon {
    color: #ffa500;
    font-size: 0.9em;
    min-height: 20px;
    margin-bottom: 8px;
    font-style: italic;
    text-align: center;
}

.status-mikrofon.success {
    color: #00ff00;
}

.status-mikrofon.error {
    color: #ff4444;
}

/* ====================================================================
   MODAL - Statystyki
   ==================================================================== */

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
}

.modal-content {
    background: linear-gradient(135deg, #1a1a2e 0%, #232338 100%);
    margin: 5% auto;
    padding: 25px;
    border: 3px solid #00bfff;
    border-radius: 15px;
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 191, 255, 0.5);
}

.modal-close {
    color: #aaa;
    float: right;
    font-size: 32px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
}

.modal-close:hover {
    color: #00ffcc;
    transform: scale(1.2);
}

.modal-table {
    width: 100%;
    border-collapse: collapse;
    margin: 15px 0;
}

.modal-table th {
    background: rgba(0, 191, 255, 0.2);
    color: #00bfff;
    padding: 12px;
    text-align: left;
    border-bottom: 2px solid #00bfff;
}

.modal-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #333;
    color: #f0f0f0;
}

.modal-table tr:hover {
    background: rgba(0, 191, 255, 0.1);
}

.modal-section {
    margin: 25px 0;
}

.modal-section-title {
    color: #00bfff;
    font-size: 1.2em;
    font-weight: bold;
    margin-bottom: 15px;
    padding-bottom: 8px;
    border-bottom: 2px solid #007bb5;
}

/* ====================================================================
   STATYSTYKI - Karty
   ==================================================================== */

.statystyki-box {
    background: linear-gradient(135deg, #1a1a2e 0%, #232338 100%);
    border: 3px solid #00bfff;
    padding: 20px;
    margin: 20px auto;
    border-radius: 15px;
    max-width: 600px;
    box-shadow: 0 8px 25px rgba(0, 191, 255, 0.3);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-bottom: 15px;
}

.stat-card {
    background: rgba(35, 35, 56, 0.8);
    border: 2px solid #00bfff;
    border-radius: 10px;
    padding: 15px 10px;
    text-align: center;
    transition: all 0.3s ease;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.stat-card:hover {
    transform: translateY(-5px);
    border-color: #00ffcc;
    box-shadow: 0 8px 20px rgba(0, 191, 255, 0.5);
}

.stat-card-title {
    color: #00bfff;
    font-size: 0.85em;
    font-weight: 600;
    margin-bottom: 8px;
    text-transform: uppercase;
}

.stat-card-value {
    color: #00ffcc;
    font-size: 1.4em;
    font-weight: bold;
    margin: 5px 0;
}

.stat-card-sub {
    color: #aaa;
    font-size: 0.75em;
    margin-top: 3px;
}

.stat-title {
    text-align: center;
    color: #00bfff;
    font-size: 1.3em;
    font-weight: bold;
    margin-bottom: 20px;
    border-bottom: 3px solid #00bfff;
    padding-bottom: 12px;
    text-shadow: 0 2px 8px rgba(0, 191, 255, 0.5);
}

.btn-show-details {
    display: block;
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #007bb5, #00bfff);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 10px rgba(0, 123, 181, 0.3);
}

.btn-show-details:hover {
    background: linear-gradient(135deg, #00bfff, #00ffcc);
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(0, 191, 255, 0.5);
}

/* Responsive */
@media (max-width: 600px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .energia-box {
        max-width: 100%;
    }
}