/* style.css - MobiQR.uk */

:root {
    --primary: #0284c7;
    --primary-dark: #0369a1;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border-color: #cbd5e1;
    --border-light: #e2e8f0;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
}

html {
    overflow-y: scroll;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    margin: 0;
    padding: 20px 0;
    line-height: 1.5;
}

.page-wrapper {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 20px;
    box-sizing: border-box;
}

/* Nagłówek główny */
.main-header {
    background: var(--card-bg);
    border: 1px solid var(--border-light);
    border-radius: 10px;
    padding: 14px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    margin-bottom: 8px;
    box-sizing: border-box;
    width: 100%;
}

.header-row-top {
    display: flex;
    align-items: center;
    gap: 15px;
}

.header-logo-link {
    font-size: 17px;
    font-weight: 800;
    color: var(--primary);
    text-decoration: none;
    white-space: nowrap;
}

.header-right-area {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
}

.header-user-badge {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}

/* Pudełko rangi dopasowane wysokością do przycisków w nagłówku */
.header-role-box {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    background: #e0f2fe;
    border: 1px solid #bae6fd;
    border-radius: 6px;
    font-size: 8px;
    font-weight: 800;
    color: #0369a1;
    line-height: 1.1;
    text-transform: uppercase;
    box-sizing: border-box;
    white-space: nowrap;
}

.header-email-text {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 600;
}

/* Karty / kontenery */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border-light);
    border-radius: 10px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    margin-bottom: 20px;
    box-sizing: border-box;
    width: 100%;
}

.auth-grid {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 20px;
    align-items: stretch;
}

.form-group {
    margin-bottom: 15px;
}

.form-label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
select,
textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: #ffffff;
    color: var(--text-main);
    font-size: 14px;
    box-sizing: border-box;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

.btn-primary {
    background: var(--primary);
    color: #ffffff;
    border: none;
    padding: 10px 18px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    transition: background 0.2s;
    text-align: center;
    box-sizing: border-box;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    font-size: 13px;
}

th, td {
    padding: 12px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
}

th {
    font-weight: 700;
    color: var(--text-muted);
    background: #f8fafc;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.5px;
}

.config-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    flex-wrap: wrap;
    background: #f8fafc;
    border: 1px solid var(--border-light);
    border-radius: 8px;
    padding: 12px 14px;
    box-sizing: border-box;
}

.logo-form {
    display: flex;
    gap: 10px;
    align-items: center;
    flex: 1;
    min-width: 260px;
    justify-content: flex-end;
}

.logo-form input[type="file"] {
    font-size: 11px;
    padding: 5px;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    flex: 1;
    box-sizing: border-box;
}

.qr-layout {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 20px;
    align-items: start;
}

.qr-preview-box {
    text-align: center;
    background: #f8fafc;
    border: 1px solid var(--border-light);
    border-radius: 8px;
    padding: 12px;
}

.qr-preview-img {
    width: 100%;
    max-width: 200px;
    height: auto;
    display: block;
    margin: 0 auto 8px auto;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.nav-menu {
    display: flex;
    gap: 6px;
    align-items: center;
}

/* Style bazowe stopki (Desktop) */
.site-footer {
    max-width: 1100px;
    width: 100%;
    margin: 30px auto 20px auto;
    padding: 20px 15px;
    border-top: 1px solid var(--border-light);
    font-size: 12px;
    color: var(--text-muted);
    box-sizing: border-box;
}

.footer-grid {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.footer-main-info {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
}

.footer-domain {
    font-weight: 600;
    color: var(--text-main);
}

.footer-version-badge {
    background: #e0f2fe;
    color: #0369a1;
    padding: 2px 6px;
    border-radius: 6px;
    font-weight: 700;
    text-decoration: none;
}

.footer-legal-links {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.footer-legal-links a {
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
}

.footer-author-link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

/* ==========================================================================
   Komponenty pomocnicze (Admin / Formularze dwukolumnowe)
   ========================================================================== */

.split-card {
    margin-bottom: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.page-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    gap: 10px;
    flex-wrap: wrap;
}

.page-title {
    margin: 0;
    font-size: 20px;
    font-weight: 800;
    color: var(--text-main);
}

.btn-link-back {
    text-decoration: none;
    font-size: 13px;
    padding: 6px 12px;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    cursor: pointer;
    color: var(--text-main);
}

.checkbox-row input[type="checkbox"] {
    width: 16px;
    height: 16px;
}

.btn-block {
    display: block;
    width: 100%;
}

.meta-note {
    text-align: center;
    margin-top: 20px;
    font-size: 12px;
    color: var(--text-muted);
}

.help-card {
    margin-bottom: 0;
    height: 100%;
    background: #f8fafc;
}

.help-card-title {
    margin-top: 0;
    font-size: 15px;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 12px;
    border-bottom: 1px solid var(--border-light);
    padding-bottom: 8px;
}

.help-list {
    margin: 0;
    padding-left: 18px;
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.6;
}

.help-list li {
    margin-bottom: 8px;
}

.help-list li:last-child {
    margin-bottom: 0;
}

/* ==========================================================================
   Odznaki statusu (Badges) i akcje wierszowe w tabelach
   ========================================================================== */

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
}

.badge-indigo {
    background: #e0e7ff;
    color: #3730a3;
}

.badge-neutral {
    background: #f1f5f9;
    color: #475569;
}

.badge-success {
    background: #d1fae5;
    color: #065f46;
}

.badge-danger {
    background: #fee2e2;
    color: #991b1b;
}

.badge-warning {
    background: #fef3c7;
    color: #d97706;
}

.badge-sky {
    background: #e0f2fe;
    color: #0369a1;
}

.table-scroll {
    overflow-x: auto;
}

.col-actions {
    text-align: right;
    white-space: nowrap;
}

.row-actions {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.icon-action-btn {
    text-decoration: none;
    padding: 5px 8px;
    border-radius: 4px;
    display: inline-block;
    font-size: 13px;
    line-height: 1;
}

.icon-action-edit {
    background: #e0f2fe;
    color: #0369a1;
}

.icon-action-warn {
    background: #fef3c7;
    color: #d97706;
}

.icon-action-success {
    background: #d1fae5;
    color: #065f46;
}

.icon-action-danger {
    background: #fee2e2;
    color: #991b1b;
}

.empty-state-text {
    color: var(--text-muted);
    font-size: 13px;
}

.card-title-icon {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ==========================================================================
   Formularz ustawień systemowych (sekcje, siatki pól, konsola diagnostyczna)
   ========================================================================== */

.settings-section-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--primary);
    border-bottom: 1px solid var(--border-light);
    padding-bottom: 8px;
    margin-top: 25px;
    margin-bottom: 15px;
}

.settings-section-title:first-child {
    margin-top: 0;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 20px;
}

.form-grid-wide-narrow {
    display: grid;
    grid-template-columns: 3fr 1fr;
    gap: 15px;
    margin-bottom: 15px;
}

.form-grid .form-group,
.form-grid-wide-narrow .form-group {
    margin-bottom: 0;
}

.diagnostic-box {
    background: #f8fafc;
    border: 1px solid var(--border-light);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.diagnostic-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 6px;
}

.diagnostic-text {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 12px;
    line-height: 1.5;
}

.btn-outline {
    background: #ffffff;
    border: 1px solid var(--border-color);
    font-weight: 600;
    cursor: pointer;
}

.btn-lg {
    padding: 12px 25px;
    font-size: 15px;
}

.console-box {
    margin-top: 12px;
    font-size: 12px;
    display: none;
    background: #0f172a;
    color: #e2e8f0;
    padding: 12px;
    border-radius: 6px;
    font-family: monospace;
    line-height: 1.6;
}

.console-box.is-visible {
    display: block;
}

.console-status-pending { color: #f59e0b; }
.console-status-ok { color: #34d399; }
.console-status-error { color: #f87171; }

/* ==========================================================================
   Pasek filtrów (formularze GET: logi, listy z wyszukiwarką)
   ========================================================================== */

.filter-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    align-items: center;
}

.filter-input {
    flex: 1;
    min-width: 200px;
}

.filter-limit-group {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-muted);
}

.filter-select {
    width: auto;
}

.btn-reset {
    padding: 9px 12px;
    font-size: 13px;
    background: #e2e8f0;
    color: #334155;
    text-decoration: none;
    border-radius: 6px;
    font-weight: 600;
    display: inline-block;
}

.table-empty-cell {
    text-align: center;
    color: var(--text-muted);
    padding: 20px;
}

/* ==========================================================================
   Nagłówki sekcji z etykietą nadrzędną, liczniki, changelog
   ========================================================================== */

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

.header-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.card-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}

.count-badge {
    font-size: 11px;
    background: #f1f5f9;
    color: var(--text-muted);
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: 600;
    border: 1px solid var(--border-color);
}

.section-subtitle {
    margin-top: 0;
    font-size: 14px;
    font-weight: 700;
    color: var(--text-main);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
    margin-bottom: 20px;
}

.textarea-mono {
    font-family: monospace;
    font-size: 12px;
}

.form-actions {
    display: flex;
    gap: 10px;
}

.empty-state-block {
    text-align: center;
    color: var(--text-muted);
    padding: 30px 0;
    margin: 0;
    font-size: 14px;
}

.text-version {
    font-weight: 700;
    color: var(--primary);
}

.cell-strong {
    font-weight: 600;
    color: var(--text-main);
}

.cell-muted-sm {
    color: var(--text-muted);
    font-size: 12px;
}

.action-link {
    padding: 5px 10px;
    border-radius: 6px;
    text-decoration: none;
    font-size: 12px;
    font-weight: 600;
    display: inline-block;
    border: 1px solid transparent;
}

.action-link-edit {
    background: #e0f2fe;
    color: #0369a1;
    border-color: #bae6fd;
    margin-right: 4px;
}

.action-link-danger {
    background: #fee2e2;
    color: #991b1b;
    border-color: #fecaca;
}

.changelog-list {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.changelog-entry:not(:last-child) {
    padding-bottom: 25px;
    border-bottom: 1px solid var(--border-color);
}

.changelog-entry-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    flex-wrap: wrap;
    gap: 8px;
}

.changelog-entry-title-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.version-pill {
    background: #e0f2fe;
    color: #0369a1;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    border: 1px solid #bae6fd;
}

.changelog-entry-title {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: var(--text-main);
}

.changelog-entry-date {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 600;
}

.changelog-entry-body {
    color: var(--text-main);
    font-size: 14px;
    line-height: 1.6;
}

/* ==========================================================================
   Responsywność dla urządzeń mobilnych
   ========================================================================== */
@media (max-width: 768px) {
    body {
        padding: 10px 0;
    }
    .page-wrapper {
        padding: 0 10px;
    }
    .card {
        padding: 16px;
    }
    .qr-layout {
        grid-template-columns: 1fr !important;
    }

    /* Siatka formularzy (profil itp.) – jedna pod drugą na telefonach */
    .auth-grid {
        display: flex !important;
        flex-direction: column !important;
        gap: 20px !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    .auth-grid > div {
        width: 100% !important;
        box-sizing: border-box !important;
    }

    /* Siatki pól w ustawieniach systemowych - jedna kolumna na telefonie */
    .form-grid,
    .form-grid-wide-narrow {
        grid-template-columns: 1fr !important;
    }

    /* Nagłówek podzielony na 2 rzędy na urządzeniach mobilnych */
    .main-header {
        flex-direction: column !important;
        align-items: stretch !important;
        padding: 12px !important;
        gap: 10px !important;
    }

    /* Górny rząd: Logo i Menu z ikonami */
    .header-row-top {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        width: 100% !important;
        border-bottom: 1px solid var(--border-light);
        padding-bottom: 8px;
    }

    .header-logo-link {
        font-size: 15px !important;
    }

    .nav-menu {
        display: flex !important;
        gap: 4px !important;
        flex-wrap: nowrap !important;
    }

    .header-btn {
        padding: 6px 8px !important;
        font-size: 15px !important;
        justify-content: center !important;
    }

    .header-btn .nav-text {
        display: none !important;
    }

    /* Dolny rząd: Informacje o użytkowniku, ranga, profil i wylogowanie */
    .header-row-bottom {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        width: 100% !important;
        margin-left: 0 !important;
        box-sizing: border-box;
    }

    .header-right-area {
        margin-left: 0 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: flex-end !important;
        gap: 8px !important;
    }

    .header-user-badge {
        flex-direction: row !important;
        align-items: center !important;
        gap: 8px !important;
        margin-right: auto !important;
    }

    .header-role-box {
        width: 36px;
        height: 36px;
        font-size: 7.5px;
    }

    .header-email-text {
        display: inline !important;
        font-size: 11px !important;
    }

    /* Sekcja logo */
    .config-row {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 12px !important;
    }
    .logo-form {
        flex-direction: column !important;
        align-items: stretch !important;
        width: 100% !important;
        justify-content: stretch !important;
        gap: 8px !important;
        min-width: 0 !important;
    }
    .logo-form input[type="file"] {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box;
    }
    .logo-form button[type="submit"] {
        width: 100% !important;
        box-sizing: border-box;
    }

    /* Przyciski pod generatorem QR - klasa .qr-action-row zamiast [style*="display: flex"] */
    .card .qr-layout .qr-action-row {
        flex-direction: column !important;
    }
    .card .qr-layout .qr-action-row > * {
        width: 100% !important;
        box-sizing: border-box;
    }

    /* Stopka mobilna: jedna linia, wyśrodkowana, bez linków prawnych */
    .site-footer {
        padding: 12px 10px !important;
        margin: 20px auto 15px auto !important;
    }

    .footer-grid {
        display: flex !important;
        flex-direction: row !important;
        justify-content: center !important;
        align-items: center !important;
        flex-wrap: nowrap !important;
        font-size: 10px !important;
        gap: 6px !important;
        white-space: nowrap !important;
        text-align: center !important;
    }

    .footer-legal-links {
        display: none !important;
    }

    .footer-main-info {
        display: inline-flex !important;
        align-items: center !important;
        gap: 4px !important;
    }

    .footer-author {
        display: inline-flex !important;
        align-items: center !important;
    }
}

/* Powiadomienia Toast */
#toast-container {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
    pointer-events: none;
}

.toast-msg {
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
    animation: slideDown 0.3s ease, fadeOut 0.3s ease 2.7s forwards;
    display: flex;
    align-items: center;
    gap: 8px;
    pointer-events: auto;
    white-space: nowrap;
}

.toast-success {
    background: #ecfdf5;
    border: 1px solid #10b981;
    color: #065f46;
}

.toast-error {
    background: #fef2f2;
    border: 1px solid #ef4444;
    color: #991b1b;
}

@keyframes slideDown {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes fadeOut {
    to {
        opacity: 0;
        transform: translateY(-10px);
    }
}