/* ==========================================================================
   App-style authentication pages (login / register / password)
   Mobile-first, fixed dimensions to avoid CLS, safe-area aware.
   ========================================================================== */

/* dm-tasarim-v1: auth token'ları site geneli --dm-* token'larına bağlandı */
:root {
    --auth-primary: var(--dm-primary, var(--theme-color-1, #E11D48));
    --auth-primary-soft: var(--dm-primary-soft, var(--theme-color-0_15, rgba(225, 29, 72, .15)));
    --auth-primary-softer: var(--theme-color-0_08, rgba(225, 29, 72, .08));
    --auth-text: var(--dm-text, #111827);
    --auth-muted: var(--dm-text-muted, #6b7280);
    --auth-border: var(--dm-border, #e5e7eb);
    --auth-bg: var(--dm-bg, #f7f8fb);
    --auth-card: var(--dm-surface, #ffffff);
    --auth-danger: var(--dm-danger, #dc2626);
    --auth-radius: var(--dm-radius, 14px);
}

html, body.auth-app {
    margin: 0;
    padding: 0;
    background: var(--auth-bg);
    color: var(--auth-text);
    -webkit-font-smoothing: antialiased;
    -webkit-text-size-adjust: 100%;
}

body.auth-app {
    font-family: var(--dm-font-body, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif);
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
}

body.auth-app * { -webkit-tap-highlight-color: transparent; }

.auth-app-bg {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background:
        linear-gradient(180deg, var(--auth-primary-softer) 0%, rgba(255,255,255,0) 42%),
        repeating-linear-gradient(135deg, rgba(17,24,39,.018) 0 1px, transparent 1px 28px),
        var(--auth-bg);
    opacity: 1;
}

.auth-app-shell {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding:
        calc(env(safe-area-inset-top, 0px) + 30px)
        max(16px, env(safe-area-inset-right, 0px))
        calc(env(safe-area-inset-bottom, 0px) + 24px)
        max(16px, env(safe-area-inset-left, 0px));
    box-sizing: border-box;
}

.auth-app-container {
    width: 100%;
    max-width: 440px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
}

.auth-app-header {
    text-align: center;
    margin-bottom: 12px;
    min-height: 54px;
}

.auth-app-logo-link {
    display: inline-block;
    line-height: 0;
}

.auth-app-logo-link img {
    height: 46px;
    width: auto;
    max-width: 240px; /* dm-logo: 5:1 yatay logo için genişletildi */
    object-fit: contain;
}

.auth-app-grid {
    display: grid;
    gap: 18px;
    width: 100%;
}

.auth-brand-panel {
    display: none;
}

.auth-app-card {
    background: var(--auth-card);
    border-radius: var(--auth-radius);
    box-shadow: 0 10px 30px rgba(16, 24, 40, .08), 0 2px 6px rgba(16, 24, 40, .04);
    padding: 22px;
    box-sizing: border-box;
    border: 1px solid rgba(229, 231, 235, .7);
}

/* Tabs ---------------------------------------------------------------- */
.auth-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    background: var(--auth-bg);
    border-radius: 10px;
    padding: 4px;
    margin-bottom: 16px;
    border: 1px solid rgba(229, 231, 235, .65);
}

.auth-tab {
    display: block;
    text-align: center;
    padding: 8px 12px;
    border-radius: 8px;
    text-decoration: none;
    color: var(--auth-muted);
    font-weight: 600;
    font-size: 13.5px;
    transition: background-color .2s, color .2s, box-shadow .2s;
    line-height: 1.2;
}

.auth-tab:hover,
.auth-tab:focus { color: var(--auth-text); text-decoration: none; }
.auth-tab:focus-visible,
.auth-field-pw-toggle:focus-visible,
.auth-btn:focus-visible,
.auth-social-btn:focus-visible {
    outline: 2px solid var(--auth-primary);
    outline-offset: 2px;
}

.auth-tab.is-active {
    background: var(--auth-card);
    color: var(--auth-text);
    box-shadow: 0 1px 3px rgba(0, 0, 0, .06), inset 0 0 0 1px rgba(17,24,39,.04);
    pointer-events: none;
}

/* Welcome header ------------------------------------------------------ */
.auth-welcome {
    text-align: center;
    margin-bottom: 12px;
    min-height: 52px;
}

.auth-welcome h1 {
    font-size: 19px;
    font-weight: 700;
    margin: 0 0 2px;
    line-height: 1.3;
    color: var(--auth-text);
}

.auth-welcome p {
    font-size: 12.5px;
    color: var(--auth-muted);
    margin: 0;
    line-height: 1.4;
}

/* Forms --------------------------------------------------------------- */
.auth-form { display: flex; flex-direction: column; gap: 10px; }

.auth-field { position: relative; }

.auth-field-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #8b95a5;
    font-size: 14px;
    line-height: 1;
    z-index: 2;
    pointer-events: none;
}

.auth-field-input {
    width: 100%;
    height: 48px;
    /* dm-input-v2: 17/5 asimetrisi filled-label kalıntısıydı; etiket notched-outline
       (üst kenara çıkıyor) olduğundan metin dikeyde tam ortalanır */
    padding: 0 14px;
    background: var(--auth-card);
    border: 1px solid var(--auth-border);
    border-radius: 10px;
    font-size: 16px; /* prevents iOS zoom on focus */
    color: var(--auth-text);
    box-sizing: border-box;
    -webkit-appearance: none;
    appearance: none;
    transition: border-color .15s, box-shadow .15s;
    line-height: 1.2;
}

.auth-field.has-icon .auth-field-input {
    padding-left: 44px;
}

.auth-field-input::placeholder { color: transparent; }
.auth-field-input:focus {
    outline: none;
    border-color: var(--auth-primary);
    box-shadow: 0 0 0 3px var(--auth-primary-soft);
}

.auth-field-label {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 14px;
    color: var(--auth-muted);
    pointer-events: none;
    transition: top .15s, font-size .15s, color .15s, transform .15s;
    background: transparent;
    padding: 0 4px;
    max-width: calc(100% - 24px);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.auth-field.has-icon .auth-field-label {
    left: 40px;
    max-width: calc(100% - 54px);
}

.auth-field-input:focus ~ .auth-field-label,
.auth-field-input:not(:placeholder-shown) ~ .auth-field-label {
    top: 0;
    transform: translateY(-50%);
    font-size: 11px;
    color: var(--auth-primary);
    background: var(--auth-card); /* yüzerken input kenarlığını maskele */
}

.auth-field.has-pw .auth-field-input { padding-right: 48px; }
.auth-field.has-icon.has-pw .auth-field-label {
    max-width: calc(100% - 94px);
}
.auth-field-pw-toggle {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    background: transparent;
    border: 0;
    color: var(--auth-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    border-radius: 8px;
}

.auth-field-pw-toggle:hover { color: var(--auth-text); }

.auth-field.has-error .auth-field-input { border-color: var(--auth-danger); }
.auth-field.has-error .auth-field-label { color: var(--auth-danger); }
.auth-field.has-success .auth-field-input { border-color: #16a34a; }

.auth-error,
.status-not-available {
    display: block;
    color: var(--auth-danger);
    font-size: 12px;
    margin-top: 4px;
    line-height: 1.4;
}

/* Row (remember + forgot) -------------------------------------------- */
.auth-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    gap: 12px;
    flex-wrap: wrap;
}

.auth-check {
    display: inline-flex;
    gap: 8px;
    align-items: center;
    color: var(--auth-muted);
    cursor: pointer;
    user-select: none;
    line-height: 1.4;
}

.auth-check input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin: 0;
    accent-color: var(--auth-primary);
    flex-shrink: 0;
}

/* legacy style.css'in `label span {font-size:10px; color:#444}` kuralını ez */
.auth-check span {
    font-size: 12.5px;
    font-weight: 400;
    color: var(--auth-muted);
}

.auth-check a {
    color: var(--auth-primary);
    text-decoration: none;
    font-weight: 500;
}

.auth-link {
    color: var(--auth-primary);
    text-decoration: none;
    font-weight: 500;
    font-size: 13px;
}

.auth-link:hover { text-decoration: underline; }

/* Primary button ----------------------------------------------------- */
.auth-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    height: 48px;
    border: 0;
    border-radius: 10px;
    background: var(--auth-primary);
    color: #fff;
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    transition: filter .15s, transform .05s;
    margin-top: 4px;
    font-family: inherit;
}

.auth-btn:active { filter: brightness(.92); transform: scale(.995); }
.auth-btn:hover { filter: brightness(1.04); }
.auth-btn[disabled] { opacity: .7; cursor: wait; }

/* Social buttons + divider ------------------------------------------- */
.auth-divider {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 12px 0;
    color: var(--auth-muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .06em;
}

.auth-divider::before,
.auth-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--auth-border);
}

.auth-socials {
    display: flex;
    gap: 10px;
    width: 100%;
}

.auth-social-btn {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 44px;
    border: 1px solid var(--auth-border);
    border-radius: 10px;
    background: var(--auth-card);
    font-weight: 500;
    font-size: 13.5px;
    cursor: pointer;
    text-decoration: none;
    color: var(--auth-text);
    transition: background .15s, border-color .15s;
    font-family: inherit;
    padding: 0 10px;
}

.auth-social-btn:hover { background: #f9fafb; color: var(--auth-text); text-decoration: none; }
.auth-social-btn img { width: 18px; height: 18px; flex-shrink: 0; }
.auth-social-btn span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Captcha reserved space (prevents CLS) ------------------------------ */
.auth-captcha {
    min-height: 0;
    display: flex;
    justify-content: center;
    margin: 2px 0;
}

.auth-captcha:not(:empty) { min-height: 78px; margin: 4px 0 2px; }

.auth-captcha:empty { display: none; }
.auth-captcha > div { max-width: 100%; }

/* Footer ------------------------------------------------------------- */
.auth-footer {
    text-align: center;
    margin-top: 18px;
    font-size: 13px;
    color: var(--auth-muted);
}

.auth-footer a {
    color: var(--auth-muted);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.auth-footer a:hover { color: var(--auth-text); }

/* Demo credentials box ---------------------------------------------- */
.auth-demo {
    margin-top: 16px;
    padding: 12px;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 10px;
    font-size: 12px;
    color: #92400e;
}

.auth-demo-title { font-weight: 600; margin-bottom: 6px; }
.auth-demo table { width: 100%; border-collapse: collapse; }
.auth-demo th, .auth-demo td { padding: 4px 6px; text-align: left; font-weight: 400; }
.auth-demo th { font-weight: 600; }

/* Responsive tweaks -------------------------------------------------- */
@media (max-width: 360px) {
    .auth-app-card { padding: 16px; }
    .auth-socials { flex-direction: column; }
    .auth-app-logo-link img { height: 44px; }
}

@media (min-width: 640px) {
    .auth-app-shell { padding-top: calc(env(safe-area-inset-top, 0px) + 44px); }
    .auth-app-card { padding: 24px; }
}

@media (min-width: 900px) {
    .auth-app-shell {
        justify-content: center;
        padding-top: calc(env(safe-area-inset-top, 0px) + 24px);
        padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 24px);
    }

    .auth-app-container {
        max-width: 930px;
    }

    .auth-app-header {
        display: none;
    }

    .auth-app-grid {
        grid-template-columns: minmax(0, 1fr) 440px;
        align-items: stretch;
        gap: 22px;
    }

    .auth-brand-panel {
        display: flex;
        flex-direction: column;
        justify-content: center;
        min-height: 520px;
        padding: 34px;
        border-radius: 18px;
        border: 1px solid rgba(229, 231, 235, .72);
        background: rgba(255,255,255,.76);
        box-shadow: 0 14px 36px rgba(16, 24, 40, .07), 0 2px 8px rgba(16, 24, 40, .04);
        overflow: hidden;
    }

    .auth-brand-logo {
        margin-bottom: 26px;
    }

    .auth-brand-logo img {
        height: 52px;
        width: auto;
        max-width: 280px; /* dm-logo: 5:1 yatay logo için genişletildi */
        object-fit: contain;
    }

    .auth-brand-panel h2 {
        margin: 0 0 10px;
        max-width: 360px;
        color: var(--auth-text);
        font-size: 30px;
        line-height: 1.14;
        font-weight: 800;
        letter-spacing: 0;
    }

    .auth-brand-panel p {
        margin: 0 0 24px;
        max-width: 380px;
        color: var(--auth-muted);
        font-size: 15px;
        line-height: 1.55;
    }

    .auth-brand-features {
        display: grid;
        gap: 11px;
        margin: 0;
        padding: 0;
        list-style: none;
    }

    .auth-brand-features li {
        display: flex;
        align-items: center;
        gap: 10px;
        color: #374151;
        font-size: 14px;
        font-weight: 650;
    }

    .auth-brand-features i {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 34px;
        height: 34px;
        min-width: 34px;
        border-radius: 10px;
        background: var(--auth-primary-soft);
        color: var(--auth-primary);
        font-size: 14px;
    }

    .auth-app-card {
        align-self: center;
        min-height: 0;
    }
}

/* RTL ---------------------------------------------------------------- */
body.auth-app.rtl .auth-field-label { left: auto; right: 12px; }
body.auth-app.rtl .auth-field-icon { left: auto; right: 14px; }
body.auth-app.rtl .auth-field.has-icon .auth-field-input { padding-left: 14px; padding-right: 44px; }
body.auth-app.rtl .auth-field.has-icon .auth-field-label { left: auto; right: 40px; }
body.auth-app.rtl .auth-field.has-pw .auth-field-input { padding-right: 14px; padding-left: 48px; }
body.auth-app.rtl .auth-field.has-icon.has-pw .auth-field-input { padding-right: 44px; padding-left: 48px; }
body.auth-app.rtl .auth-field-pw-toggle { right: auto; left: 4px; }

/* Disable outer wrapper artefacts from base style.css ----------------- */
body.auth-app #wrapper,
body.auth-app #header-container,
body.auth-app #titlebar,
body.auth-app #footer,
body.auth-app #dashboard-footer,
body.auth-app .mobile-nav-trigger { display: none !important; }

/* In-app browser notice ---------------------------------------------- */
.auth-browser-notice[hidden] {
    display: none !important;
}

.auth-browser-notice {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 16px;
    box-sizing: border-box;
}

.auth-browser-notice-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, .42);
    backdrop-filter: blur(4px);
}

.auth-browser-notice-panel {
    position: relative;
    width: min(100%, 390px);
    padding: 18px;
    border-radius: 18px;
    background: #fff;
    color: var(--auth-text);
    box-shadow: 0 18px 48px rgba(15, 23, 42, .24);
    border: 1px solid rgba(229, 231, 235, .85);
    box-sizing: border-box;
}

.auth-browser-notice-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 10px;
    background: #f8fafc;
    color: #64748b;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.auth-browser-notice-icon {
    width: 42px;
    height: 42px;
    border-radius: 13px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
    background: var(--auth-primary-soft);
    color: var(--auth-primary);
    font-size: 17px;
}

.auth-browser-notice-panel h2 {
    margin: 0 34px 6px 0;
    color: var(--auth-text);
    font-size: 19px;
    line-height: 1.25;
    font-weight: 800;
    letter-spacing: 0;
}

.auth-browser-notice-panel p {
    margin: 0 0 14px;
    color: var(--auth-muted);
    font-size: 13.5px;
    line-height: 1.45;
}

.auth-browser-notice-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 10px;
}

.auth-browser-notice-primary,
.auth-browser-notice-secondary {
    min-width: 0;
    height: 42px;
    border-radius: 11px;
    border: 0;
    padding: 0 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: inherit;
    font-size: 13px;
    font-weight: 750;
    line-height: 1;
    cursor: pointer;
}

.auth-browser-notice-primary {
    background: var(--auth-primary);
    color: #fff;
}

.auth-browser-notice-secondary {
    background: #f8fafc;
    color: #334155;
    border: 1px solid #e2e8f0;
}

.auth-browser-notice-panel small {
    display: block;
    color: #64748b;
    font-size: 11.5px;
    line-height: 1.4;
}

@media (min-width: 700px) {
    .auth-browser-notice {
        align-items: center;
    }
}

@media (max-width: 360px) {
    .auth-browser-notice-actions {
        grid-template-columns: 1fr;
    }
}

/* ==========================================================================
   dm-tasarim-v1: koyu tema desteği — hardcoded açık renklerin overrides'ı.
   Dosyanın SONUNDA kalmalı (cascade önceliği).
   ========================================================================== */
html[data-theme="dark"] .auth-app-bg {
    background:
        linear-gradient(180deg, var(--dm-primary-soft) 0%, rgba(0,0,0,0) 42%),
        repeating-linear-gradient(135deg, rgba(255,255,255,.02) 0 1px, transparent 1px 28px),
        var(--dm-bg);
}
html[data-theme="dark"] .auth-app-card {
    border-color: var(--dm-border);
    box-shadow: 0 10px 30px rgba(0, 0, 0, .45), 0 2px 6px rgba(0, 0, 0, .3);
}
html[data-theme="dark"] .auth-tabs {
    background: var(--dm-bg-2);
    border-color: var(--dm-border);
}
html[data-theme="dark"] .auth-tab.is-active {
    box-shadow: 0 1px 3px rgba(0, 0, 0, .4), inset 0 0 0 1px var(--dm-border);
    background: var(--dm-surface-2);
    color: var(--dm-text);
}
html[data-theme="dark"] .auth-field-input,
html[data-theme="dark"] .auth-field .auth-field-input {
    background: var(--dm-surface-2);
    border-color: var(--dm-border);
    color: var(--dm-text);
}
html[data-theme="dark"] .auth-field-input::placeholder { color: var(--dm-text-faint); }
html[data-theme="dark"] .auth-social-btn {
    background: var(--dm-surface-2);
    border-color: var(--dm-border);
    color: var(--dm-text);
}
html[data-theme="dark"] .auth-social-btn:hover { background: var(--dm-surface); color: var(--dm-text); }
html[data-theme="dark"] .auth-brand-panel {
    border-color: var(--dm-border) !important;
    background: rgba(21, 21, 26, .8) !important;
    box-shadow: 0 14px 36px rgba(0, 0, 0, .4) !important;
}
html[data-theme="dark"] .auth-brand-panel h2,
html[data-theme="dark"] .auth-brand-features span { color: var(--dm-text); }
html[data-theme="dark"] .auth-browser-notice-panel {
    background: var(--dm-surface);
    border-color: var(--dm-border);
    color: var(--dm-text);
}
html[data-theme="dark"] .auth-browser-notice-secondary {
    background: var(--dm-surface-2);
    color: var(--dm-text);
    border-color: var(--dm-border);
}
/* dm-audit-2026: onay kutusunun dokunma alanı 18px'ti — kutu büyütüldü,
   etiketin tamamı zaten tıklanabilir (label sarmalı) */
.auth-check input[type="checkbox"] {
    width: 20px;
    height: 20px;
}
.auth-check { padding: 6px 0; align-items: flex-start; }
.auth-check span { padding-top: 1px; }
