/* --- assets/css/login.css --- */

/* --- Fonts --- */
@import url('https://fonts.googleapis.com/css?family=Roboto:300,400,500,600&display=swap');

/* --- Design Tokens --- */
:root {
    /* Base */
    --bg-0: #0a0a0a;
    --bg-1: #121212;
    --bg-main: #151515;

    /* Text */
    --text-strong: rgba(255,255,255,0.95);
    --text:        rgba(255,255,255,0.85);
    --text-muted:  rgba(255,255,255,0.70);
    --text-faint:  rgba(255,255,255,0.55);
    --text-dim:    rgba(255,255,255,0.38);

    /* Stroke / Surfaces */
    --stroke:      rgba(255,255,255,0.14);
    --stroke-2:    rgba(255,255,255,0.20);
    --surface:     rgba(255,255,255,0.03);
    --surface-2:   rgba(255,255,255,0.06);

    /* Focus */
    --focus-ring:  rgba(255,255,255,0.06);
    --focus-stroke:rgba(255,255,255,0.8);

    /* Brand Gradient */
    --title-grad-a: rgba(255,255,255,0.96);
    --title-grad-b: rgba(255,255,255,0.18);

    /* Status */
    --danger:      #ff5252;
    --danger-bg:   rgba(255, 82, 82, 0.10);
    --danger-st:   rgba(255, 82, 82, 0.22);

    /* Typography */
    --font-family: 'Roboto', system-ui, -apple-system, sans-serif;
    --fs-title:    1.5rem;
    --fs-subtitle: 0.95rem;
    --fs-input:    0.92rem;
    --fs-button:   0.90rem;
    --fs-footer:   0.75rem;
    --lh-title:    1.30;
    --lh-body:     1.55;

    /* Radius & Spacing */
    --r-lg: 18px;
    --r-md: 16px;
    --r-sm: 10px;
    --control-h: 48px;

    /* Motion */
    --ease: cubic-bezier(.2,.8,.2,1);
}

/* --- Global Reset & Body --- */
* { box-sizing: border-box; margin: 0; padding: 0; outline: none; }

html {
    color-scheme: dark;
    background-color: var(--bg-main);
    -webkit-text-size-adjust: 100%;
    width: 100%;
    height: 100%;
}

html, body {
    background: var(--bg-main);
    overscroll-behavior: none;
}

body {
    font-family: var(--font-family);
    font-weight: 400;
    color: var(--text);
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0px;
}

/* --- Layout --- */
.container {
    width: 100%;
    padding: 0px;
    opacity: 0;
    animation: fadeIn 0.6s var(--ease) forwards;
    display: flex;
    flex-direction: column;
    position: relative;
}

.container .inner {
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    padding: 40px;
    opacity: 0;
    animation: fadeIn 0.6s var(--ease) forwards;
    display: flex;
    flex-direction: column;
}

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

.header {
    display: flex;
    flex-direction: column;
    row-gap: 1.2rem;
    text-align: center;
    margin-bottom: 2.5rem;
    position: relative;
    z-index: 1;
}

/* --- Logo & Typography --- */
.logo {
    margin: 0 auto;
    width: 80px; height: 80px;
    border-radius: 50%;
    display: flex; justify-content: center; align-items: center;
    opacity: 0.65;
    background: linear-gradient(180deg, rgba(40,40,40,0.8), rgba(40,40,40,0.8));
    border: 0px solid rgba(255,255,255,0.09);
    position: relative;
    z-index: 1;
}
.logo img {
    width: 60px; max-width: 60px; height: auto; border: 0;
    filter: invert(1) brightness(1.9);
}

.title {
    font-size: var(--fs-title);
    font-weight: 400;
    line-height: var(--lh-title);
    letter-spacing: -0.01em;
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-image: linear-gradient(to right, var(--title-grad-a), var(--title-grad-b));
}

.subtitle {
    font-size: var(--fs-subtitle);
    line-height: var(--lh-body);
    font-weight: 300;
    color: var(--text-muted);
}

/* --- Language Switch --- */
.lang-switch {
    display: flex; justify-content: center; gap: 1rem; margin-bottom: 2rem;
}
.lang-switch a {
    font-size: 0.82rem; font-weight: 500; color: var(--text-faint);
    cursor: pointer; text-decoration: none; padding-bottom: 2px;
    border-bottom: 2px solid transparent;
    transition: all 0.2s var(--ease);
}
.lang-switch a:hover { color: var(--text-strong); }
.lang-switch a.active {
    color: var(--text-strong);
    border-bottom-color: rgba(255,255,255,0.88);
}

/* --- Forms & Inputs --- */
.form-group { margin-bottom: 1.25rem; }

input {
    width: 100%; padding: 0 16px; height: var(--control-h);
    font-size: var(--fs-input); font-weight: 300;
    background: rgba(0,0,0,0);
    border: 1px solid var(--stroke);
    color: var(--text);
    border-radius: var(--r-md);
    transition: all 0.2s var(--ease);
    -webkit-appearance: none; margin: 0;
}
input::placeholder { color: var(--text-dim); opacity: 1; }
input:focus {
    border-color: var(--focus-stroke);
    box-shadow: 0 0 0 4px var(--focus-ring);
    background: var(--surface);
}

/* 2FA Special Input */
input.code-input {
    height: 64px;
    font-size: 2rem;
    letter-spacing: 0.4em;
    text-align: center;
    font-family: monospace;
    margin-bottom: 1.25rem;
}

/* iOS Autofill Fix */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
    -webkit-text-fill-color: var(--text-strong);
    -webkit-box-shadow: 0 0 0px 1000px rgba(255,255,255,0.06) inset;
    transition: background-color 5000s ease-in-out 0s;
    border: 1px solid var(--stroke-2);
}

/* --- Buttons --- */
button {
    width: 100%; height: var(--control-h);
    background: rgba(255,255,255,0.95); color: rgba(0,0,0,0.92);
    border: none; border-radius: var(--r-md);
    font-weight: 600; cursor: pointer; margin-top: 1rem;
    display: flex; justify-content: center; align-items: center;
    transition: all 0.2s var(--ease);
    font-size: var(--fs-button); letter-spacing: 0.01em;
}
button:hover { background: rgba(255,255,255,0.90); }
button:active { transform: translateY(1px); }
button.loading { background: rgba(255,255,255,0.60); cursor: not-allowed; }

/* Secondary Button (Reset) */
.btn-reset {
    background: transparent;
    border: 1px solid var(--stroke);
    color: var(--text-muted);
    font-weight: 500;
    margin-top: 0.75rem;
}
.btn-reset:hover {
    background: var(--surface);
    color: var(--danger);
    border-color: var(--danger-st);
}

/* --- Components: Spinner & Error --- */
.spinner {
    display: none; width: 20px; height: 20px;
    border: 2px solid rgba(0,0,0,0.12); border-radius: 50%;
    border-top-color: rgba(0,0,0,0.75);
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.error-msg {
    background: var(--danger-bg); color: var(--danger);
    font-size: 0.9rem; padding: 12px;
    border-radius: var(--r-sm); margin-bottom: 1.5rem;
    text-align: center; display: none;
    border: 1px solid var(--danger-st);
}

/* --- 2FA Specific: Setup Section --- */
#setup-section {
    display: none;
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: var(--surface);
    border: 1px dashed var(--stroke-2);
    border-radius: var(--r-md);
    text-align: center;
}
#qr-image {
    width: 180px; height: 180px;
    margin: 1.5rem auto; display: block;
    padding: 10px; background: white;
    border-radius: var(--r-sm);
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}
.manual-key-box {
    font-family: monospace; font-weight: 700;
    color: var(--text-muted);
    background: rgba(0,0,0,0.3);
    padding: 10px 14px; border-radius: var(--r-sm);
    word-break: break-all; font-size: 0.85rem;
    display: inline-block; cursor: copy;
    border: 1px solid var(--stroke); margin-top: 5px;
}

/* --- Footer & Links --- */
.footer-links { margin-top: 2rem; text-align: center; }
.back-link {
    color: var(--text-faint); text-decoration: none;
    font-size: 0.85rem; transition: color 0.2s; font-weight: 500;
}
.back-link:hover { color: var(--text-strong); }

.footer {
    display: flex; flex-direction: column; text-align: center; padding: 2rem 0 0.5rem;
}
.footer p {
    font-size: var(--fs-footer); font-weight: 300; color: var(--text-faint); letter-spacing: 0.02em;
}

/* --- Help Section & Stores --- */
.help-section {
    margin-top: 3rem; padding-top: 2rem;
    border-top: 1px solid var(--stroke);
    opacity: 0.7; transition: opacity 0.2s;
}
.help-section:hover { opacity: 1; }

.help-title {
    font-size: 0.75rem; font-weight: 700;
    color: var(--text-muted); margin-bottom: 0.75rem;
    text-transform: uppercase; letter-spacing: 0.1em; text-align: center;
}
.help-text {
    font-size: 0.85rem; color: var(--text-muted);
    line-height: 1.6; margin-bottom: 1.5rem; text-align: center; font-weight: 300;
}

.store-links { display: flex; justify-content: center; gap: 12px; }
.store-btn {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 16px; border: 1px solid var(--stroke);
    background: var(--surface);
    border-radius: 12px; text-decoration: none;
    color: var(--text-muted); font-size: 0.75rem;
    font-weight: 500; transition: all 0.2s;
}
.store-btn:hover { background: var(--surface-2); border-color: var(--stroke-2); color: var(--text-strong); }
.store-btn svg { width: 16px; height: 16px; filter: invert(0.6); transition: filter 0.2s; }
.store-btn:hover svg { filter: invert(1); }

/* --- Mobile --- */
@media (max-width: 600px) {
    :root {
        --fs-title: 1.3rem;
        --control-h: 54px;
    }
    body { align-items: flex-start; padding-top: 60px; }
    .container { padding: 15px; }
    .logo { width: 70px; height: 70px; }
    .logo img { width: 50px; }
    
    input, button { font-size: 16px !important; }
    input.code-input { font-size: 1.5rem !important; height: 60px; }
    
    .store-btn { padding: 6px 12px; }
}


/* --- Modal / Dialog Styles --- */
.sp-modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(12px); /* Frosted glass effekt */
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none; /* Klick går igenom när den är osynlig */
    transition: opacity 0.3s cubic-bezier(.2,.8,.2,1);
}

.sp-modal-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.sp-modal-card {
    width: 90%;
    max-width: 360px;
    background: #161616; /* Solid mörk bakgrund */
    border: 1px solid var(--stroke-2);
    border-radius: var(--r-lg);
    padding: 24px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,0.6);
    transform: scale(0.92) translateY(10px);
    transition: transform 0.3s cubic-bezier(.2,.8,.2,1);
}

.sp-modal-overlay.open .sp-modal-card {
    transform: scale(1) translateY(0);
}

.sp-modal-title {
    font-size: 1.1rem;
    color: var(--text-strong);
    margin-bottom: 12px;
    font-weight: 600;
}

.sp-modal-text {
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.5;
    margin-bottom: 24px;
}

.sp-modal-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

/* Om vi bara har en knapp (t.ex. "OK") */
.sp-modal-actions.single {
    grid-template-columns: 1fr;
}

/* Modal Knappar */
.sp-btn-modal {
    height: 42px;
    border-radius: var(--r-md);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    margin-top: 0 !important; /* Override global button */
}

.sp-btn-cancel {
    background: transparent;
    border: 1px solid var(--stroke);
    color: var(--text);
}
.sp-btn-cancel:hover {
    background: var(--surface);
    color: var(--text-strong);
}

/* Varianter för Confirm-knappen */
.sp-btn-confirm.danger {
    background: var(--danger);
    color: white;
}
.sp-btn-confirm.danger:hover {
    background: #ff3333;
}

.sp-btn-confirm.primary {
    background: white;
    color: black;
}
.sp-btn-confirm.primary:hover {
    background: #e0e0e0;
}