/* =====================================================================
   Bank Card Image Generator - asosiy uslublar
   ---------------------------------------------------------------------
   Tuzilishi:
     1. Umumiy (body, header)
     2. Panel kartochkalari (chap tomondagi forma bloklari)
     3. Karta turi tanlash
     4. Dizayn tanlash
     5. Karta preview (asosiy blok - html2canvas shuni rasmga oladi)
     6. Karta dizaynlari (gradientlar)
     7. Natija va responsive
   ===================================================================== */

/* ---------------------------------------------------------------
   1. UMUMIY
   --------------------------------------------------------------- */
:root {
    --app-bg: #f2f4f8;
    --app-border: #e6eaf1;
    --app-ink: #1a2233;
}

/* Sayt qobig'iga o'tkazilgani uchun body emas — ilova bo'limi */
#bankApp {
    background-color: var(--app-bg);
    color: var(--app-ink);
    font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

.app-header {
    background: linear-gradient(120deg, #101a33 0%, #1d3163 55%, #2a4a94 100%);
    color: #fff;
    margin-bottom: 1.75rem;
}

.app-header__icon {
    width: 52px;
    height: 52px;
    flex: 0 0 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    border-radius: 14px;
    background: rgba(255, 255, 255, .14);
}

.app-header__title {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
    letter-spacing: .2px;
}

.app-header__subtitle {
    color: rgba(255, 255, 255, .78);
    font-size: .95rem;
}

/* ---------------------------------------------------------------
   FOOTER - sarlavha (app-header) bilan bir xil gradient
   --------------------------------------------------------------- */
.app-footer {
    background: linear-gradient(120deg, #101a33 0%, #1d3163 55%, #2a4a94 100%);
    color: rgba(255, 255, 255, .78);
    margin-top: 2.5rem;
}

/* Markazdagi sayt havolasi */
.app-footer__link {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    padding: .5rem 1.15rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, .10);
    border: 1px solid rgba(255, 255, 255, .18);
    color: #fff;
    font-weight: 600;
    text-decoration: none;
    transition: background-color .15s ease, transform .15s ease;
}

.app-footer__link:hover,
.app-footer__link:focus {
    background: rgba(255, 255, 255, .2);
    color: #fff;
    transform: translateY(-1px);
}

.app-footer__icon {
    width: 20px;
    height: 20px;
    object-fit: contain;
}

.app-footer__note {
    margin-top: .85rem;
    font-size: .82rem;
    color: rgba(255, 255, 255, .6);
}

/* Maxfiylik bildirishnomasi */
.alert-privacy {
    background: #eef4ff;
    border: 1px solid #d7e3ff;
    color: #1f3a6e;
    border-radius: .85rem;
    font-size: .9rem;
}

/* ---------------------------------------------------------------
   2. PANEL KARTOCHKALARI
   --------------------------------------------------------------- */
.app-card {
    border: 1px solid var(--app-border);
    border-radius: .9rem;
    box-shadow: 0 2px 10px rgba(20, 30, 60, .04);
}

.app-card__header {
    background: #fff;
    border-bottom: 1px solid var(--app-border);
    font-weight: 600;
    border-radius: .9rem .9rem 0 0 !important;
}

.app-card .form-label {
    font-weight: 500;
    font-size: .9rem;
}

.app-card .form-control {
    padding: .6rem .8rem;
}

.app-card .form-control:focus {
    border-color: #7aa0ff;
    box-shadow: 0 0 0 .2rem rgba(58, 106, 255, .15);
}

.form-check-label {
    font-size: .93rem;
}

/* Sticky preview - katta ekranlarda scroll paytida karta ko'rinib turadi */
@media (min-width: 992px) {
    .preview-sticky {
        position: sticky;
        top: 1rem;
    }
}

/* ---------------------------------------------------------------
   3. KARTA TURI TANLASH
   --------------------------------------------------------------- */
.type-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: .75rem;
}

.type-option {
    margin: 0;
    cursor: pointer;
}

/* Radio inputni yashiramiz, tanlovni box orqali ko'rsatamiz */
.type-option__input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.type-option__box {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .45rem;
    padding: .85rem .5rem;
    height: 100%;
    border: 2px solid var(--app-border);
    border-radius: .75rem;
    background: #fff;
    transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}

.type-option__box:hover {
    border-color: #b9c9ee;
}

/* Logolarning shakli har xil (UzCard - kvadrat, Humo - keng), shuning
   uchun har biriga alohida balandlik beriladi */
.type-option__logo {
    height: 28px;
    width: auto;
    max-width: 100%;
    object-fit: contain;
}

.type-option__logo--uzcard {
    height: 46px;
}

.type-option__logo--humo {
    height: 40px;
}

.type-option__label {
    font-size: .82rem;
    font-weight: 600;
    color: #5b6780;
}

.type-option__input:checked + .type-option__box {
    border-color: #2a4a94;
    box-shadow: 0 0 0 .2rem rgba(42, 74, 148, .12);
}

.type-option__input:checked + .type-option__box .type-option__label {
    color: #2a4a94;
}

.type-option__input:focus-visible + .type-option__box {
    outline: 2px solid #2a4a94;
    outline-offset: 2px;
}

/* ---------------------------------------------------------------
   4. DIZAYN TANLASH
   --------------------------------------------------------------- */
.design-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: .75rem;
}

.design-option {
    margin: 0;
    cursor: pointer;
}

.design-option__input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.design-option__box {
    display: block;
    padding: .4rem;
    border: 2px solid var(--app-border);
    border-radius: .7rem;
    background: #fff;
    transition: border-color .15s ease, box-shadow .15s ease;
}

.design-option__box:hover {
    border-color: #b9c9ee;
}

/* Kichik karta ko'rinishidagi preview */
.design-option__thumb {
    display: block;
    width: 100%;
    aspect-ratio: 1.586 / 1;
    border-radius: .4rem;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .06);
}

.design-option__label {
    display: block;
    margin-top: .35rem;
    text-align: center;
    font-size: .72rem;
    font-weight: 600;
    color: #5b6780;
    line-height: 1.2;
}

.design-option__input:checked + .design-option__box {
    border-color: #2a4a94;
    box-shadow: 0 0 0 .2rem rgba(42, 74, 148, .12);
}

.design-option__input:checked + .design-option__box .design-option__label {
    color: #2a4a94;
}

.design-option__input:focus-visible + .design-option__box {
    outline: 2px solid #2a4a94;
    outline-offset: 2px;
}

/* ---------------------------------------------------------------
   5. KARTA PREVIEW
   ---------------------------------------------------------------
   Ichki o'lchamlar `em` da berilgan. Karta elementining font-size'i
   app.js tomonidan kenglikka mutanosib qilib o'rnatiladi, shuning
   uchun karta har qanday ekranda mutanosib kichrayadi/kattalashadi.
   --------------------------------------------------------------- */
.card-preview-wrap {
    max-width: 520px;
    margin: 0 auto;
}

.card-preview {
    position: relative;
    width: 100%;
    aspect-ratio: 1.586 / 1;   /* haqiqiy plastik karta nisbati */
    border-radius: 1.05em;
    padding: 1.15em 1.35em;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;
    color: #fff;
    font-size: 20px;           /* JS tomonidan qayta hisoblanadi */
    box-shadow: 0 18px 38px rgba(16, 26, 51, .28);
}

/* Dekorativ yorug'lik dog'lari */
.cp-blob {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
}

.cp-blob--1 {
    width: 15em;
    height: 15em;
    top: -7.5em;
    right: -5.5em;
    background: rgba(255, 255, 255, .10);
}

.cp-blob--2 {
    width: 11em;
    height: 11em;
    bottom: -5.5em;
    left: -3.5em;
    background: rgba(255, 255, 255, .07);
}

/* Qatorlar dekoratsiya ustida turishi uchun */
.cp-row,
.cp-number {
    position: relative;
    z-index: 2;
}

.cp-row--top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1em;
}

.cp-chip {
    width: 3em;
    height: auto;
    border-radius: .35em;
    flex: 0 0 auto;
}

.cp-logo {
    height: 1.5em;
    width: auto;
    max-width: 7.5em;
    object-fit: contain;
    flex: 0 0 auto;
}

/* Har bir brend logosining nisbati har xil - o'lchamlar alohida beriladi */
.cp-logo--uzcard {
    height: 3em;        /* kvadrat lokup: "U" belgisi + UZCARD yozuvi */
}

.cp-logo--humo {
    height: 2em;     /* keng oltin yozuv */
    /*height: 1.15em;     /* keng oltin yozuv */*/
}

/* Och fonli kartalarda Humo to'liq belgi (to'q fonli badge) ko'rinishida */
.card-preview.is-light .cp-logo--humo {
    height: 2.3em;
}

.cp-number {
    font-family: Consolas, "Courier New", ui-monospace, monospace;
    font-size: 1.36em;
    font-weight: 600;
    letter-spacing: .055em;
    white-space: nowrap;
    text-shadow: 0 1px 2px rgba(0, 0, 0, .18);
    margin: .1em 0;
}

.cp-row--bottom {
    display: flex;
    align-items: flex-end;
    gap: 1.1em;
}

.cp-field {
    display: flex;
    flex-direction: column;
    gap: .15em;
    min-width: 0;              /* uzun matn boshqa maydonlarni siqmasligi uchun */
    flex: 0 0 auto;
}

/* Ism-familiya maydoni qolgan bo'sh joyni egallaydi va uzun bo'lsa qisqartiriladi */
.cp-field--holder {
    flex: 1 1 auto;
}

.cp-label {
    font-size: .5em;
    letter-spacing: .13em;
    text-transform: uppercase;
    opacity: .7;
    line-height: 1.1;
}

.cp-value {
    font-size: .82em;
    font-weight: 600;
    letter-spacing: .05em;
    line-height: 1.15;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Yashirilgan maydonlar umuman ko'rinmaydi (rasmda ham chiqmaydi) */
.cp-hidden {
    display: none !important;
}

/* ---------------------------------------------------------------
   6. KARTA DIZAYNLARI
   --------------------------------------------------------------- */
.design-classic-dark {
    background: linear-gradient(135deg, #3a3f47 0%, #191c21 55%, #2b2f36 100%);
}

.design-blue-gradient {
    background: linear-gradient(135deg, #1b3b7a 0%, #2a5298 50%, #4776e6 100%);
}

.design-purple-gradient {
    background: linear-gradient(135deg, #4b2072 0%, #7b2ff7 55%, #b06ab3 100%);
}

.design-green {
    background: linear-gradient(135deg, #0b6e4f 0%, #12996b 50%, #0d3b2c 100%);
}

.design-gold {
    background: linear-gradient(135deg, #a9791a 0%, #f3d98c 45%, #c9a227 100%);
}

.design-minimal-white {
    background: linear-gradient(135deg, #ffffff 0%, #f2f4f8 60%, #e3e7ee 100%);
}

/* Och rangli dizaynlarda matn to'q rangda bo'ladi */
.card-preview.is-light {
    color: #1a2233;
    box-shadow: 0 18px 38px rgba(16, 26, 51, .18);
}

.card-preview.is-light .cp-number {
    text-shadow: none;
}

.card-preview.is-light .cp-blob--1 {
    background: rgba(0, 0, 0, .05);
}

.card-preview.is-light .cp-blob--2 {
    background: rgba(0, 0, 0, .035);
}

.card-preview.design-minimal-white {
    box-shadow: 0 18px 38px rgba(16, 26, 51, .14), inset 0 0 0 1px rgba(0, 0, 0, .06);
}

/* ---------------------------------------------------------------
   7. NATIJA VA RESPONSIVE
   --------------------------------------------------------------- */
.result-image {
    display: block;
    width: 100%;
    max-width: 520px;
    margin: 0 auto;
    border-radius: .6rem;
    background: repeating-conic-gradient(#f3f5f9 0% 25%, #e7ebf2 0% 50%) 50% / 18px 18px;
}

/* Tugma bosilganda yuklanish holati */
.btn .spinner-border {
    width: 1rem;
    height: 1rem;
    border-width: .15em;
}

/* ---------------------------------------------------------------
   8. HIMOYA (protect.js) UCHUN USLUBLAR
   --------------------------------------------------------------- */

/* Bloklangan amal bosilganda ekran pastida chiqadigan xabar */
.protect-toast {
    position: fixed;
    left: 50%;
    bottom: 1.5rem;
    transform: translate(-50%, 1rem);
    z-index: 2000;
    max-width: 90vw;
    padding: .6rem 1.1rem;
    border-radius: 999px;
    background: rgba(16, 26, 51, .92);
    color: #fff;
    font-size: .88rem;
    box-shadow: 0 8px 24px rgba(16, 26, 51, .3);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease, transform .2s ease;
}

.protect-toast.is-visible {
    opacity: 1;
    transform: translate(-50%, 0);
}

/* Chop etishda (Ctrl+P yoki brauzer menyusi) sahifa mazmuni chiqmasin */
@media print {
    body * {
        visibility: hidden !important;
    }

    body::after {
        content: "Bu sahifani chop etish mumkin emas.";
        visibility: visible;
        display: block;
        text-align: center;
        margin-top: 3rem;
        font-size: 14pt;
    }
}

@media (max-width: 575.98px) {
    .app-header__title {
        font-size: 1.2rem;
    }

    .app-header__subtitle {
        font-size: .85rem;
    }

    .design-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ============================================================
   KARTALAR ICHIDAGI BO'SHLIQLAR — ixcham va bir tekis
   (sayt umumiy dizayniga moslangan)
   ============================================================ */

/* Sarlavha va tana bir xil yon chekinishga ega bo'lsin */
.app-card .card-header {
    padding: .7rem 1.1rem;
    font-size: .95rem;
}

.app-card .card-header i {
    margin-right: .35rem;
    opacity: .75;
}

.app-card .card-body {
    padding: 1rem 1.1rem .95rem;
}

/* Oxirgi element ostidagi ortiqcha bo'shliq olib tashlanadi */
.app-card .card-body > *:last-child,
.app-card .card-body .row:last-child .col-7 > *:last-child,
.app-card .card-body .row:last-child .col-5 > *:last-child {
    margin-bottom: 0 !important;
}

/* Maydonlar orasidagi masofa biroz ixchamroq */
.app-card .card-body .mb-3 {
    margin-bottom: .85rem !important;
}

.app-card .form-label {
    margin-bottom: .3rem;
    font-size: .875rem;
    color: #475569;
}

/* Xatolik matni maydonga yopishmasin, lekin joy ham egallamasin */
.app-card .invalid-feedback {
    margin-top: .25rem;
    font-size: .8rem;
}

/* Kalit (switch) ro'yxati — qatorlar zich va bir tekis */
.app-card .form-check.form-switch {
    margin-bottom: .45rem !important;
    padding-left: 2.6rem;
    min-height: auto;
}

.app-card .form-check.form-switch:last-child {
    margin-bottom: 0 !important;
}

.app-card .form-check-input {
    margin-left: -2.6rem;
    margin-top: .15rem;
}

/* Karta turi katakchalari */
.app-card .type-grid {
    gap: .6rem;
}

/* Kichik ekranlarda yanada ixcham */
@media (max-width: 575.98px) {
    .app-card .card-header { padding: .6rem .9rem; }
    .app-card .card-body   { padding: .85rem .9rem .8rem; }
    .app-card .card-body .mb-3 { margin-bottom: .75rem !important; }
}
