/* Portal de Proveedores — estilos base
   Fuente y colores de marca, comunes a auth y dashboard. */

:root {
    --sp-primary:    #1a56db;
    --sp-primary-dk: #1e429f;
    --sp-accent:     #f59e0b;
    --sp-bg:         #f3f4f6;
    --sp-surface:    #ffffff;
    --sp-text:       #111827;
    --sp-muted:      #6b7280;
    --sp-border:     #e5e7eb;
    --sp-radius:     0.5rem;
    --sp-shadow:     0 1px 3px 0 rgb(0 0 0 / .10), 0 1px 2px -1px rgb(0 0 0 / .10);
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

html, body.sp-body {
    min-height: 100vh;
    min-height: 100dvh;
    background-color: var(--sp-bg);
    color: var(--sp-text);
    font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    -webkit-tap-highlight-color: rgb(26 86 219 / 12%);
}

body.sp-body {
    padding-left: env(safe-area-inset-left, 0);
    padding-right: env(safe-area-inset-right, 0);
    padding-bottom: env(safe-area-inset-bottom, 0);
}

/* Barra superior del portal */
.sp-topbar {
    background: var(--sp-primary);
    color: #fff;
    padding: .75rem 1.25rem;
    padding-top: max(.75rem, env(safe-area-inset-top, 0px));
    padding-left: max(1.25rem, env(safe-area-inset-left, 0px));
    padding-right: max(1.25rem, env(safe-area-inset-right, 0px));
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .65rem .75rem;
    box-shadow: var(--sp-shadow);
}

.sp-topbar__brand {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-weight: 700;
    font-size: clamp(0.9rem, 3.5vw, 1.1rem);
    color: #fff;
    text-decoration: none;
    line-height: 1.25;
    min-width: 0;
    flex: 1 1 auto;
}

.sp-topbar__brand-badge {
    background: var(--sp-accent);
    color: #000;
    font-size: .65rem;
    font-weight: 700;
    padding: .15rem .45rem;
    border-radius: 999px;
    letter-spacing: .03em;
    text-transform: uppercase;
}

.sp-topbar__user {
    font-size: .8125rem;
    display: flex;
    align-items: center;
    gap: .5rem .65rem;
    color: rgba(255,255,255,.9);
    flex-wrap: wrap;
    justify-content: flex-end;
    min-width: 0;
    flex: 1 1 auto;
    max-width: 100%;
}

.sp-topbar__user > span {
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Solo lectura: usuario de acceso al portal (no editable) */
.sp-topbar__login-id {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-end;
    gap: .05rem;
    max-width: min(220px, 100%);
    flex-shrink: 1;
    min-width: 0;
    user-select: none;
    pointer-events: none;
}

.sp-topbar__login-id-label {
    font-size: .65rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, .55);
    line-height: 1.2;
}

.sp-topbar__login-id-value {
    font-size: .8125rem;
    font-weight: 600;
    color: rgba(255, 255, 255, .72);
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

.sp-topbar__logout {
    color: #fff;
    font-size: .8125rem;
    font-weight: 600;
    text-decoration: none;
    border: 1px solid rgba(255,255,255,.45);
    padding: .5rem .85rem;
    min-height: 44px;
    min-width: 44px;
    box-sizing: border-box;
    border-radius: var(--sp-radius);
    transition: background .15s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .35rem;
    flex-shrink: 0;
}

.sp-topbar__logout:hover,
.sp-topbar__logout:focus-visible {
    background: rgba(255,255,255,.15);
    color: #fff;
}

.sp-topbar__logout:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

@media (max-width: 480px) {
    .sp-topbar {
        flex-direction: column;
        align-items: stretch;
    }

    .sp-topbar__brand {
        flex: none;
        width: 100%;
    }

    .sp-topbar__user {
        flex: none;
        width: 100%;
        justify-content: space-between;
        padding-top: .35rem;
        border-top: 1px solid rgba(255,255,255,.2);
    }

    .sp-topbar__user > span {
        white-space: normal;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
        line-height: 1.3;
    }
}

/* Contenido principal */
.sp-main {
    max-width: 1100px;
    margin: 1.25rem auto 2rem;
    padding: 0 max(1rem, env(safe-area-inset-left, 0px)) 0 max(1rem, env(safe-area-inset-right, 0px));
}

@media (min-width: 768px) {
    .sp-main {
        margin-top: 2rem;
    }
}

/* Tarjeta genérica */
.sp-card {
    background: var(--sp-surface);
    border: 1px solid var(--sp-border);
    border-radius: var(--sp-radius);
    box-shadow: var(--sp-shadow);
    padding: 1.5rem;
}

/* Alertas de feedback */
.sp-alert {
    padding: .75rem 1rem;
    border-radius: var(--sp-radius);
    font-size: .9rem;
    line-height: 1.45;
    margin-bottom: 1rem;
    word-break: break-word;
}
.sp-alert--danger  { background: #fee2e2; color: #991b1b; border-left: 4px solid #dc2626; }
.sp-alert--success { background: #d1fae5; color: #065f46; border-left: 4px solid #10b981; }
.sp-alert--info    { background: #dbeafe; color: #1e40af; border-left: 4px solid #3b82f6; }
.sp-alert--warning { background: #fef3c7; color: #92400e; border-left: 4px solid #f59e0b; }

/* Botón primario del portal */
.sp-btn-primary {
    background: var(--sp-primary);
    color: #fff;
    border: none;
    padding: .75rem 1.25rem;
    min-height: 48px;
    border-radius: var(--sp-radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s;
    width: 100%;
    box-sizing: border-box;
}
.sp-btn-primary:hover { background: var(--sp-primary-dk); color: #fff; }

.sp-btn-primary:focus-visible {
    outline: 2px solid var(--sp-primary-dk);
    outline-offset: 2px;
}

.sp-btn-secondary {
    background: transparent;
    color: var(--sp-primary);
    border: 1px solid var(--sp-primary);
    padding: .5rem 1.2rem;
    border-radius: var(--sp-radius);
    font-size: .9rem;
    cursor: pointer;
    transition: background .15s;
    text-decoration: none;
    display: inline-block;
}
.sp-btn-secondary:hover { background: var(--sp-primary); color: #fff; }

/* Pie de página mínimo */
.sp-footer {
    text-align: center;
    color: var(--sp-muted);
    font-size: .8rem;
    padding: 1.5rem 1rem calc(1rem + env(safe-area-inset-bottom, 0px));
    line-height: 1.4;
}

@media (prefers-reduced-motion: reduce) {
    .sp-btn-primary,
    .sp-topbar__logout {
        transition: none;
    }
}
