/* ── Theme tokens ───────────────────────────────────────────── */
:root {
    --pg-bg:            #f4f4f5;
    --pg-gradient:      linear-gradient(135deg, #dbeafe 0%, #f1f5f9 50%, #ede9fe 100%);
    --card-bg:          #ffffff;
    --card-border:      #e4e4e7;
    --text:             #09090b;
    --text-muted:       #71717a;
    --placeholder:      #a1a1aa;
    --input-bg:         #ffffff;
    --input-border:     #e4e4e7;
    --input-focus:      #71717a;
    --btn-bg:           #09090b;
    --btn-text:         #fafafa;
    --btn-hover:        #18181b;
    --divider-color:    #e4e4e7;
    --link-color:       #09090b;
    --link-muted:       #71717a;
    --toggle-border:    #e4e4e7;
    --toggle-color:     #71717a;
    --toggle-hover-bg:  #f4f4f5;
    --spinner-border:   #09090b;
}

[data-bs-theme="dark"] {
    --pg-bg:            #09090b;
    --pg-gradient:      linear-gradient(135deg, #0f172a 0%, #09090b 50%, #1e0a2e 100%);
    --card-bg:          #0f0f12;
    --card-border:      #27272a;
    --text:             #fafafa;
    --text-muted:       #a1a1aa;
    --placeholder:      #52525b;
    --input-bg:         #09090b;
    --input-border:     #27272a;
    --input-focus:      #71717a;
    --btn-bg:           #fafafa;
    --btn-text:         #09090b;
    --btn-hover:        #e4e4e7;
    --divider-color:    #27272a;
    --link-color:       #fafafa;
    --link-muted:       #a1a1aa;
    --toggle-border:    #27272a;
    --toggle-color:     #a1a1aa;
    --toggle-hover-bg:  #18181b;
    --spinner-border:   #09090b;
    --section-label:    #818cf8;
}

/* ── Base ───────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    min-height: 100vh;
    background: var(--pg-gradient);
    color: var(--text);
    font-family: 'Inter', sans-serif;
    font-size: 16px;
    transition: background 0.3s, color 0.2s;
}

body {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    position: relative;
    min-height: 100dvh;
}

.login-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: center;
    width: 100%;
    max-width: 1000px;
    gap: 2rem;
    position: relative;
    z-index: 1;
}

.cloud-side {
    display: flex;
    align-items: center;
    justify-content: center;
}

#icon-cloud-canvas {
    cursor: grab;
    border-radius: 0.5rem;
}

#icon-cloud-canvas:active { cursor: grabbing; }

@media (max-width: 768px) {
    .login-layout { grid-template-columns: 1fr; }
    .cloud-side { display: none; }
}

.striped-pattern {
    pointer-events: none;
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    color: rgba(99, 102, 241, 0.35);
    stroke-width: 0.5;
}

[data-bs-theme="dark"] .striped-pattern {
    color: rgba(165, 180, 252, 0.2);
}

/* ── Theme toggle ───────────────────────────────────────────── */
.theme-toggle {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1050;
    background: none;
    border: 1px solid var(--toggle-border);
    border-radius: 0.375rem;
    color: var(--toggle-color);
    width: 2.25rem;
    height: 2.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.theme-toggle:hover {
    border-color: var(--input-focus);
    color: var(--text);
    background: var(--toggle-hover-bg);
}

/* ── Wrapper & card ─────────────────────────────────────────── */
.login-wrapper {
    width: 100%;
    position: relative;
    z-index: 1;
    max-width: 400px;
}

.branding {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.625rem;
    margin-bottom: 1.75rem;
}
.branding img {
    width: 32px; height: 32px;
    border-radius: 50%;
    object-fit: cover;
}
.branding-name {
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.01em;
}

.branding-name em {
    font-style: normal;
    color: var(--section-label);
}

.login-card {
    background-color: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 0.75rem;
    padding: 2rem;
    transition: background-color 0.2s, border-color 0.2s;
    position: relative;
}

@keyframes border-beam {
    from { offset-distance: 0%; }
    to   { offset-distance: 100%; }
}

.border-beam-wrap {
    pointer-events: none;
    position: absolute;
    inset: 0;
    border-radius: inherit;
    border: 1px solid transparent;
    -webkit-mask-image: linear-gradient(#000 0 0), linear-gradient(#000 0 0);
    mask-image: linear-gradient(#000 0 0), linear-gradient(#000 0 0);
    -webkit-mask-clip: padding-box, border-box;
    mask-clip: padding-box, border-box;
    -webkit-mask-composite: xor;
    mask-composite: exclude;
}

.border-beam {
    position: absolute;
    width: 80px;
    aspect-ratio: 1 / 1;
    background: linear-gradient(to left, transparent, #9c40ff, #ffaa40);
    offset-path: rect(0 auto auto 0 round 0.75rem);
    animation: border-beam 6s linear infinite;
}

.login-header { margin-bottom: 1.5rem; }
.login-header h1 {
    font-size: 1.375rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 0.375rem;
    letter-spacing: -0.02em;
}
.login-header p {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* ── Form elements ──────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 0.375rem;
}

.label-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.375rem;
}
.label-row .form-label { margin-bottom: 0; }

.forgot-link {
    font-size: 0.8125rem;
    color: var(--text-muted);
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-color: transparent;
    transition: color 0.15s, text-decoration-color 0.15s;
}
.forgot-link:hover {
    color: var(--text);
    text-decoration-color: var(--text-muted);
}

.shadcn-input {
    width: 100%;
    background-color: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 0.375rem;
    color: var(--text);
    font-size: 0.875rem;
    font-family: 'Inter', sans-serif;
    padding: 0.5rem 0.75rem;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s, background-color 0.2s;
}
.shadcn-input::placeholder { color: var(--placeholder); }
.shadcn-input:focus {
    border-color: var(--input-focus);
    box-shadow: 0 0 0 2px rgba(113,113,122,0.2);
}

.pw-wrap { position: relative; }
.pw-wrap .shadcn-input { padding-right: 2.5rem; }

.toggle-pw {
    position: absolute;
    right: 0.625rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem;
    display: flex;
    align-items: center;
    transition: color 0.15s;
}
.toggle-pw:hover { color: var(--text); }

/* ── Submit button ──────────────────────────────────────────── */
.btn-login {
    width: 100%;
    background-color: var(--btn-bg);
    color: var(--btn-text);
    border: none;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    padding: 0.5625rem 1rem;
    cursor: pointer;
    margin-top: 0.5rem;
    transition: background-color 0.15s, opacity 0.15s;
}
.btn-login:hover:not(:disabled) { background-color: var(--btn-hover); }
.btn-login:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Google button ──────────────────────────────────────────── */
.btn-google {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.625rem;
    background-color: var(--card-bg);
    color: var(--text);
    border: 1px solid var(--card-border);
    border-radius: 0.375rem;
    font-size: 0.875rem;
    font-weight: 500;
    font-family: 'Inter', sans-serif;
    padding: 0.5625rem 1rem;
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s, opacity 0.15s;
}
.btn-google:hover:not(:disabled) {
    background-color: var(--toggle-hover-bg);
    border-color: var(--input-focus);
}
.btn-google:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Divider & footer ───────────────────────────────────────── */
.divider {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 1.25rem 0;
}
.divider::before, .divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--divider-color);
    transition: background 0.2s;
}
.divider span {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.signup-text {
    text-align: center;
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-top: 1.25rem;
}
.signup-text a {
    color: var(--link-color);
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-color: var(--divider-color);
    transition: text-decoration-color 0.15s;
}
.signup-text a:hover { text-decoration-color: var(--link-color); }

.back-home {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    font-size: 0.8125rem;
    color: var(--text-muted);
    text-decoration: none;
    margin-top: 1.25rem;
    transition: color 0.15s;
}
.back-home:hover { color: var(--text); }
.back-home i { font-size: 0.7rem; }

/* ── Spinner ────────────────────────────────────────────────── */
.spinner {
    display: inline-block;
    width: 0.875rem;
    height: 0.875rem;
    border: 2px solid var(--spinner-border);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    vertical-align: middle;
    margin-right: 0.375rem;
}
@keyframes spin { to { transform: rotate(360deg); } }
