/* ============================================
   ABBrygady — AppsBusters palette & components
   ============================================ */

:root {
    --global-palette1: #009244;
    --global-palette2: #c1d11c;
    --global-palette3: #111317;
    --global-palette4: #022c32;
    --global-palette5: #1e4c53;
    --global-palette6: #4a6a6e;
    --text-light: #ffffff;
    --bg-light: #f5f5f5;
    --border-color: #e0e0e0;
    --card-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    --hover-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

html, body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg-light);
    color: var(--global-palette3);
}

a, .btn-link { color: var(--global-palette1); }

.btn:focus, .btn:active:focus, .form-control:focus, .form-check-input:focus {
    box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem rgba(0,146,68,0.5);
}

h1:focus { outline: none; }

.valid.modified:not([type=checkbox]) { outline: 1px solid var(--global-palette1); }
.invalid { outline: 1px solid #e50000; }
.validation-message { color: #dc3545; font-size: 0.85rem; }

.blazor-error-boundary {
    background: #b32121;
    padding: 1rem;
    color: white;
}
.blazor-error-boundary::after { content: "Wystąpił błąd."; }

/* ---------- Layout helpers ---------- */
.modern-container {
    width: 100%;
    padding: 0.75rem;
    animation: fadeIn 0.4s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

.hero-section {
    background: linear-gradient(135deg, var(--global-palette4) 0%, var(--global-palette5) 100%);
    border-radius: 8px;
    padding: 1.25rem 1.5rem;
    margin-bottom: 1rem;
    box-shadow: var(--card-shadow);
    position: relative;
    overflow: hidden;
    color: white;
}
.hero-section::before {
    content: '';
    position: absolute;
    top: -50%; right: -10%;
    width: 400px; height: 400px;
    background: var(--global-palette1);
    opacity: 0.08;
    border-radius: 50%;
}
.hero-section h1 { color: white; margin: 0; }
.hero-section p { color: rgba(255,255,255,0.85); margin: 0.5rem 0 0; }

/* ---------- Cards ---------- */
.modern-card {
    background: white;
    border-radius: 4px;
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
    box-shadow: var(--card-shadow);
    border-left: 4px solid var(--global-palette1);
    transition: all 0.3s ease;
}
.modern-card:hover { box-shadow: var(--hover-shadow); }

.card-header-modern {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--global-palette3);
    margin-bottom: 1rem;
    padding-bottom: 0.6rem;
    border-bottom: 2px solid var(--global-palette2);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ---------- Forms ---------- */
.modern-input, select.modern-input, textarea.modern-input {
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.7rem 0.9rem;
    font-size: 0.95rem;
    transition: all 0.3s ease;
    background: white;
    color: var(--global-palette3);
    width: 100%;
    font-family: inherit;
}
.modern-input:focus {
    border-color: var(--global-palette1);
    box-shadow: 0 0 0 3px rgba(0, 146, 68, 0.1);
    outline: none;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1rem;
}
.form-field {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}
.form-label-modern {
    font-weight: 600;
    color: var(--global-palette3);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.label-badge {
    background: var(--global-palette1);
    color: white;
    padding: 0.15rem 0.5rem;
    border-radius: 3px;
    font-size: 0.7rem;
    font-weight: 600;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 56px;
    height: 28px;
    flex-shrink: 0;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: #ccc;
    border-radius: 28px;
    transition: 0.3s;
}
.toggle-slider:before {
    position: absolute;
    content: "";
    height: 22px; width: 22px;
    left: 3px; bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: 0.3s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
input:checked + .toggle-slider { background: var(--global-palette1); }
input:checked + .toggle-slider:before { transform: translateX(28px); }

.readonly-value {
    padding: 0.6rem 0.85rem;
    background: #f8f9fa;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: #495057;
    min-height: 2.4rem;
    display: flex;
    align-items: center;
    word-break: break-word;
}

/* ---------- Buttons ---------- */
.modern-btn {
    padding: 0.7rem 1.25rem;
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.9rem;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    text-decoration: none;
}
.modern-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.modern-btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

.btn-gradient-success { background: var(--global-palette1); color: white; }
.btn-gradient-success:hover { background: #007a38; color: white; }

.btn-gradient-primary { background: var(--global-palette5); color: white; }
.btn-gradient-primary:hover { background: var(--global-palette4); color: white; }

.btn-gradient-info { background: var(--global-palette6); color: white; }
.btn-gradient-info:hover { background: var(--global-palette5); color: white; }

.btn-gradient-warning { background: #dc3545; color: white; }
.btn-gradient-warning:hover { background: #c82333; color: white; }

.btn-gradient-secondary { background: #6c757d; color: white; }
.btn-gradient-secondary:hover { background: #5a6268; color: white; }

/* ---------- Banners ---------- */
.warning-banner, .success-banner, .info-banner, .error-banner {
    border-radius: 4px;
    padding: 0.85rem 1.25rem;
    margin: 0.75rem 0;
    font-weight: 500;
}
.warning-banner { background: #fff3cd; border-left: 4px solid #ffc107; color: #856404; }
.success-banner { background: #d4edda; border-left: 4px solid var(--global-palette1); color: #155724; }
.info-banner    { background: #f1f5f9; border-left: 4px solid #cbd5e1; color: #475569; }
.error-banner   { background: #f8d7da; border-left: 4px solid #dc3545; color: #721c24; }

/* ---------- Toast ---------- */
.toast-notification {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    padding: 0;
    border-radius: 4px;
    color: white;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 1000;
    animation: slideInRight 0.4s ease-out;
    max-width: 500px;
    min-width: 280px;
}
@keyframes slideInRight {
    from { transform: translateX(400px); opacity: 0; }
    to   { transform: translateX(0); opacity: 1; }
}
.toast-success { background: var(--global-palette1); }
.toast-error   { background: #dc3545; }
.toast-content {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 1rem 1.5rem;
    gap: 1rem;
}
.toast-content span {
    flex: 1;
    word-break: break-word;
    line-height: 1.5;
}
.toast-close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 1.6rem;
    cursor: pointer;
    line-height: 1;
    opacity: 0.85;
}
.toast-close-btn:hover { opacity: 1; }

/* ---------- Spinner ---------- */
.spinner-overlay {
    position: fixed; inset: 0;
    background: rgba(17, 19, 23, 0.85);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    animation: fadeIn 0.3s ease;
}
.spinner-content {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    text-align: center;
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
}
.spinner {
    width: 50px; height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--global-palette1);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 1rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Tables ---------- */
.modern-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 4px;
    overflow: hidden;
    box-shadow: var(--card-shadow);
}
.modern-table th {
    background: var(--global-palette4);
    color: white;
    text-align: left;
    padding: 0.75rem 1rem;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.modern-table td {
    padding: 0.65rem 1rem;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.95rem;
}
.modern-table tr:last-child td { border-bottom: none; }
.modern-table tr:hover td { background: rgba(0,146,68,0.05); }

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

/* ---------- Worker checklist (rejestruj czas) ---------- */
.worker-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.5rem;
}
.worker-row {
    display: flex;
    align-items: center;
    background: #f8f9fa;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.6rem 0.75rem;
    gap: 0.6rem;
    transition: all 0.2s ease;
}
.worker-row.checked {
    background: rgba(0, 146, 68, 0.08);
    border-color: var(--global-palette1);
}
.worker-row label {
    flex: 1;
    cursor: pointer;
    font-weight: 500;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin: 0;
}
.worker-row input[type=checkbox] {
    width: 22px; height: 22px;
    accent-color: var(--global-palette1);
    cursor: pointer;
    flex-shrink: 0;
}
.worker-row .ot-input {
    width: 80px;
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    text-align: right;
    font-size: 0.95rem;
}
.worker-row .ot-input:disabled { background: #f1f1f1; opacity: 0.6; }
.worker-row .ot-suffix { font-size: 0.8rem; color: var(--global-palette6); white-space: nowrap; }

/* ---------- Button row ---------- */
.btn-row {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-top: 1rem;
}
.btn-row .modern-btn { min-width: 160px; }

/* ---------- Mobile tweaks ---------- */
@media (max-width: 640.98px) {
    .modern-container { padding: 0.5rem; }
    .modern-card { padding: 0.85rem; }
    .modern-btn { padding: 0.7rem 1rem; font-size: 0.85rem; }
    .toast-notification { right: 0.5rem; bottom: 0.5rem; left: 0.5rem; max-width: none; }
    .btn-row .modern-btn { flex: 1 1 100%; min-width: 0; }
    .form-grid { grid-template-columns: 1fr; }
}

/* ---------- Responsive toggles ----------
   Bez bazowego `display`, bo wewnętrzne klasy (np. `.data-card-list { display: flex }`)
   ustawiają własny tryb i nie chcemy ich nadpisywać. Toggle wyłącznie w media query
   z !important — kontrola na poziomie bandwidth. */
@media (max-width: 768px) {
    .desktop-only { display: none !important; }
}
@media (min-width: 769px) {
    .mobile-only  { display: none !important; }
}

/* ---------- Data cards (mobile alternative to tables) ---------- */
.data-card-list { display: flex; flex-direction: column; gap: 0.75rem; }
.data-card {
    background: white;
    border-radius: 6px;
    padding: 0.85rem 1rem;
    box-shadow: var(--card-shadow);
    border-left: 4px solid var(--global-palette1);
}
.data-card-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--global-palette3);
    margin-bottom: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.data-card-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 0.4rem 0;
    font-size: 0.9rem;
    border-bottom: 1px solid #f4f4f4;
    gap: 0.5rem;
}
.data-card-row:last-of-type { border-bottom: none; }
.data-card-row .label {
    color: var(--global-palette6);
    font-weight: 500;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    flex: 0 0 auto;
}
.data-card-row .value {
    font-weight: 600;
    color: var(--global-palette3);
    text-align: right;
    word-break: break-word;
    flex: 1 1 auto;
}
.data-card-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
    flex-wrap: wrap;
}
.data-card-actions .modern-btn {
    flex: 1 1 calc(50% - 0.25rem);
    min-width: 0;
    padding: 0.55rem 0.7rem;
    font-size: 0.78rem;
}

.status-badge {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: 12px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.status-badge.on  { background: rgba(0,146,68,0.15); color: var(--global-palette1); }
.status-badge.off { background: rgba(220,53,69,0.12); color: #b91c1c; }

/* ---------- Modal ---------- */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(17, 19, 23, 0.85);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.25s ease;
    padding: 1rem;
    /* Overlay bez pointer-events (nie ma close-on-outside-click) — żeby buttony w dialogu
       były klikalne bez problemu „overlay intercepts pointer events". */
    pointer-events: none;
}
/* NOTE (ABRemote): AB-owe modale zawężone do wrappera .modal-overlay. Reużywane konfiguratory
   (Nexo) renderują natywne modale Bootstrap (.modal > .modal-dialog) — bez tego zawężenia AB-owe
   .modal-dialog/.modal-header/... nadpisywały Bootstrap (kolizja nazw klas) i psuły layout
   ("lista wewnątrz modala"). LogBrowser działa dalej, bo jego modal też siedzi w .modal-overlay. */
.modal-overlay .modal-dialog {
    background: white;
    border-radius: 10px;
    max-width: 640px;
    width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 16px 48px rgba(0,0,0,0.4);
    animation: modalSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    overflow: hidden;
    /* Włącz interaktywność z powrotem dla samego dialogu i wszystkich jego dzieci. */
    pointer-events: auto;
}
@keyframes modalSlideUp {
    from { transform: translateY(40px); opacity: 0; }
    to   { transform: translateY(0); opacity: 1; }
}
.modal-overlay .modal-header {
    background: linear-gradient(135deg, var(--global-palette4) 0%, var(--global-palette5) 100%);
    color: white;
    padding: 1rem 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 2px solid var(--global-palette1);
}
.modal-overlay .modal-header h2 {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 600;
    color: white;
    flex: 1;
    word-break: break-word;
}
.modal-close {
    background: rgba(255,255,255,0.1);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 1.4rem;
    cursor: pointer;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}
.modal-close:hover { background: rgba(255,255,255,0.25); }
.modal-overlay .modal-body {
    padding: 1.25rem;
    overflow-y: auto;
    flex: 1;
}
.modal-overlay .modal-footer {
    padding: 0.85rem 1.25rem;
    background: #f8f9fa;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}
.modal-overlay .modal-footer .modern-btn { min-width: 110px; }

@media (max-width: 640px) {
    .modal-overlay { padding: 0; align-items: flex-end; }
    .modal-overlay .modal-dialog {
        max-height: 95vh;
        border-radius: 12px 12px 0 0;
        max-width: 100%;
    }
    .modal-overlay .modal-footer { padding: 0.75rem 1rem; }
    .modal-overlay .modal-footer .modern-btn { flex: 1 1 calc(50% - 0.25rem); min-width: 0; }
}
