/* ================= ADMIN ================= */

html, body {
    max-width: 100%;
    /*overflow-x: hidden;*/
}

body.admin {
    background: var(--bg-soft);
}

/* ================= ADMIN LAYOUT ================= */

.admin .dashboard {
    max-width: 1100px;
    margin: 60px auto;
    padding: 0 24px;
}

.admin .card {
    background: #fff;
    border-radius: 18px;
    padding: 28px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.08);
}

.admin .top-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.admin table.table {
    width: 100%;
    border-collapse: collapse;
}

.admin table.table th,
.admin table.table td {
    padding: 14px 12px;
    border-bottom: 1px solid var(--border-soft);
    text-align: left;
}

.admin table.table th {
    font-weight: 600;
    color: var(--text-light);
}

.admin .actions a {
    margin-right: 12px;
    font-size: 14px;
    text-decoration: none;
}

.admin .actions a.delete {
    color: #b91c1c;
}

/* BADGES */

.admin .badge {
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}

.admin .badge.facts {
    background: #e0f2fe;
    color: #0369a1;
}

.admin .badge.custom {
    background: #ede9fe;
    color: #5b21b6;
}

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

.admin .badge-muted {
    background: #eef2f7;
    color: #475569;
}

.admin .container.form {
    max-width: 900px;
    background: #fff;
    border-radius: 18px;
    padding: 32px;
    margin: 40px auto;
    box-shadow: 0 20px 40px rgba(0,0,0,0.08);
}

.admin h1 {
    margin-top: 0;
}

.admin .field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.admin label {
    font-weight: 500;
}

.admin label .hint {
    color: var(--text-light);
    font-weight: 400;
    font-size: 13px;
}

.field-hint {
    font-size: 0.8rem;
    color: #6b7280;
    line-height: 1.4;
    margin-top: 4px;
}
.admin input[type="text"] {
    max-width: 420px;
}

.admin select {
    max-width: 320px;
}

.admin input[type="checkbox"] {
    width: auto;
    margin-right: 6px;
}

.admin .actions {
    display: flex;
    gap: 12px;
    margin-top: 28px;
}

.admin .btn-secondary {
    background: #e5e7eb;
    color: #111;
    padding: 14px 22px;
    border-radius: 12px;
    text-decoration: none;
    font-weight: 500;
}

@media (max-width: 768px) {
    .btn-primary,
    .btn-secondary {
        padding: 10px 16px;
        font-size: 0.95rem;
        border-radius: 10px;
        line-height: 1.2;
    }
}
/* ================= MODAL ================= */

.modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.show {
    display: flex;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
}

.modal-box {
    position: relative;
    background: #fff;
    border-radius: 18px;
    padding: 28px 32px;
    max-width: 420px;
    width: 100%;
    box-shadow: 0 30px 60px rgba(0,0,0,0.25);
    animation: modalIn 0.2s ease-out;
}

.modal-box h3 {
    margin-top: 0;
    font-size: 20px;
}

.modal-box p {
    color: var(--text-light);
    margin: 12px 0 24px;
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.btn-danger {
    background: #dc2626;
    color: #fff;
    border: none;
    border-radius: 12px;
    padding: 12px 20px;
    cursor: pointer;
}

.btn-danger:hover {
    background: #b91c1c;
}

a.delete {
    color: #dc2626;
}
a.delete:hover {
    text-decoration: underline;
}

/* ================= SCREEN EDITOR LAYOUT ================= */

.screen-code {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 999px;

    background: #dcfce7;     /* jasna zieleń */
    color: #166534;          /* ciemna zieleń */

    font-weight: 700;
    text-decoration: none;   /* 🔥 usuwa podkreślenie */
    letter-spacing: 0.5px;
}

.screen-code:hover {
    background: #bbf7d0;
    text-decoration: none;   /* 🔥 na hover też bez underline */
}


.code-label {
    font-size: 11px;
    color: #6b7280;
    margin-bottom: 2px;
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
    white-space: nowrap;
}

/* numer klienta */
.client-badge {
    background: #fef3c7;          /* jasny żółty */
    color: #92400e;
    border: 1px solid #facc15;
    border-radius: 999px;
    padding: 6px 14px;
    font-size: 14px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.client-badge strong {
    font-weight: 800;
    letter-spacing: 1px;
}


/* nav */
.nav {
    display: flex;
    gap: 16px;
}

.nav a {
    text-decoration: none;
    font-weight: 500;
}

/* hamburger */
.hamburger {
    display: none;
}
.hamburger {
    background: transparent;
    border: none;
    display: none;
    flex-direction: column;
    gap: 4px;
    padding: 6px;
    cursor: pointer;
}

.hamburger span {
    width: 22px;
    height: 2px;
    background: #111;
    display: block;
}

@media (max-width: 768px) {

    .nav {
        display: none;
    }

    .hamburger {
        display: flex;
    }

    .logo {
        display: flex;
        align-items: center;
        gap: 0px !important;
        white-space: nowrap;
        font-size: 18px;
    }

    .logo-clock {
        margin: 0;
        padding: 0;
        transform: scale(0.8);
    }
    .logo-w,
    .logo-text {
        line-height: 1;
    }

    .logo {
        display: inline-flex;   /* 🔥 zamiast flex */
        align-items: center;
        gap: 2px;               /* 🔥 kontrolowany odstęp */
        font-size: 18px;
    }

    .logo-clock {
        margin: 0 2px;          /* 🔥 zmniejszamy odstęp */
        transform: scale(0.85);
    }
    .nav {
        display: none;
    }

    .hamburger {
        display: flex;
        background: transparent;
        border: none;
        flex-direction: column;
        gap: 4px;
        padding: 6px;
    }

    .hamburger span {
        width: 22px;
        height: 2px;
        background: #111;
    }


    .header-inner {
        display: flex;
        align-items: center;
        justify-content: space-between;
    }


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

    .client-badge {
        font-size: 12px;
        padding: 6px 10px;
        border-radius: 20px;
        white-space: nowrap;
    }
}

.screen-row.has-alert .screen-code {
    background: #fff7ed;   /* ostrzeżenie */
    color: #9a3412;
}

.screen-editor {
    display: grid;
    grid-template-columns: 1fr;
    gap: 32px;
    max-width: 1200px;
    margin: 40px auto;
    padding: 32px;
}

@media (min-width: 1024px) {
    .screen-editor {
        grid-template-columns: 1fr 1fr; /* 50 / 50 */
        align-items: start;
    }
}

/* ================= FORM ================= */

.screen-editor form {
    width: 100%;
}

.screen-editor input[type="text"],
.screen-editor input[type="number"],
.screen-editor select {
    width: 100%;
    max-width: none;
}


/* ================= PREVIEW (UNIFIED) ================= */

/* ================= ADMIN PREVIEW ================= */

.screen-preview {
    border: 1px dashed #cbd5e1;
    background: #f8fafc;
    padding: 16px;
    border-radius: 12px;
}

.screen-preview-inner #fact {
    visibility: visible;
}

.orientation-field {
    align-items: center;
}

.orientation-field > label:first-child {
    align-self: flex-start; /* tytuł + hint po lewej */
}

.orientation-field .radio {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.orientation-field .radio input {
    pointer-events: auto; /* 🔑 iOS */
}

.screen-preview-inner {
    width: 100%;
    aspect-ratio: 16 / 9;   /* tylko wizualna rama */
    min-height: 320px;

    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;

    background: #ffffff;
    border-radius: 8px;

    /* admin-friendly */
    padding: 24px;
    box-sizing: border-box;
}

.screen-preview-inner .preview-text {
    font-weight: 600;
    line-height: 1.2;
    word-break: break-word;
}

/* 🔧 DODANE: preview portrait */
.screen-preview-inner.portrait {
    aspect-ratio: 9 / 16;
    min-height: 480px;
}
.screen-preview-inner {
    position: relative;   /* 🔥 to jest punkt odniesienia */
}

.screen-preview-inner #timer-wrap {
    --p: 0.60;
}
.color-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* ===== COLOR DOT PICKER ===== */

.color-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.color-dot {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid #cbd5e1;
    flex-shrink: 0;
}

.color-btn {
    padding: 6px 12px;
    border-radius: 6px;
    background: #2563eb;
    color: #fff;
    border: none;
    font-size: 0.85rem;
    cursor: pointer;
}

.color-btn:hover {
    background: #1d4ed8;
}



/* ===== BUTTON UX (GLOBAL) ===== */

/* wszystkie przyciski */
button,
.btn-primary,
.btn-secondary,
a.btn-primary,
a.btn-secondary {
    cursor: pointer;
}

/* hover – lekki feedback */
button:hover,
.btn-primary:hover,
.btn-secondary:hover {
    filter: brightness(0.97);
}

/* active – efekt kliknięcia */
button:active,
.btn-primary:active,
.btn-secondary:active {
    transform: translateY(1px);
}

/* usuń podkreślenia z <a> udających button */
a.btn-primary,
a.btn-secondary {
    text-decoration: none;
}


.hint {
    font-size: 0.8rem;
    color: #6b7280;
    margin-top: 4px;
}

.preview {
    margin-top: 6px;
    font-size: 0.85rem;
    color: #374151;
}



/* 🔑 MOBILE */
@media (max-width: 900px) {
    .screen-editor {
        grid-template-columns: 1fr;
    }
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}
/* ===== COLOR PICKER LAYOUT ===== */

.color-picker {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* desktop – preview + button w jednej linii */
.color-picker .color-preview,
.color-picker .color-btn {
    align-self: flex-start;
}

/* mobile – twardo pod labelem */
@media (max-width: 768px) {
    .color-picker {
        gap: 10px;
    }

    .color-picker .color-preview,
    .color-picker .color-btn {
        align-self: stretch;
    }
}

.form-row {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;   /* label w środku */
    gap: 16px;
}

.picker-wrap {
    display: flex;
    align-items: center;   /* 🔑 TO JEST KLUCZ */
}

.form-row > label {
    justify-self: start;
    font-weight: 500;
}
.status-text {
    font-weight: 600;
    font-size: 0.9rem;
}

.status-text.active {
    color: #15803d; /* spokojna zieleń */
}

.status-text.inactive {
    color: #9ca3af; /* szary */
}


.form-row > .color-picker {
    justify-self: end;
}

/* ================= ADMIN BUTTON SIZE NORMALIZATION ================= */

/* główne przyciski w panelu admin */
.admin .btn-primary,
.admin .btn-secondary,
.admin button,
.admin a.btn-primary,
.admin a.btn-secondary {
    padding: 8px 16px;        /* było ~14-22px */
    font-size: 0.9rem;        /* było ~1rem+ */
    border-radius: 10px;      /* było 12-18px */
    line-height: 1.2;
    height: auto;
}

/* mniejsze w headerach (tabs, sticky bars) */
.admin .editor-tabs .btn-primary,
.admin .editor-tabs .btn-secondary,
.admin .editor-tabs button {
    padding: 7px 14px;
    font-size: 0.85rem;
    border-radius: 9px;
}

/* przyciski formularza (dół strony) – trochę większe UX */
.admin .actions .btn-primary,
.admin .actions .btn-secondary,
.admin .actions button {
    padding: 10px 18px;
    font-size: 0.95rem;
    border-radius: 12px;
}

/* mobile – żeby nie były "tabletowe" */
@media (max-width: 768px) {
    .admin .btn-primary,
    .admin .btn-secondary,
    .admin button {
        padding: 8px 14px;
        font-size: 0.85rem;
        border-radius: 8px;
    }
}

/* ================= PREVIEW RATIO FIX (MOBILE 16:9) ================= */

/* bazowy kontener preview */
.admin .screen-preview-inner {
    width: 100%;
    aspect-ratio: 16 / 9;   /* 🔥 zawsze 16:9 */
    height: auto;           /* usuwa wymuszanie wysokości */
    min-height: 0;          /* 🔥 KLUCZ – usuwa rozciąganie na mobile */
    max-height: none;
    box-sizing: border-box;
}

/* portrait preview */
.admin .screen-preview-inner.portrait {
    aspect-ratio: 9 / 16;
    min-height: 0;
}

/* mobile – żeby nie robiło „tabletowego boxa” */
@media (max-width: 768px) {
    .admin .screen-preview-inner {
        aspect-ratio: 16 / 9;
        min-height: 0 !important;
        padding: 16px;
    }
}
