/* XPR Client Portal — Phase 1 styles
 * Self-contained: no Tailwind, no WP admin dependencies. Aim for a clean,
 * modern, agency-portal aesthetic that holds up across browsers and email
 * clients.
 */

* { box-sizing: border-box; }
html, body {
    margin: 0; padding: 0; min-height: 100%;
    background: #f4f6f9;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    color: #1d2327;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
a { color: #2271b1; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout ─────────────────────────────────────────────────────────────── */

.xpr-portal-header {
    display: flex; align-items: center; gap: 20px;
    padding: 12px 28px;
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    box-shadow: 0 1px 0 rgba(0,0,0,.02);
    position: sticky; top: 0; z-index: 50;
}
.xpr-portal-brand {
    display: flex; align-items: center; gap: 10px;
    color: inherit; text-decoration: none;
    flex-shrink: 0;
}
.xpr-portal-brand:hover { text-decoration: none; }
.xpr-portal-logo {
    max-height: 36px; max-width: 160px; object-fit: contain;
    display: block;
}
.xpr-portal-mark {
    width: 32px; height: 32px; border-radius: 8px;
    background: linear-gradient(135deg, #2271b1, #135e96);
    color: #fff; font-weight: 700; font-size: 14px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.xpr-portal-name { font-weight: 700; font-size: 15px; color: #0f172a; }

/* Active project bar — sits between brand and nav. */
.xpr-portal-projectbar {
    display: flex; align-items: center;
    margin-left: 8px;
    padding-left: 20px;
    border-left: 1px solid #e2e8f0;
    min-width: 0;
}

/* Project switcher button + dropdown */
.xpr-project-switcher { position: relative; }
.xpr-project-switcher-btn,
.xpr-project-switcher-static {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 6px 10px;
    background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 8px;
    font-family: inherit; font-size: 13px; color: #0f172a;
    cursor: pointer; max-width: 280px;
}
.xpr-project-switcher-btn:hover { border-color: #cbd5e1; background: #fff; }
.xpr-project-switcher-static { cursor: default; background: transparent; border-color: transparent; padding-left: 0; }
.xpr-project-switcher.is-open .xpr-project-switcher-btn {
    border-color: #2271b1;
    box-shadow: 0 0 0 2px rgba(34,113,177,.15);
}
.xpr-project-switcher-logo {
    width: 24px; height: 24px; border-radius: 5px;
    object-fit: contain; background: #fff;
    border: 1px solid #e2e8f0; padding: 2px;
    flex-shrink: 0;
}
.xpr-project-switcher-mark {
    width: 24px; height: 24px; border-radius: 5px;
    background: linear-gradient(135deg, #6366f1, #4338ca);
    color: #fff; font-weight: 700; font-size: 11px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.xpr-project-switcher-name {
    font-weight: 600; white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis;
    min-width: 0;
}
.xpr-project-switcher-caret { color: #94a3b8; font-size: 10px; }
.xpr-project-switcher-menu {
    position: absolute; top: calc(100% + 6px); left: 0;
    background: #fff; border: 1px solid #e2e8f0;
    border-radius: 10px; box-shadow: 0 10px 30px rgba(15,23,42,.10);
    list-style: none; margin: 0; padding: 4px;
    min-width: 280px; max-width: 360px;
    max-height: 360px; overflow-y: auto;
    z-index: 100;
}
.xpr-project-switcher-menu li { margin: 0; padding: 0; }
.xpr-project-switcher-item {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px; border-radius: 6px;
    font-size: 13px; color: #1d2327; text-decoration: none;
}
.xpr-project-switcher-item:hover { background: #f1f5f9; text-decoration: none; }
.xpr-project-switcher-item.is-current { background: #f0f6fc; color: #135e96; font-weight: 600; }
.xpr-project-switcher-tick { margin-left: auto; color: #2271b1; }

/* Section nav (Rankings / CRM) */
.xpr-portal-nav {
    display: flex; gap: 4px; flex: 1;
    align-items: center; justify-content: flex-start;
    margin-left: 4px;
}
.xpr-portal-nav-link {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 7px 12px; border-radius: 8px;
    font-size: 13px; font-weight: 500; color: #475569;
}
.xpr-portal-nav-link:hover { background: #f1f5f9; text-decoration: none; color: #1d2327; }
.xpr-portal-nav-link.is-active {
    background: #f0f6fc; color: #135e96;
    font-weight: 600;
}
.xpr-portal-nav-icon { font-size: 14px; }

.xpr-portal-user { display: flex; align-items: center; gap: 14px; flex-shrink: 0; }
.xpr-portal-email { font-size: 12px; color: #64748b; }
.xpr-portal-logout {
    font-size: 12px; color: #64748b; padding: 6px 12px;
    border: 1px solid #e2e8f0; border-radius: 6px;
}
.xpr-portal-logout:hover { color: #1d2327; border-color: #cbd5e1; text-decoration: none; }

@media (max-width: 880px) {
    .xpr-portal-header { flex-wrap: wrap; gap: 10px; padding: 10px 16px; }
    .xpr-portal-projectbar { padding-left: 0; border-left: 0; margin-left: 0; }
    .xpr-portal-nav { width: 100%; order: 4; }
    .xpr-portal-user { margin-left: auto; }
}

.xpr-portal-main {
    max-width: 1240px; margin: 0 auto; padding: 32px;
}
.xpr-portal-footer {
    text-align: center; padding: 24px;
    color: #94a3b8; font-size: 12px;
}

body.is-anon {
    background: linear-gradient(180deg, #f8fafc 0%, #eef2f7 100%);
    min-height: 100vh;
    display: flex; flex-direction: column; justify-content: center;
}
body.is-anon .xpr-portal-main {
    width: 100%; max-width: 460px; padding: 16px;
}
body.is-anon .xpr-portal-footer { padding: 12px; }

/* ── Cards ──────────────────────────────────────────────────────────────── */

.xpr-card {
    background: #fff; border: 1px solid #e2e8f0; border-radius: 14px;
    box-shadow: 0 1px 3px rgba(15,23,42,.04);
    padding: 28px;
}

/* ── Login ──────────────────────────────────────────────────────────────── */

.xpr-login-card { padding: 32px; }
.xpr-login-mark {
    width: 48px; height: 48px; border-radius: 12px;
    background: linear-gradient(135deg, #2271b1, #135e96);
    color: #fff; font-weight: 700; font-size: 20px;
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 18px;
}
.xpr-login-logo {
    max-height: 56px; max-width: 220px; object-fit: contain;
    display: block; margin-bottom: 18px;
}
.xpr-login-card h1 {
    margin: 0 0 8px; font-size: 22px; line-height: 1.25;
    color: #0f172a; font-weight: 700;
}
.xpr-login-lead {
    margin: 0 0 22px; color: #64748b; font-size: 14px; line-height: 1.55;
}
.xpr-login-error {
    background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c;
    padding: 10px 14px; border-radius: 8px; font-size: 13px;
    margin-bottom: 16px;
}
.xpr-login-label {
    display: block; font-size: 12px; font-weight: 600;
    color: #334155; margin-bottom: 6px; letter-spacing: .02em;
}
#xpr-login-email {
    width: 100%; padding: 11px 14px; font-size: 15px;
    border: 1px solid #cbd5e1; border-radius: 8px;
    background: #fff; transition: border-color .15s, box-shadow .15s;
}
#xpr-login-email:focus {
    outline: none; border-color: #2271b1;
    box-shadow: 0 0 0 3px rgba(34,113,177,.15);
}
.xpr-login-submit {
    width: 100%; margin-top: 16px;
    padding: 12px; font-size: 15px; font-weight: 600;
}
.xpr-login-status {
    margin-top: 12px; font-size: 13px; min-height: 18px;
    text-align: center;
}
.xpr-login-status.is-success { color: #047857; }
.xpr-login-status.is-error { color: #b91c1c; }
.xpr-login-tips {
    margin: 8px 0 0; padding-left: 18px; color: #475569;
    font-size: 13px; line-height: 1.7;
}
.xpr-login-foot {
    margin: 22px 0 0; font-size: 11px; color: #94a3b8;
    text-align: center;
}

/* ── Buttons ────────────────────────────────────────────────────────────── */

.xpr-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 9px 16px; font-size: 13px; font-weight: 600;
    border-radius: 8px; border: 1px solid transparent;
    cursor: pointer; transition: background .15s, border-color .15s, transform .05s;
    text-decoration: none;
    font-family: inherit;
}
.xpr-btn:active { transform: translateY(1px); }
.xpr-btn:disabled { opacity: .55; cursor: not-allowed; }
.xpr-btn-primary {
    background: #2271b1; color: #fff; border-color: #1e6299;
}
.xpr-btn-primary:hover { background: #135e96; text-decoration: none; }
.xpr-btn-secondary {
    background: #fff; color: #1d2327; border-color: #cbd5e1;
}
.xpr-btn-secondary:hover { background: #f8fafc; border-color: #94a3b8; text-decoration: none; }

/* ── Page chrome ────────────────────────────────────────────────────────── */

.xpr-page-header { margin-bottom: 24px; }
.xpr-page-header h1 {
    margin: 4px 0 6px; font-size: 26px; color: #0f172a; font-weight: 700;
}
.xpr-page-sub { margin: 0; color: #64748b; font-size: 14px; }
.xpr-back-link {
    display: inline-block; font-size: 12px; color: #64748b;
    margin-bottom: 6px;
}
.xpr-back-link:hover { color: #1d2327; }

/* ── Project grid ───────────────────────────────────────────────────────── */

.xpr-project-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}
.xpr-project-card {
    background: #fff; border: 1px solid #e2e8f0; border-radius: 12px;
    padding: 18px; display: flex; flex-direction: column; gap: 14px;
    transition: border-color .15s, box-shadow .15s, transform .05s;
}
.xpr-project-card:hover {
    border-color: #cbd5e1; box-shadow: 0 6px 18px rgba(15,23,42,.06);
}
.xpr-project-card-head { display: flex; gap: 12px; align-items: center; }
.xpr-project-mark {
    width: 44px; height: 44px; border-radius: 10px;
    background: linear-gradient(135deg, #6366f1, #4338ca);
    color: #fff; font-weight: 700; font-size: 18px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.xpr-project-logo {
    width: 44px; height: 44px; border-radius: 10px;
    object-fit: contain; background: #f8fafc; padding: 4px;
    border: 1px solid #e2e8f0;
}
.xpr-project-meta { min-width: 0; }
.xpr-project-name {
    margin: 0 0 2px; font-size: 15px; color: #0f172a; font-weight: 700;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.xpr-project-website {
    font-size: 12px; color: #64748b;
}
.xpr-project-website:hover { color: #2271b1; }
.xpr-project-actions { display: flex; gap: 8px; }
.xpr-project-actions .xpr-btn { flex: 1; }

/* ── Empty state ───────────────────────────────────────────────────────── */

.xpr-empty {
    text-align: center; padding: 60px 20px;
    color: #64748b;
}
.xpr-empty-icon { font-size: 48px; margin-bottom: 12px; }
.xpr-empty h3 { margin: 0 0 6px; color: #1d2327; font-size: 17px; }
.xpr-empty p { margin: 0; font-size: 14px; }

/* ── Mobile ────────────────────────────────────────────────────────────── */

@media (max-width: 640px) {
    .xpr-portal-header { flex-wrap: wrap; padding: 12px 16px; gap: 8px; }
    .xpr-portal-nav { width: 100%; }
    .xpr-portal-main { padding: 20px 16px; }
    .xpr-page-header h1 { font-size: 22px; }
    .xpr-project-grid { grid-template-columns: 1fr; }
}
