/* --------------------------------------
 * 1. GLOBALNE STYLE I WIDOK GŁÓWNY
 * -------------------------------------- */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    background-color: #f4f7fa; /* Bardzo jasne tło */
    color: #333;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 50px;
}

.main-content {
    flex-grow: 0;
    width: 100%;
    max-width: 800px;
    padding: 30px;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.1);
}

/* --------------------------------------
 * 2. NAGŁÓWEK I TYTUŁ
 * -------------------------------------- */
.header-bar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding-bottom: 20px;
    border-bottom: 1px solid #eee;
    margin-bottom: 20px;
}

.header-bar .admin-info {
    font-weight: bold;
    color: #2b3643;
}

h1.page-title {
    font-size: 1.8em;
    color: #2b3643;
    margin: 0 0 20px 0;
    padding-bottom: 10px;
    border-bottom: 2px solid #007bff;
    text-align: center;
}

/* Sekcja Kontroli Losowania - tło i marginesy */
.table-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    align-items: center;
    margin-bottom: 20px;
    padding: 15px;
    background-color: #f8f9fa;
    border: 1px solid #eee;
    border-radius: 4px;
}

/* --------------------------------------
 * 3. PRZYCISKI (BUTTONS)
 * -------------------------------------- */
.btn {
	background: #3498db;
    padding: 8px 12px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    white-space: nowrap;
	color: #eee;
	transition: all 0.1s;
}

.btn-action {
	margin: 0 -4px;
	padding: 6px 6px 5px 7px;
	font-size: 16px;
}

.btn:hover {
	transform: scale(1.1);
}

/* Kontener przycisków akcji w wierszu tabeli */
.action-buttons-group {
    display: flex;
    gap: 5px; /* Mniejszy odstęp między ikonami akcji */
    align-items: center;
}
.action-form { display: inline; }
.table-row .action-form button { margin-right: 3px; }

/* --------------------------------------
 * 4. KOMUNIKATY I STATUSY
 * -------------------------------------- */
.status-message {
    padding: 10px;
    margin-bottom: 15px;
    border-radius: 4px;
    font-weight: bold;
    border: 1px solid;
}
.success { background-color: #d4edda; color: #155724; border-color: #c3e6cb; }
.error { background-color: #f8d7da; color: #721c24; border-color: #f5c6cb; }

/* Znaczniki statusu (Badge) */
.status-badge {
    padding: 4px 8px;
    border-radius: 20px;
    font-size: 0.75em;
    font-weight: bold;
    display: inline-block;
}
.status-active { background-color: #d4edda; color: #155724; }
.status-excluded { background-color: #f8d7da; color: #721c24; }
.status-info { background-color: #ffeeba; color: #856404; }
.pin-display { font-weight: bold; color: #007bff; }

/* --------------------------------------
 * 5. SEKCJE I UKŁAD (GRID)
 * -------------------------------------- */
.grid {
    display: flex;
    flex-direction: column; /* Wszystko w kolumnie dla małej szerokości */
    gap: 20px;
    margin-top: 20px;
}

/* Ukrycie starego stylu tabeli - wymuszenie użycia Flexbox Card View */
table, thead, tbody, tr, th, td { display: none; }
.table-container { padding: 0; box-shadow: none; }

/* --------------------------------------
 * 6. WIDOK TABELI JAKO KARTY (FLEXBOX)
 * -------------------------------------- */

/* NAGŁÓWEK TABELI (Header) */
.table-header {
    display: flex;
    padding: 12px 15px;
    margin-bottom: 5px;
    background-color: #e9ecef;
    border-radius: 4px;
    font-weight: 600;
    color: #495057;
    font-size: 0.9em;
    text-transform: uppercase;
}
.table-header > div { flex: 1; text-align: left; }

/* KONTENER WIERSZA (Row as Card) */
.table-row {
    display: flex;
    align-items: center;
    padding: 15px;
    margin-bottom: 8px;
    background-color: #fff;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    border-left: 5px solid transparent;
    transition: all 0.2s ease;
    cursor: default;
}
.table-row:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.table-row > div {
    flex: 1;
    text-align: left;
    color: #343a40;
    font-size: 0.9em;
}

/* Kolumny: 1. ID */
.table-losowanie .table-header > div:nth-child(1),
.table-losowanie .table-row > div:nth-child(1) { flex: 0 0 60px; } /* 1. ID: Stała mała szerokość */

/* Kolumny: 2. Nazwa */
.table-losowanie .table-header > div:nth-child(2),
.table-losowanie .table-row > div:nth-child(2) { flex: 1; } /* 2. Nazwa: Wypełnia całą resztę */

/* Kolumny: 3. PIN */
.table-losowanie .table-header > div:nth-child(3),
.table-losowanie .table-row > div:nth-child(3) { 
    flex: 0 0 auto; 
    min-width: 100px;
	text-align: center; 
    padding-right: 25px;
}

/* Kolumny: 4. Status */
.table-losowanie .table-header > div:nth-child(4),
.table-losowanie .table-row > div:nth-child(4) { 
    flex: 0 0 auto;
    min-width: 100px; 
    text-align: center; 
	padding-right: 25px;
}

/* Kolumny: 5. Akcja */
.table-losowanie .table-header > div:nth-child(5),
.table-losowanie .table-row > div:nth-child(5) { 
    flex: 0 0 auto;
    min-width: 120px; 
    text-align: right; 
}

////
/* Kolumny: 1. ID dziecka */
.table-delegacja .table-header > div:nth-child(1),
.table-delegacja .table-row > div:nth-child(1) { flex: 0 0 60px; max-width: 60px; }

/* Kolumny: 2. Nazwa dziecka */
.table-delegacja .table-header > div:nth-child(2),
.table-delegacja .table-row > div:nth-child(2) { flex: 1; }

/* Kolumny: 3. Przypisana para */
.table-delegacja .table-header > div:nth-child(3),
.table-delegacja .table-row > div:nth-child(3) { flex: 1; }

/* Kolumny: 4. Zmien przypisanie */
.table-delegacja .table-header > div:nth-child(4),
.table-delegacja .table-row > div:nth-child(4) { flex: 1; text-align: center; }

/* Kolumny: 5. Akcja */
.table-delegacja .table-header > div:nth-child(5),
.table-delegacja .table-row > div:nth-child(5) { 
	flex: 0 0 auto;
    min-width: 100px; 
    text-align: right; 
}

////
/* Kolumny: 1. ID dziecka */
.table-wyniki .table-header > div:nth-child(1),
.table-wyniki .table-row > div:nth-child(1) { flex: 2; }

/* Kolumny: 2. Nazwa dziecka */
.table-wyniki .table-header > div:nth-child(2),
.table-wyniki .table-row > div:nth-child(2) { flex: 1; }

/* Kolumny: 2. Nazwa dziecka */
.table-wyniki .table-header > div:nth-child(3),
.table-wyniki .table-row > div:nth-child(3) { flex: 2; }


/* --------------------------------------
 * 7. MATERIAL INPUTS (Formularze)
 * -------------------------------------- */

.add-form-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
	flex-shrink: 0;
}

.flex-row {
    display: flex; 
    align-items: center; 
    gap: 10px; 
    width: 100%; 
}

/* Kontener inputa, który umożliwi animację etykiety */
.material-input-group {
    position: relative;
    margin-bottom: 0; 
	min-width: 150px;
    flex-grow: 1;
}

/* Stylowanie inputów i selektów */
.material-input-group input[type="text"],
.material-input-group input[type="password"],
.material-input-group select {
    /* Zmieniono: Dodanie padding-top/bottom, aby input i przycisk były równe */
    width: 100%;
    padding: 12px 10px 8px 10px; 
    font-size: 1em;
    border: 1px solid #ced4da;
    border-radius: 4px;
    background-color: #fff;
    outline: none;
    transition: all .2s ease-out;
    box-sizing: border-box;
    color: #333;
    appearance: none; /* Reset dla select */
}

/* Strzałka dla selekta (dane jako SVG) */
.material-input-group select {
    background-image: url('data:image/svg+xml;utf8,<svg fill="%232b3643" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M7 10l5 5 5-5z"/><path d="M0 0h24v24H0z" fill="none"/></svg>');
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 35px;
}

/* Etykieta */
.material-input-group label {
    position: absolute;
    left: 10px;
    /* Dostosowanie pozycji etykiety po zmianie paddingu inputa */
    top: 8px; 
    font-size: 1em;
    color: #6c757d;
    pointer-events: none;
    transition: all .2s ease-out;
    background-color: #fff;
    padding: 0 5px;
    margin-left: -5px;
}

/* Stan focus / wypełniony */
.material-input-group input[type="text"]:focus,
.material-input-group input[type="password"]:focus,
.material-input-group select:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 1px #007bff;
}

/* Animacja etykiety na focus lub wypełnienie */
.material-input-group input[type="text"]:focus + label,
.material-input-group input[type="text"]:not(:placeholder-shown) + label,
.material-input-group input[type="password"]:focus + label,
.material-input-group input[type="password"]:not(:placeholder-shown) + label,
.material-input-group select:focus + label,
.material-input-group select:not([value=""]) + label {
    top: -8px;
    font-size: 0.75em;
    color: #007bff;
}

/* Ukryj placeholder, aby działała animacja etykiety */
.material-input-group input::placeholder {
    color: transparent;
}

/* Poprawka stylów przycisku, aby był wyśrodkowany pionowo i miał margines */
.add-form-row .btn {
    /* Ustawienie górnego i dolnego marginesu na auto dla lepszego wyśrodkowania pionowego */
    margin-top: auto; 
    margin-bottom: auto;
    height: 40px; /* Dopasowanie wysokości do inputa, który ma około 40px wysokości po uwzględnieniu paddingu i borderu */
    line-height: 1; /* Upewnienie się, że tekst w przycisku jest dobrze wyśrodkowany */
    white-space: nowrap;
}