/* ============================================
   RAILWAY BACKEND INTEGRATION UI
   Credential warnings, update modal, refresh button
   ============================================ */

/* ===== CREDENTIAL WARNING BANNER ===== */
.railway-banner {
    background: linear-gradient(135deg, #DC2626 0%, #991B1B 100%);
    border-radius: 10px;
    padding: 14px 20px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    color: #fff;
    font-size: 0.9rem;
    animation: bannerSlideIn 0.3s ease-out;
}

.railway-banner.hidden {
    display: none;
}

.railway-banner-content {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.railway-banner-icon {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
}

.railway-banner-text strong {
    display: block;
    font-size: 0.85rem;
    margin-bottom: 2px;
}

.railway-banner-text span {
    opacity: 0.9;
    font-size: 0.8rem;
}

.railway-banner-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.railway-banner-btn {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.railway-banner-btn:hover {
    background: rgba(255, 255, 255, 0.35);
}

.railway-banner-dismiss {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    padding: 4px;
    font-size: 1.2rem;
    line-height: 1;
}

.railway-banner-dismiss:hover {
    color: #fff;
}

@keyframes bannerSlideIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== CREDENTIAL UPDATE MODAL ===== */
.railway-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.railway-modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.railway-modal {
    background: #fff;
    border-radius: 16px;
    width: 560px;
    max-width: 95vw;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalFadeIn 0.25s ease-out;
}

.railway-modal-header {
    background: linear-gradient(135deg, var(--midnight-blue, #1D2A44) 0%, var(--space-blue, #004861) 100%);
    color: #fff;
    padding: 20px 24px;
    border-radius: 16px 16px 0 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.railway-modal-header h2 {
    font-size: 1.15rem;
    font-weight: 700;
    margin: 0;
}

.railway-modal-close {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.8);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

.railway-modal-close:hover {
    color: #fff;
}

.railway-modal-body {
    padding: 24px;
}

.railway-status-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 24px;
}

.railway-status-card {
    border: 1px solid var(--gray-200, #E5E7EB);
    border-radius: 10px;
    padding: 14px;
    text-align: center;
}

.railway-status-card.valid {
    border-color: #059669;
    background: #F0FDF4;
}

.railway-status-card.expired,
.railway-status-card.missing {
    border-color: #DC2626;
    background: #FEF2F2;
}

.railway-status-card.partial {
    border-color: #D97706;
    background: #FFFBEB;
}

.railway-status-card .platform-name {
    font-weight: 700;
    font-size: 0.85rem;
    margin-bottom: 4px;
    color: var(--midnight-blue, #1D2A44);
}

.railway-status-card .status-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.railway-status-card.valid .status-badge {
    background: #059669;
    color: #fff;
}

.railway-status-card.expired .status-badge,
.railway-status-card.missing .status-badge {
    background: #DC2626;
    color: #fff;
}

.railway-status-card.partial .status-badge {
    background: #D97706;
    color: #fff;
}

.railway-cred-section {
    margin-bottom: 20px;
}

.railway-cred-section h3 {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--midnight-blue, #1D2A44);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.railway-cred-section p {
    font-size: 0.78rem;
    color: var(--gray-600, #4B5563);
    margin-bottom: 10px;
    line-height: 1.5;
}

.railway-cred-section p a {
    color: var(--edutopia-orange, #FF4C00);
    font-weight: 600;
    text-decoration: none;
}

.railway-cred-section p a:hover {
    text-decoration: underline;
}

.railway-cred-help {
    font-size: 0.75rem;
    margin-bottom: 12px;
    background: var(--gray-50, #F9FAFB);
    border: 1px solid var(--gray-200, #E5E7EB);
    border-radius: 8px;
    padding: 8px 12px;
}

.railway-cred-help summary {
    cursor: pointer;
    color: var(--gray-600, #4B5563);
    font-weight: 600;
}

.railway-cred-help p {
    margin: 8px 0 6px;
    font-size: 0.72rem;
}

.railway-cred-snippet {
    display: block;
    background: var(--gray-100, #F3F4F6);
    border: 1px solid var(--gray-200, #E5E7EB);
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 0.68rem;
    line-height: 1.5;
    word-break: break-all;
    color: var(--gray-800, #1F2937);
    user-select: all;
}

.railway-cred-field {
    margin-bottom: 10px;
}

.railway-cred-field label {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--gray-700, #374151);
    margin-bottom: 4px;
}

.railway-cred-field textarea {
    width: 100%;
    min-height: 56px;
    padding: 8px 10px;
    border: 1px solid var(--gray-200, #E5E7EB);
    border-radius: 8px;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', monospace;
    font-size: 0.72rem;
    resize: vertical;
    transition: border-color 0.15s;
    color: var(--gray-800, #1F2937);
}

.railway-cred-field textarea:focus {
    outline: none;
    border-color: var(--pacific-blue, #0094C7);
    box-shadow: 0 0 0 3px rgba(0, 148, 199, 0.1);
}

.railway-modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--gray-200, #E5E7EB);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.railway-feedback {
    font-size: 0.8rem;
    flex: 1;
}

.railway-feedback.success {
    color: #059669;
}

.railway-feedback.error {
    color: #DC2626;
}

.railway-save-btn {
    background: var(--edutopia-orange, #FF4C00);
    color: #fff;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.railway-save-btn:hover {
    background: #E04400;
}

.railway-save-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.railway-save-btn .spinner-sm {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes modalFadeIn {
    from { opacity: 0; transform: translateY(12px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ===== REFRESH BUTTON ===== */
.railway-refresh-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.15);
    padding: 8px 16px;
    border-radius: 100px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    backdrop-filter: blur(8px);
}

.railway-refresh-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.railway-refresh-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.railway-refresh-btn svg {
    width: 14px;
    height: 14px;
    transition: transform 0.3s;
}

.railway-refresh-btn.spinning svg {
    animation: spin 1s linear infinite;
}

.railway-refresh-btn span {
    font-variant-numeric: tabular-nums;
    min-width: 50px;
    text-align: center;
}

.railway-refresh-btn.success {
    border-color: #059669;
    color: #A7F3D0;
}

.railway-refresh-btn.error {
    border-color: #DC2626;
    color: #FCA5A5;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== TOAST NOTIFICATION ===== */
.railway-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 14px 20px;
    border-radius: 10px;
    color: #fff;
    font-size: 0.85rem;
    font-weight: 500;
    z-index: 11000;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    animation: toastSlideIn 0.3s ease-out;
    max-width: 400px;
}

.railway-toast.info {
    background: var(--space-blue, #004861);
}

.railway-toast.success {
    background: #059669;
}

.railway-toast.error {
    background: #DC2626;
}

.railway-toast-dismiss {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    padding: 2px;
    margin-left: 8px;
    font-size: 1rem;
    line-height: 1;
}

.railway-toast-dismiss:hover {
    color: #fff;
}

@keyframes toastSlideIn {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 600px) {
    .railway-banner {
        flex-direction: column;
        text-align: center;
    }

    .railway-status-grid {
        grid-template-columns: 1fr;
    }

    .railway-modal {
        width: 98vw;
    }
}
