/* oauth.css — Shared styles for all OAuth/consent pages */
/* Used by: authorize.html, device_verify.html, device_approved.html, error.html, login container */

:root {
    --seedr-primary: #6366f1;
    --seedr-primary-hover: #4f46e5;
    --seedr-primary-light: #e0e7ff;
    --seedr-gray: #6b7280;
    --seedr-gray-light: #f3f4f6;
    --seedr-gray-medium: #d1d5db;
    --seedr-gray-dark: #374151;
    --seedr-text-muted: #6b7280;
    --seedr-card: #ffffff;
    --seedr-border: #e5e7eb;
    --seedr-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.07), 0 2px 4px -2px rgb(0 0 0 / 0.07);
    --seedr-radius: 0.5rem;
    --seedr-danger: #ef4444;
    --font-sans: 'Nunito Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

body.oauth-page {
    font-family: var(--font-sans);
    line-height: 1.5;
    color: var(--seedr-gray-dark);
    margin: 0;
    padding: 1rem;
    background: linear-gradient(135deg, #fbc2eb 0%, #a18cd1 50%, #fad0c4 100%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

/* --- Card container --- */
.oauth-card {
    max-width: 460px;
    width: 100%;
    padding: 2rem;
    background: var(--seedr-card);
    border-radius: 12px;
    box-shadow: var(--seedr-shadow);
    border: 1px solid var(--seedr-border);
}

/* --- Header: centered logo --- */
.oauth-header {
    text-align: center;
    margin-bottom: 1rem;
}
.oauth-logo { height: 26px; }

/* --- Account pill --- */
.oauth-account {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin: 0 auto 1.25rem;
    padding: 0.4rem 0.75rem;
    background: var(--seedr-gray-light);
    border: 1px solid var(--seedr-border);
    border-radius: 20px;
    font-size: 0.8rem;
    color: var(--seedr-text-muted);
    width: fit-content;
}
.oauth-account-avatar {
    width: 20px; height: 20px;
    border-radius: 50%;
    background: var(--seedr-primary);
    color: white;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.65rem; font-weight: 700;
    flex-shrink: 0;
}
.oauth-account-email {
    color: var(--seedr-gray-dark);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 220px;
}
.oauth-account a {
    color: var(--seedr-primary);
    font-size: 0.75rem;
    text-decoration: none;
    margin-left: 0.25rem;
}
.oauth-account a:hover { text-decoration: underline; }

/* --- App identity: icon left, name right --- */
.oauth-app {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}
.oauth-app-logo {
    width: 44px; height: 44px;
    border-radius: 10px;
    border: 1px solid var(--seedr-border);
    object-fit: cover;
    background-color: var(--seedr-gray-light);
    flex-shrink: 0;
}
.oauth-app-text { min-width: 0; }
.oauth-app-name {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--seedr-gray-dark);
    line-height: 1.3;
    word-wrap: break-word;
}
.oauth-app-sub {
    font-size: 0.8rem;
    color: var(--seedr-text-muted);
}

/* --- Scope list --- */
.oauth-scopes-wrapper {
    position: relative;
    margin-bottom: 1.25rem;
}
.oauth-scopes {
    border: 1px solid var(--seedr-border);
    border-radius: var(--seedr-radius);
    overflow-y: auto;
    max-height: 40vh;
}
/* Top + bottom fade shadows to indicate scroll — both directions */
.oauth-scopes-wrapper::before,
.oauth-scopes-wrapper::after {
    content: '';
    position: absolute;
    left: 1px; right: 1px;
    height: 24px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 1;
}
.oauth-scopes-wrapper::before {
    top: 0;
    background: linear-gradient(white 30%, transparent);
    border-radius: var(--seedr-radius) var(--seedr-radius) 0 0;
}
.oauth-scopes-wrapper::after {
    bottom: 0;
    background: linear-gradient(transparent, white 70%);
    border-radius: 0 0 var(--seedr-radius) var(--seedr-radius);
}
.oauth-scopes-wrapper.fade-bottom::after { opacity: 1; }
.oauth-scopes-wrapper.fade-top::before { opacity: 1; }
/* Scroll count badge — "N more below" */
.oauth-scroll-hint {
    text-align: center;
    font-size: 0.7rem;
    color: var(--seedr-text-muted);
    margin-top: 0.25rem;
}
.oauth-scope-group {
    padding: 0.6rem 0.875rem;
    border-bottom: 1px solid var(--seedr-border);
}
.oauth-scope-group:last-child { border-bottom: none; }
.oauth-scope-label {
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--seedr-gray-dark);
}
.oauth-scope-desc {
    font-size: 0.8rem;
    color: var(--seedr-text-muted);
    line-height: 1.4;
    margin-top: 0.1rem;
}
/* Flat scope item (ungrouped fallback) */
.oauth-scope-item {
    padding: 0.6rem 0.875rem;
    border-bottom: 1px solid var(--seedr-border);
}
.oauth-scope-item:last-child { border-bottom: none; }

/* --- Buttons --- */
.oauth-buttons {
    display: flex;
    gap: 0.75rem;
}
.oauth-btn {
    flex: 1;
    padding: 0.7rem 1rem;
    border-radius: var(--seedr-radius);
    border: 1px solid transparent;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    font-family: var(--font-sans);
    transition: background-color 0.15s, border-color 0.15s;
}
.oauth-btn-primary {
    background: var(--seedr-primary);
    color: white;
    border-color: var(--seedr-primary);
}
.oauth-btn-primary:hover {
    background: var(--seedr-primary-hover);
    border-color: var(--seedr-primary-hover);
}
.oauth-btn-secondary {
    background: var(--seedr-card);
    color: var(--seedr-gray-dark);
    border-color: var(--seedr-gray-medium);
}
.oauth-btn-secondary:hover {
    background: var(--seedr-gray-light);
    border-color: var(--seedr-gray);
}

/* --- Alerts / Errors --- */
.oauth-alert {
    padding: 0.6rem 0.75rem;
    margin-bottom: 1rem;
    border-radius: var(--seedr-radius);
    font-size: 0.85rem;
    line-height: 1.4;
}
.oauth-alert-danger {
    background-color: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}
.oauth-alert-success {
    background: #ecfdf5;
    color: #059669;
    border: 1px solid #6ee7b7;
}
.oauth-alert-warning {
    background: #fffbeb;
    color: #92400e;
    border: 1px solid #fcd34d;
}

/* --- Disclaimer / footer text --- */
.oauth-disclaimer {
    margin-top: 1.25rem;
    text-align: center;
    font-size: 0.75rem;
    color: var(--seedr-text-muted);
    line-height: 1.4;
}
.oauth-disclaimer a {
    color: var(--seedr-primary);
    text-decoration: none;
}
.oauth-disclaimer a:hover { text-decoration: underline; }

/* --- Step indicator --- */
.oauth-steps {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin-bottom: 1.25rem;
}
.oauth-step {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
    color: var(--seedr-text-muted);
}
.oauth-step-num {
    background-color: var(--seedr-gray-light);
    color: var(--seedr-gray);
    width: 22px; height: 22px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.75rem; font-weight: 700;
}
.oauth-step.active .oauth-step-num { background-color: var(--seedr-primary); color: white; }
.oauth-step.active { color: var(--seedr-primary); font-weight: 600; }

/* --- Code input (device flow) --- */
.oauth-code-input {
    display: flex;
    justify-content: center;
    gap: 0.375rem;
    margin-bottom: 1rem;
}
.oauth-code-input input {
    width: 2.75rem; height: 2.75rem;
    font-size: 1.25rem;
    text-align: center;
    border: 2px solid var(--seedr-gray-medium);
    border-radius: var(--seedr-radius);
    background: var(--seedr-gray-light);
    font-family: var(--font-sans);
}
.oauth-code-input input:focus {
    border-color: var(--seedr-primary);
    outline: none;
    background: white;
}

/* --- Error page --- */
.oauth-error-box {
    text-align: center;
    padding: 1.5rem 1rem;
    margin-bottom: 1rem;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: var(--seedr-radius);
}
.oauth-error-box .error-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    line-height: 1;
}
.oauth-error-box .error-title {
    font-weight: 700;
    font-size: 1rem;
    color: #991b1b;
    margin-bottom: 0.35rem;
}
.oauth-error-box .error-code {
    font-size: 0.75rem;
    font-weight: 600;
    color: #b91c1c;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 0.35rem;
}
.oauth-error-box .error-message {
    font-size: 0.85rem;
    color: #7f1d1d;
    line-height: 1.4;
}

/* --- Login page container --- */
.oauth-login-card {
    max-width: 400px;
    width: 100%;
    padding: 1.5rem;
    background: var(--seedr-card);
    border-radius: 12px;
    box-shadow: var(--seedr-shadow);
    border: 1px solid var(--seedr-border);
}
.oauth-login-card .oauth-header { margin-bottom: 0; }
.oauth-login-iframe {
    overflow: hidden;
    height: 480px;
    border: none;
    border-radius: var(--seedr-radius);
}
.oauth-login-iframe iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* --- Footer --- */
.oauth-footer {
    text-align: center;
    padding: 0.75rem;
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.65);
}
.oauth-footer p { margin: 0.2rem 0; }
.oauth-footer a {
    color: white;
    text-decoration: none;
    font-weight: 600;
}
.oauth-footer a:hover { text-decoration: underline; }

/* =========================== */
/* Mobile: white bg, no card    */
/* =========================== */
@media (max-width: 480px) {
    body.oauth-page {
        padding: 0;
        align-items: stretch;
        background: white;
    }
    .oauth-card {
        border-radius: 0;
        padding: 1rem;
        border: none;
        box-shadow: none;
        max-width: none;
    }
    .oauth-card.oauth-card-center {
        padding-top: 3rem;
    }
    .oauth-login-card {
        border-radius: 0;
        padding: 0.75rem;
        padding-bottom: 0;
        border: none;
        box-shadow: none;
        max-width: none;
    }
    .oauth-login-iframe {
        height: 480px;
        border-radius: 0;
    }
    .oauth-scopes { border-left: none; border-right: none; border-radius: 0; margin-left: -1rem; margin-right: -1rem; }
    .oauth-buttons { padding: 0.25rem 0; }
    .oauth-disclaimer { margin-top: 0.75rem; font-size: 0.7rem; }
    .oauth-code-input input { width: 2.25rem; height: 2.25rem; font-size: 1.1rem; }
    .oauth-footer { padding: 0.4rem 0.75rem; background: white; }
    .oauth-footer, .oauth-footer a { color: var(--seedr-text-muted); }
}

@media (min-width: 481px) and (max-width: 1024px) {
    /* Tablet: wider card */
    .oauth-card { max-width: 520px; }
    .oauth-login-card { max-width: 480px; }
    .oauth-login-iframe { height: 520px; }
}

@media (max-width: 360px) {
    .oauth-code-input input { width: 2rem; height: 2rem; font-size: 1rem; }
    .oauth-app-logo { width: 36px; height: 36px; }
    .oauth-app-name { font-size: 0.85rem; }
    .oauth-card { padding: 0.75rem; }
    .oauth-header { margin-bottom: 0.5rem; }
    .oauth-account { margin-bottom: 0.75rem; padding: 0.3rem 0.6rem; font-size: 0.75rem; }
    .oauth-app { margin-bottom: 0.75rem; }
    .oauth-scopes { max-height: 35vh; margin-left: -0.75rem; margin-right: -0.75rem; }
    .oauth-disclaimer { margin-top: 0.5rem; font-size: 0.65rem; }
}

/* =========================== */
/* Embedded login variant       */
/* Activated via ?style=embed   */
/* Add class "oauth-embed" to   */
/* body to activate              */
/* =========================== */
body.oauth-embed {
    background: white;
    padding: 0;
}
body.oauth-embed .oauth-login-card {
    max-width: none;
    border: none;
    box-shadow: none;
    border-radius: 0;
    padding: 0.75rem 0 0;
    flex: 1;
}
body.oauth-embed .oauth-login-iframe {
    height: 480px;
}
body.oauth-embed .oauth-footer {
    color: var(--seedr-text-muted);
}
body.oauth-embed .oauth-footer a {
    color: var(--seedr-gray-dark);
}
