/* Vista #gateways (JAK-17). Mobile-first. */

.gateways-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    align-items: center;
    margin-bottom: var(--space-md);
}

.gateways-toolbar__group {
    display: flex;
    gap: var(--space-xs);
    align-items: center;
    font-size: 0.875rem;
}

.gateways-toolbar__group label {
    color: var(--text-muted);
}

.gateways-toolbar select {
    padding: 0.5rem 0.625rem;
    background: var(--bg-elevated);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.875rem;
}

.gateways-toolbar__refreshing {
    font-size: 0.75rem;
    color: var(--accent);
    font-style: italic;
    margin-left: auto;
}

/* ==================== Grid ==================== */

.gateway-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-md);
}

@media (min-width: 640px) {
    .gateway-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1024px) {
    .gateway-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ==================== Card ==================== */

.gateway-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-md);
    cursor: pointer;
    transition: border-color 0.15s, transform 0.05s;
}

.gateway-card:hover,
.gateway-card:focus-visible {
    border-color: var(--accent);
    outline: none;
}

.gateway-card:active {
    transform: scale(0.99);
}

.gateway-card__head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--space-sm);
    margin-bottom: var(--space-sm);
}

.gateway-card__name {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text);
    word-break: break-word;
}

.gateway-card__meta {
    color: var(--text-muted);
    font-size: 0.8125rem;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.gateway-card__meta strong {
    color: var(--text);
    font-weight: 500;
}

.gateway-card__row {
    display: flex;
    justify-content: space-between;
    gap: var(--space-sm);
    margin-top: var(--space-sm);
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.gateway-card__row span strong {
    color: var(--text);
    font-weight: 500;
}

/* ==================== Footer paginación ==================== */

.gateways-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: var(--space-lg);
    color: var(--text-muted);
    font-size: 0.875rem;
    gap: var(--space-sm);
    flex-wrap: wrap;
}

.gateways-footer__buttons {
    display: flex;
    gap: var(--space-sm);
}

/* ==================== FAB ==================== */

.fab {
    position: fixed;
    right: var(--space-md);
    bottom: calc(var(--space-md) + env(safe-area-inset-bottom) + 64px);
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--accent);
    border: none;
    color: #fff;
    font-size: 1.75rem;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
}

.fab:hover {
    background: var(--accent-hover);
}

@media (min-width: 768px) {
    .fab {
        /* En desktop no hay bottom-nav. */
        bottom: var(--space-lg);
    }
}

/* ==================== Modal centrado (registrar gateway) ==================== */

.modal-center__overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-md);
}

.modal-center {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    max-width: 460px;
    width: 100%;
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
    z-index: 101;
}

.modal-center__header {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--bg-elevated);
    padding: var(--space-md);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-center__footer {
    position: sticky;
    bottom: 0;
    background: var(--bg-elevated);
}

.modal-center__header h2 {
    margin: 0;
    font-size: 1rem;
}

.modal-center__close {
    background: transparent;
    border: none;
    color: var(--text);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0 var(--space-sm);
}

.modal-center__close:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.modal-center__body {
    padding: var(--space-md);
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.modal-center__footer {
    padding: var(--space-md);
    border-top: 1px solid var(--border);
    display: flex;
    gap: var(--space-sm);
    justify-content: flex-end;
}

.token-display {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--space-md);
    font-family: ui-monospace, "SF Mono", Consolas, monospace;
    font-size: 0.875rem;
    word-break: break-all;
    color: var(--accent);
    user-select: all;
}

.copy-feedback {
    color: #3fb950;
    font-size: 0.875rem;
    margin-left: var(--space-sm);
}

.token-warning {
    background: rgba(218, 165, 32, 0.1);
    border: 1px solid rgba(218, 165, 32, 0.4);
    border-radius: var(--radius);
    padding: var(--space-sm) var(--space-md);
    color: #f1c40f;
    font-size: 0.875rem;
}

.token-checkbox {
    display: flex;
    gap: var(--space-sm);
    align-items: center;
    font-size: 0.875rem;
    cursor: pointer;
}

.token-checkbox input {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.modal-error {
    background: rgba(248, 81, 73, 0.1);
    border: 1px solid rgba(248, 81, 73, 0.4);
    border-radius: var(--radius);
    padding: var(--space-sm) var(--space-md);
    color: #ff7b72;
    font-size: 0.875rem;
}

.modal-textarea {
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.5rem 0.625rem;
    font-family: inherit;
    font-size: 0.875rem;
    resize: vertical;
    min-height: 80px;
}

.notes-counter {
    text-align: right;
    color: var(--text-muted);
    font-size: 0.75rem;
}

.notes-counter--over {
    color: #ff7b72;
}

/* ==================== Modal help / instructivo ==================== */

.modal-help {
    background: rgba(47, 129, 247, 0.07);
    border: 1px solid rgba(47, 129, 247, 0.25);
    border-radius: var(--radius);
    padding: var(--space-md);
    font-size: 0.875rem;
    color: var(--text);
}

.modal-help p {
    margin: 0;
}

.modal-help p + p {
    margin-top: var(--space-sm);
}

.modal-help code {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 1px 6px;
    font-family: ui-monospace, "SF Mono", Consolas, monospace;
    font-size: 0.8125rem;
    color: var(--accent);
}

.modal-help__examples {
    color: var(--text-muted);
}

.modal-help__warn {
    color: #f1c40f;
}

.modal-help__label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: var(--space-xs);
    font-weight: 600;
}

.modal-help__steps {
    margin: var(--space-sm) 0;
    padding-left: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.modal-help__steps li {
    line-height: 1.5;
}

.token-display--id {
    color: var(--text);
    font-size: 0.8125rem;
}

.modal-decomm-warn {
    background: rgba(248, 81, 73, 0.10);
    border: 1px solid rgba(248, 81, 73, 0.4);
    border-radius: var(--radius);
    padding: var(--space-md);
    font-size: 0.875rem;
    color: var(--text);
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.modal-decomm-warn p {
    margin: 0;
    line-height: 1.5;
}
